Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java52
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java46
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java63
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java163
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java184
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java266
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java72
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java122
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java544
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java65
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java45
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java44
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java45
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java45
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java183
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java230
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java269
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java37
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java215
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java388
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java55
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java305
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java46
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java105
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java46
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java239
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java56
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java143
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java106
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties21
30 files changed, 0 insertions, 4200 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java
deleted file mode 100644
index 755a447c9..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AddArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the arithmetic + operator in EL
- *
- * @author cbateman
- *
- */
-/*package*/ class AddArithmeticBinaryOperator extends NoDivArithmeticBinaryOperator {
-
- private static final String ADDITION = "addition"; //$NON-NLS-1$
-
- AddArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- protected Long doRealOperation(Long firstArg, Long secondArg)
- {
- return Long.valueOf(firstArg.longValue() + secondArg.longValue());
- }
-
- protected Double doRealOperation(Double firstArg, Double secondArg) {
- return Double.valueOf(firstArg.doubleValue() + secondArg.doubleValue());
- }
-
- protected BigDecimal doRealOperation(BigDecimal firstArg,
- BigDecimal secondArg)
- {
- return firstArg.add(secondArg);
- }
-
- protected String getOperatorName() {
- return ADDITION;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java
deleted file mode 100644
index 2ef4a2523..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/AndBinaryOperator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-
-/**
- * Encapsulates the 'and'/'&&' boolean-AND operator
- * Based on JSP.2.3.6.1
- *
- * @author cbateman
- *
- */
-/*package*/class AndBinaryOperator extends LogicalBinaryOperator
-{
-
- AndBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- protected boolean doRealOperation(Boolean firstArg, Boolean secondArg)
- {
- return (firstArg.booleanValue() && secondArg.booleanValue());
- }
-
- protected String readableOperatorName()
- {
- return "logical-AND"; //$NON-NLS-1$
- }
-
- protected boolean shortCircuitValue() {
- // AND short-circuits on false
- return false;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java
deleted file mode 100644
index 3f7000046..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Super for all arithmetic binary operators -- +, -, *,/,%
- *
- * @author cbateman
- *
- */
-/*package*/ abstract class ArithmeticBinaryOperator extends BinaryOperator
-{
- ArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- public abstract ValueType performOperation(ValueType firstArg, ValueType secondArg);
- public abstract Diagnostic validate(ValueType firstArg, ValueType secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of firstArg op secondArg
- */
- protected abstract Long doRealOperation(Long firstArg, Long secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of firstArg op secondArg
- */
- protected abstract Double doRealOperation(Double firstArg, Double secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of firstArg op secondArg
- */
- protected abstract BigDecimal doRealOperation(BigDecimal firstArg, BigDecimal secondArg);
-
- /**
- * @return human-readable name of the operator
- */
- protected abstract String getOperatorName();
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java
deleted file mode 100644
index 58661da4e..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BinaryOperator.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants;
-import org.eclipse.jst.jsp.core.internal.java.jspel.Token;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- * Represents an abstract EL binary operator that always
- * takes arguments and produces a single results
- *
- * @author cbateman
- *
- */
-public abstract class BinaryOperator
-{
- /**
- * the factory used to construct diagnostics
- */
- protected final DiagnosticFactory _diagnosticFactory;
-
- /**
- * @param operatorToken
- * @param diagnosticFactory
- * @param context -- the current EL document context; must not be null
- * @return a binary operator based on the provided token
- * @throws IllegalArgumentException if the token is not a recognized
- * EL binary operator token or if context is null
- */
- public static BinaryOperator getBinaryOperator(Token operatorToken, DiagnosticFactory diagnosticFactory, IStructuredDocumentContext context)
- {
- if (context == null)
- {
- throw new IllegalArgumentException("Context must not be null"); //$NON-NLS-1$
- }
- final String facetVersion = determineJSFVersion(context);
-
- switch (operatorToken.kind)
- {
- case JSPELParserConstants.AND1:
- case JSPELParserConstants.AND2:
- return new AndBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.OR1:
- case JSPELParserConstants.OR2:
- return new OrBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.EQ1:
- case JSPELParserConstants.EQ2:
- return new EqualsBinaryRelationalOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.NEQ1:
- case JSPELParserConstants.NEQ2:
- return new NotEqualsBinaryRelationalOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.GT1:
- case JSPELParserConstants.GT2:
- return new GreaterThanRelationalBinaryOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.GE1:
- case JSPELParserConstants.GE2:
- return new GreaterThanEqRelationalBinaryOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.LT1:
- case JSPELParserConstants.LT2:
- return new LessThanRelationalBinaryOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.LE1:
- case JSPELParserConstants.LE2:
- return new LessThanEqRelationalBinaryOperator(diagnosticFactory,facetVersion);
-
- case JSPELParserConstants.PLUS:
- return new AddArithmeticBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.MINUS:
- return new SubtractArithmeticBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.MULTIPLY:
- return new MultiplyArithmeticBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.DIVIDE1:
- case JSPELParserConstants.DIVIDE2:
- return new DivArithmeticBinaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.MODULUS1:
- case JSPELParserConstants.MODULUS2:
- return new ModArithmeticBinaryOperator(diagnosticFactory);
- }
-
- throw new IllegalArgumentException("Unknown binary operator: "+operatorToken.image); //$NON-NLS-1$
- }
-
- /**
- *
- * Constructor
- */
- BinaryOperator(DiagnosticFactory diagnosticFactory)
- {
- /* no construction or sub-classing outside package*/
- _diagnosticFactory = diagnosticFactory;
- }
-
- /**
- * If both arguments are literals and the operation can be performed, then
- * the return must be a new LiteralType transformed using this operator.
- *
- * If one or both of the arg is not a literal and the operaton can be performed, then
- * the return is a new ValueType transformed per the rules of the operator
- *
- * If the operation cannot be performed on ValueType, return null
- *
- * @param firstArg
- * @param secondArg
- * @return a new value type after the operation is performed
- */
- public abstract ValueType performOperation(ValueType firstArg, ValueType secondArg);
-
-
- /**
- * @param firstArg
- * @param secondArg
- * @return a Diagnostic interpreting whether it is valid to perform the
- * operation on the two arguments
- */
- public abstract Diagnostic validate(ValueType firstArg, ValueType secondArg);
-
- private static String determineJSFVersion(IStructuredDocumentContext context)
- {
- final IWorkspaceContextResolver wkResolver =
- IStructuredDocumentContextResolverFactory.
- INSTANCE.getWorkspaceContextResolver(context);
-
- IProject project = wkResolver.getProject();
-
- IProjectFacetVersion projectVersion = JSFAppConfigUtils.getProjectFacet(project);
-
- if (projectVersion != null)
- {
- return projectVersion.getVersionString();
- }
-
- return null;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java
deleted file mode 100644
index ac9308fb9..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/BracketOperator.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.context.symbol.IObjectSymbol;
-import org.eclipse.jst.jsf.context.symbol.ISymbol;
-import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType;
-import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager;
-import org.eclipse.jst.jsf.designtime.el.AbstractDTPropertyResolver;
-import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Handles the operator 'bracket' where bracket(expr-a, id-b) == 'expr-a[id-b]' in EL syntax
- *
- * @author cbateman
- *
- */
-public class BracketOperator extends MemberAccessorOperator
-{
- private static final String OPERATOR_NAME_ARRAY_ACCESSOR = "array ('[]') accessor"; //$NON-NLS-1$
-
- /**
- * @param diagnosticFactory
- * @param file
- * @param resolver
- */
- public BracketOperator(final DiagnosticFactory diagnosticFactory, final IFile file, final ISymbolContextResolver resolver)
- {
- super(file, diagnosticFactory, resolver);
- }
-
- protected SignatureBasedType handlePerformObjectSymbolValue(
- IObjectSymbolBasedValueType firstArg, ValueType secondArg)
- {
- // per JSP.2.3.4 step 5.2, if value-a is a list or array access
- if (firstArg.isInstanceOf(TypeConstants.TYPE_LIST)
- || Signature.getArrayCount(firstArg.getSignature()) > 0)
- {
- return handlePerformNumericPropertyAccessorBase(firstArg, secondArg);
- }
-
- // per JSP.2.3.4 step 5, if value-a is a map or if it is not
- // a list or array (and therefore a bean), treat it as named property accessed object
- // if firstArg is a map then we must treat the access like a map.get(secondArg)
-
- // if we don't have a literal value with which to derive value-b, then
- // we can't get a property
- if (secondArg instanceof LiteralType)
- {
- return handlePerformNamedPropertyAccessorBase(firstArg, (LiteralType)secondArg);
- }
-
- return null;
- }
-
- protected Diagnostic validateObjectSymbolValue(IObjectSymbolBasedValueType firstArg,
- ValueType secondArg)
- {
- // per JSP.2.3.4 step 5.2, if value-a is a list or array access
- if (firstArg.isInstanceOf(TypeConstants.TYPE_LIST)
- || firstArg.getSymbol().getTypeDescriptor().isArray())
- {
- return validateNumericPropertyAccessorBase(firstArg, secondArg);
- }
-
- // per JSP.2.3.4 step 5, if value-a is a map or if it is not
- // a list or array (and therefore a bean), treat it as named property accessed object
- // if firstArg is a map then we must treat the access like a map.get(secondArg)
- if (secondArg instanceof LiteralType)
- {
- return validateNamedPropertyAccessorBase(firstArg, (LiteralType) secondArg);
- }
- // otherwise, there's nothing we can guarantee
- return Diagnostic.OK_INSTANCE;
- }
-
- private Diagnostic validateNumericPropertyAccessorBase(IObjectSymbolBasedValueType firstArg,
- ValueType secondArg)
- {
- try
- {
- // secondArg must successfully coerce to integer
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- if (secondArg instanceof LiteralType)
- {
- // this will throw a TypeCoercionExceptino if it won't
- // coerce
- Integer integerValue =
- (Integer) ((LiteralType)secondArg).coerceToNumber(Integer.class);
-
- if (integerValue.intValue() < 0)
- {
- return _diagnosticFactory.create_POSSIBLE_ARRAY_INDEX_OUT_OF_BOUNDS(integerValue);
- }
- }
- else
- {
- // if the argument is a non-literal string, we can't verify
- // that the coercion to integer won't throw an exception
- // at runtime
- if (TypeCoercer.typeIsString(secondArg.getSignature()))
- {
- return _diagnosticFactory.create_UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED(OPERATOR_NAME_ARRAY_ACCESSOR);
- }
- }
-
- // TODO: attempt to detect ArrayIndexOutOfBoundsException
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException e)
- {
- return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(OPERATOR_NAME_ARRAY_ACCESSOR);
- }
- }
-
- private SignatureBasedType handlePerformNumericPropertyAccessorBase(IObjectSymbolBasedValueType firstArg,
- ValueType secondArg)
- {
- AbstractDTPropertyResolver propResolver = getPropertyResolver();
- int index = 0;
- if (secondArg instanceof LiteralType)
- {
- try {
- index = ((LiteralType)secondArg).coerceToNumber(Integer.class).intValue();
- } catch (TypeCoercionException e) {
- // suppress, just use index = 0
- // this maybe should be an assertion...
- }
- }
-
- final ISymbol symbol =
- propResolver.getProperty(firstArg.getSymbol(), index);
-
- if (symbol instanceof IObjectSymbol)
- {
- return IObjectSymbolBasedValueType.getInstance(symbol);
- }
-
- // if can't be resolved, return null
- return null;
- }
-
- @Override
- protected String getOperatorName()
- {
- return Messages.getString("BracketOperator.Name"); //$NON-NLS-1$
- }
-
- /**
- * @return the property resolver for the current source file
- */
- private AbstractDTPropertyResolver getPropertyResolver()
- {
- final DesignTimeApplicationManager manager =
- DesignTimeApplicationManager.getInstance(_file.getProject());
-
- if (manager != null)
- {
- return manager.getPropertyResolver();
- }
-
- return null;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java
deleted file mode 100644
index 67242ec60..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DivArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents dividing EL binary operators: div and / (same operator)
- * Based on JSP.2.3.5.2
- *
- * @author cbateman
- *
- */
-/*package*/ class DivArithmeticBinaryOperator extends ArithmeticBinaryOperator
-{
-
- private static final String DIVISION = "division"; //$NON-NLS-1$
-
- DivArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- // TODO Auto-generated constructor stub
- }
-
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- // JSP.2.3.5.2, step one: if both null then always 0
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return new IntegerLiteralType(0);
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.2, step 2: if one arg is BigInteger or BigDecimal
- // then coerce to BigDecimal and do div
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return performBigDecimal(firstArg, secondArg);
- }
-
- return performDouble(firstArg, secondArg);
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg) {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.3.5.2, step one: if both null then always 0
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(DIVISION);
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.2, step 2: if one arg is BigInteger or BigDecimal
- // then coerce to BigDecimal and do div
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return validateBigDecimal(firstArg, secondArg);
- }
-
- return validateDouble(firstArg, secondArg);
- }
-
- private ValueType performBigDecimal(ValueType firstArg, ValueType secondArg)
- {
- // since one or the other args must be either big decimal or big int,
- // we don't have two literals, so it is sufficient to ensure that we can
- // coerce both to numbers and check for div by zero and div of zero
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- // if we get to here, the result is always BigDecimal unless we have
- // a div by zero
- if (secondArg instanceof LiteralType)
- {
- final Number coercedValue = ((LiteralType)secondArg).coerceToNumber(BigDecimal.class);
- if (((BigDecimal)coercedValue).equals(new BigDecimal(0)))
- {
- return null;
- }
- }
-
- return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException ce)
- {
- return null;
- }
- }
-
- private ValueType performDouble(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class);
- // if the second value is definitely 0, then return null since
- // we have a div by zero
- if (secondValue.doubleValue() == 0.0)
- {
- return null;
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- return new FloatLiteralType(
- doRealOperation(new Double(firstValue.doubleValue())
- , new Double(secondValue.doubleValue())).doubleValue());
- }
-
- // if not both literals and could coerce, then the type is double
- return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException ce)
- {
- // could not coerce for the operation
- return null;
- }
- }
-
- private Diagnostic validateBigDecimal(ValueType firstArg, ValueType secondArg)
- {
- // since one or the other args must be either big decimal or big int,
- // we don't have two literals, so it is sufficient to ensure that we can
- // coerce both to numbers and check for div by zero and div of zero
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- // if we get to here, the result is always BigDecimal unless we have
- // a div by zero
- if (secondArg instanceof LiteralType)
- {
- final Number coercedValue = ((LiteralType)secondArg).coerceToNumber(BigDecimal.class);
- if (((BigDecimal)coercedValue).equals(new BigDecimal(0)))
- {
- return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO();
- }
- }
-
- // everything's okay if we get here
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException ce)
- {
- return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(DIVISION);
- }
- }
-
- private Diagnostic validateDouble(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class);
- // if the second value is definitely 0, then return null since
- // we have a div by zero
- if (secondValue.doubleValue() == 0.0)
- {
- return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO();
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- String result
- = Double.toString(
- doRealOperation(new Double(firstValue.doubleValue()),
- new Double(secondValue.doubleValue())).doubleValue());
-
- return _diagnosticFactory.create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME(DIVISION, result);
- }
-
- // if not both literals and could coerce, then the type is double
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException ce)
- {
- // could not coerce for the operation
- return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(DIVISION);
- }
- }
-
- protected BigDecimal doRealOperation(BigDecimal firstArg, BigDecimal secondArg) {
- // per JSP.2.3.5.2, step 2
- return firstArg.divide(secondArg, BigDecimal.ROUND_HALF_UP);
- }
-
- protected Double doRealOperation(Double firstArg, Double secondArg)
- {
- return new Double(firstArg.doubleValue() / secondArg.doubleValue());
- }
-
- protected Long doRealOperation(Long firstArg, Long secondArg) {
- return Long.valueOf(firstArg.longValue() / secondArg.longValue());
- }
-
- protected String getOperatorName() {
- return DIVISION;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java
deleted file mode 100644
index f31950cc7..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/DotOperator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType;
-import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Handles the operator 'dot' where dot(expr-a, id-b) == 'expr-a.id-b' in EL syntax
- *
- * @author cbateman
- *
- */
-public class DotOperator extends MemberAccessorOperator
-{
- /**
- * @param diagnosticFactory
- * @param file
- * @param resolver
- */
- public DotOperator(final DiagnosticFactory diagnosticFactory, final IFile file, final ISymbolContextResolver resolver)
- {
- super(file, diagnosticFactory, resolver);
- }
-
- protected SignatureBasedType handlePerformObjectSymbolValue(
- IObjectSymbolBasedValueType firstArg, ValueType secondArg)
- {
- // the dot operator (unlike the bracket) can only treat firstArg as
- // a named property accessor object
- // if we don't have a literal value with which to derive value-b, then
- // we can't get a property
- if (secondArg instanceof LiteralType)
- {
- return handlePerformNamedPropertyAccessorBase(firstArg, (LiteralType)secondArg);
- }
- return null;
- }
-
- public Diagnostic validateObjectSymbolValue(IObjectSymbolBasedValueType firstArg,
- ValueType secondArg)
- {
- Diagnostic diag = Diagnostic.OK_INSTANCE;
-
- if (secondArg instanceof LiteralType)
- {
- diag = validateNamedPropertyAccessorBase(firstArg, (LiteralType) secondArg);
- }
-
- return diag;
- }
-
- @Override
- protected String getOperatorName()
- {
- return Messages.getString("DotOperator.Name"); //$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java
deleted file mode 100644
index 8da62be01..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EmptyUnaryOperator.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.NullLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.StringLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL unary operator '-' on a ValueType
- * as described by JSP.2.3.7
- *
- * @author cbateman
- *
- */
-/*package*/ class EmptyUnaryOperator extends UnaryOperator
-{
- private static final String EMPTY = "empty"; //$NON-NLS-1$
-
- EmptyUnaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- public ValueType performOperation(ValueType type)
- {
- if (type instanceof StringLiteralType)
- {
- if ("".equals(((StringLiteralType)type).getLiteralValue())) //$NON-NLS-1$
- {
- // if the string is empty, operator always returns true
- return BooleanLiteralType.TRUE;
- }
-
- // if the string is empty, operator always returns true
- return BooleanLiteralType.FALSE;
- }
-
- // empty(null) is always true
- if (type instanceof NullLiteralType)
- {
- return BooleanLiteralType.TRUE;
- }
-
- // if the type is not string, array, Map, or Collection
- // then empty is always false
- String testSig = type.getSignature();
-
- if (!TypeConstants.TYPE_STRING.equals(testSig)
- && !type.isInstanceOf(TypeConstants.TYPE_COLLECTION)
- && !type.isInstanceOf(TypeConstants.TYPE_MAP)
- && Signature.getTypeSignatureKind(testSig) != Signature.ARRAY_TYPE_SIGNATURE)
- {
- return BooleanLiteralType.FALSE;
- }
-
- // otherwise, return a generic boolean type
- return new ValueType(TypeConstants.TYPE_BOOLEAN, type.getAssignability());
- }
-
- public Diagnostic validate(ValueType type)
- {
- // empty always validates to false unless:
- // the value is an empty string, array, map or collection
- // one thing we do is see if the thing is a literal. If it is
- // we can warn that the value could be folded
- if (type instanceof StringLiteralType)
- {
- String condition;
-
- if ("".equals(((StringLiteralType)type).getLiteralValue())) //$NON-NLS-1$
- {
- condition = "true"; //$NON-NLS-1$
- }
- else
- {
- condition = "false"; //$NON-NLS-1$
- }
-
- return _diagnosticFactory.
- create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID
- (EMPTY,condition);
- }
-
- // empty(null) is always true
- if (type instanceof NullLiteralType)
- {
- return _diagnosticFactory.
- create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID
- (EMPTY,"true"); //$NON-NLS-1$
- }
-
- // if the type is not string, array, Map, or Collection warn that
- // this may be always false
- String testSig = type.getSignature();
-
- if (!TypeConstants.TYPE_STRING.equals(testSig)
- && !type.isInstanceOf(TypeConstants.TYPE_COLLECTION)
- && !type.isInstanceOf(TypeConstants.TYPE_MAP)
- && Signature.getTypeSignatureKind(testSig) != Signature.ARRAY_TYPE_SIGNATURE)
- {
- return _diagnosticFactory.create_UNARY_OP_EMPTY_ALWAYS_FALSE_ON_TYPE();
- }
-
- return Diagnostic.OK_INSTANCE;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java
deleted file mode 100644
index 963f9ad00..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualityRelationalBinaryOperator.java
+++ /dev/null
@@ -1,544 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.StringLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.common.util.TypeUtil;
-import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * A relational binary operator for equality: "==" or "!="
- *
- * @author cbateman
- *
- */
-/*package*/ abstract class EqualityRelationalBinaryOperator extends RelationalBinaryOperator
-{
- EqualityRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion)
- {
- super(diagnosticFactory, jsfVersion);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected abstract boolean doRealOperation(Boolean firstArg, Boolean secondArg);
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.jsf.validation.internal.el.operators.BinaryOperator#performOperation(org.eclipse.jst.jsf.core.internal.types.ValueType, org.eclipse.jst.jsf.core.internal.types.ValueType)
- */
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- // JSP.2.3.5.7 step 1 if operands are equal, then true for ==, false for !=
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- // perform the operation on two arguments that are equal.
- return BooleanLiteralType.valueOf(doRealOperation(Integer.valueOf(4), Integer.valueOf(4)));
- }
-
- String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.7 step 3, if either is BigDecimal, promote both and compare
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.7, step 4 if either is a float or double, promote both to
- // double and compare
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.7, step 5 if either is a big integer, promote and compare
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.7, step 6 if either is Long or smaller, coerce both to Long
- if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, Long.class);
- }
-
- // JSP.2.3.5.7, step 7 if either is a boolean, coerce to boolean
- if (TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedSecondType))
- {
- return handleBooleanComparison(firstArg, secondArg);
- }
-
- // Unified EL 1.8.2, step 8 if either is a enum, then coerce both to enum
- // NOTE: we handle the JSF 1.1 case also where enums are treated as non-coercable
- // Object's
- if (firstArg.isEnumType() || secondArg.isEnumType())
- {
- return handleEnumComparison(firstArg, secondArg);
- }
-
- // JSP.2.3.5.7, step 8 if either is a string, coerce to string and
- // compare lexically
- if (TypeConstants.TYPE_STRING.equals(boxedFirstType)
- || TypeConstants.TYPE_STRING.equals(boxedSecondType))
- {
- return handleStringComparison(firstArg, secondArg);
- }
-
- // otherwise, an equal compare will be done A.equals(B). Since
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- private ValueType handleEnumComparison(ValueType firstArg,
- ValueType secondArg)
- {
- assert firstArg.isEnumType() || secondArg.isEnumType();
-
- // if the first is not an enum, then we have non-Enum == Enum case
- if (!firstArg.isEnumType())
- {
- return handleComparsionOfEnumAndNonEnum(secondArg, firstArg);
- }
-
- // if the second is not an enum, then we have Enum == non-Enum case
- if (!secondArg.isEnumType())
- {
- return handleComparsionOfEnumAndNonEnum(firstArg, secondArg);
- }
-
- // only other case is they are both enums. Check if they are directly
- // comparable.
- if (TypeUtil.canNeverBeEqual(firstArg.getSignature(), secondArg.getSignature()))
- {
- boolean result = doRealOperation("foo", "notFoo"); // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$
-
- return BooleanLiteralType.valueOf(result);
- }
-
- // otherwise, all we know is that it's a boolean
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- private ValueType handleComparsionOfEnumAndNonEnum(ValueType enumType,
- ValueType nonEnumType)
- {
- // the only literal value that could have got us here is a
- // StringLiteralValue since the others a filtered out before this is
- // called
- if (nonEnumType instanceof LiteralType)
- {
- assert nonEnumType instanceof StringLiteralType;
-
- Diagnostic result = validateIfEnumToStringComparison(((StringLiteralType)nonEnumType).getLiteralValue(), enumType);
-
- if (result != null)
- {
- // compare two things that aren't equal
- return BooleanLiteralType.valueOf(doRealOperation("foo", "foo_")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- // if the arg is a String, then we can't prove anything before runtime
- if (nonEnumType.isInstanceOf(TypeConstants.TYPE_STRING))
- {
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- // otherwise, we know it will result in a problem since one is an enum
- // and the other isn't so simply do a comparison on two things that aren't equals
- return BooleanLiteralType.valueOf(doRealOperation("foo", "foo_")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg) {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.3.5.7 step 2 if either operand is null, then not equal
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- // perform the operation on two arguments that are equal.
- final boolean result = doRealOperation(Integer.valueOf(4), Integer.valueOf(4));
- return _diagnosticFactory.create_BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME(Boolean.toString(result));
- }
-
- final String boxedFirstType =
- TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondType =
- TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.7 step 3, if either is BigDecimal, promote both and compare
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.7, step 4 if either is a float or double, promote both to
- // double and compare
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.7, step 5 if either is a big integer, promote and compare
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.7, step 6 if either is Long or smaller, coerce both to Long
- if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, Long.class);
- }
-
- // JSP.2.3.5.7, step 7 if either is a boolean, coerce to boolean
- if (TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BOOLEAN.equals(boxedSecondType))
- {
- return validateBooleanComparison(firstArg, secondArg);
- }
-
- // Unified EL 1.8.2, step 8 if either is a enum, then coerce both to enum
- // NOTE: we handle the JSF 1.1 case also where enums are treated as non-coercable
- // Object's
- if (firstArg.isEnumType() || secondArg.isEnumType())
- {
- return validateEnumComparison(firstArg, secondArg);
- }
-
- // JSP.2.3.5.7, step 8 if either is a string, coerce to string and
- // compare lexically
- if (TypeConstants.TYPE_STRING.equals(boxedFirstType)
- || TypeConstants.TYPE_STRING.equals(boxedSecondType))
- {
- return validateStringComparison(firstArg, secondArg);
- }
-
- // otherwise, an equal compare will be done A.equals(B). Since
- return Diagnostic.OK_INSTANCE;
- }
-
-
- /**
- * Both types are coerced to boolean before comparison
- *
- * @param firstArg
- * @param secondArg
- * @return the result of the comparison
- */
- private ValueType handleBooleanComparison(ValueType firstArg, ValueType secondArg)
- {
- boolean canCoerceFirstArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- boolean canCoerceSecondArg = TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- if (! (canCoerceFirstArg && canCoerceSecondArg))
- {
- return null;
- }
-
- if (firstArg instanceof LiteralType && secondArg instanceof LiteralType)
- {
- try
- {
- Boolean firstValue = ((LiteralType)firstArg).coerceToBoolean();
- Boolean secondValue = ((LiteralType)secondArg).coerceToBoolean();
-
- if (firstValue != null && secondValue != null)
- {
- boolean result = doRealOperation(firstValue, secondValue);
- return result ?
- BooleanLiteralType.TRUE :
- BooleanLiteralType.FALSE;
- }
- }
- catch (TypeCoercionException tce)
- {
- throw new AssertionError("should never get here; have already checked coercability above"); //$NON-NLS-1$
- }
- }
-
- // otherwise, we have a valid comparison that results in boolean
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- private Diagnostic validateBooleanComparison(ValueType firstType, ValueType secondType)
- {
- boolean canCoerceFirstArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstType.getSignature()));
- boolean canCoerceSecondArg = TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondType.getSignature()));
-
- if (!canCoerceFirstArg)
- {
- return _diagnosticFactory.create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(Messages.getString("EqualityRelationalBinaryOperator.FirstArgument")); //$NON-NLS-1$
- }
-
- if (!canCoerceSecondArg)
- {
- return _diagnosticFactory.create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN(Messages.getString("EqualityRelationalBinaryOperator.SecondArgument")); //$NON-NLS-1$
- }
-
- if (firstType instanceof LiteralType && secondType instanceof LiteralType)
- {
- try
- {
- Boolean firstValue = ((LiteralType)firstType).coerceToBoolean();
- Boolean secondValue = ((LiteralType)secondType).coerceToBoolean();
-
- if (firstValue != null && secondValue != null)
- {
- final boolean result =
- doRealOperation(firstValue, secondValue);
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME(getOperationName(), Boolean.toString(result));
- }
- }
- catch (TypeCoercionException tce)
- {
- throw new AssertionError("should never get here; have already checked coercability above"); //$NON-NLS-1$
- }
- }
-
- // otherwise, we have a valid comparison
- return Diagnostic.OK_INSTANCE;
- }
-
- @Override
- protected Diagnostic validateStringComparison(ValueType firstType,
- ValueType secondType)
- {
- String firstValue = null;
-
- if (firstType instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstType).getLiteralValue();
- }
-
- String secondValue = null;
- if (secondType instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondType).getLiteralValue();
- }
-
- if (firstValue != null)
- {
- Diagnostic result = validateIfEnumToStringComparison(firstValue, secondType);
-
- if (result != null)
- {
- return result;
- }
- }
-
- if (secondValue != null)
- {
- Diagnostic result = validateIfEnumToStringComparison(secondValue, firstType);
-
- if (result != null)
- {
- return result;
- }
- }
-
- // if it's a string to enum compare, do the default parent thing
- return super.validateStringComparison(firstType, secondType);
- }
-
-
- @Override
- protected ValueType handleStringComparison(ValueType firstType,
- ValueType secondType)
- {
- String firstValue = null;
-
- if (firstType instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstType).getLiteralValue();
- }
-
- String secondValue = null;
- if (secondType instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondType).getLiteralValue();
- }
-
- if (firstValue != null)
- {
- Diagnostic result = validateIfEnumToStringComparison(firstValue, secondType);
-
- if (result != null)
- {
- return handleIfEnumToNonMemberStringComparison(firstValue, secondType);
- }
- }
-
- if (secondValue != null)
- {
- Diagnostic result = validateIfEnumToStringComparison(secondValue, firstType);
-
- if (result != null)
- {
- return handleIfEnumToNonMemberStringComparison(secondValue, firstType);
- }
- }
-
- // otherwise, do the super thing
- return super.handleStringComparison(firstType, secondType);
- }
-
- private Diagnostic validateEnumComparison(final ValueType firstArg, final ValueType secondArg)
- {
- assert firstArg.isEnumType() || secondArg.isEnumType();
-
- // if the first is not an enum, then we have non-Enum == Enum case
- if (!firstArg.isEnumType())
- {
- return validateComparsionOfEnumAndNonEnum(firstArg, secondArg);
- }
-
- // if the second is not an enum, then we have Enum == non-Enum case
- if (!secondArg.isEnumType())
- {
- return validateComparsionOfEnumAndNonEnum(secondArg, firstArg);
- }
-
- // only other case is they are both enums. Check if they are directly
- // comparable.
- if (TypeUtil.canNeverBeEqual(firstArg.getSignature(), secondArg.getSignature()))
- {
- return _diagnosticFactory.
- create_BINARY_COMPARISON_WITH_TWO_ENUMS_ALWAYS_SAME
- (getOperationName()
- , doRealOperation("foo", "notFoo") // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$
- , TypeUtil.getFullyQualifiedName(firstArg.getSignature())
- , TypeUtil.getFullyQualifiedName(secondArg.getSignature()));
- }
-
- // otherwise, it's all good
- return Diagnostic.OK_INSTANCE;
- }
-
- private Diagnostic validateComparsionOfEnumAndNonEnum(final ValueType nonEnumType, final ValueType enumType)
- {
- // the only literal value that could have got us here is a
- // StringLiteralValue since the others a filtered out before this is
- // called
- if (nonEnumType instanceof LiteralType)
- {
- assert nonEnumType instanceof StringLiteralType;
-
- Diagnostic result = validateIfEnumToStringComparison(((StringLiteralType)nonEnumType).getLiteralValue(), enumType);
-
- if (result != null)
- {
- return result;
- }
- return Diagnostic.OK_INSTANCE;
- }
-
- // if the arg is a String, then we can't prove anything before runtime
- if (nonEnumType.isInstanceOf(TypeConstants.TYPE_STRING))
- {
- return Diagnostic.OK_INSTANCE;
- }
- // otherwise, we know it will result in a problem since one is an enum
- // and the other isn't
- return _diagnosticFactory.
- create_BINARY_COMPARISON_WITH_ENUM_AND_UNCOERCABLE_NONCONST_ALWAYS_SAME
- (getOperationName()
- , doRealOperation("foo", "notFoo") // just simulate the operation where the operands are not equal //$NON-NLS-1$ //$NON-NLS-2$
- , TypeUtil.getFullyQualifiedName(enumType.getSignature())
- , TypeUtil.getFullyQualifiedName(nonEnumType.getSignature()));
- }
-
- private Diagnostic validateIfEnumToStringComparison(final String literalValue, final ValueType validateIfEnum)
- {
- if (validateIfEnum.isEnumType()
- && validateIfEnum instanceof IObjectSymbolBasedValueType)
- {
- final IObjectSymbolBasedValueType symbolValueType =
- (IObjectSymbolBasedValueType) validateIfEnum;
-
- IType type = symbolValueType.getSymbol().getTypeDescriptor().resolveType(symbolValueType.getSymbol().getTypeDescriptor().getTypeSignature());
-
- if (type != null && !TypeUtil.isEnumMember(type, literalValue))
- {
- return _diagnosticFactory.
- create_BINARY_COMPARISON_WITH_ENUM_AND_CONST_ALWAYS_SAME
- (getOperationName()
- , doRealOperation(literalValue, literalValue+"_") // just simulate the operation where the operands are not equal //$NON-NLS-1$
- , TypeUtil.getFullyQualifiedName(validateIfEnum.getSignature())
- , literalValue);
- }
- }
-
- return null;
- }
-
- private ValueType handleIfEnumToNonMemberStringComparison(final String literalValue, final ValueType enumValueType)
- {
- // we need to apply the real operation to literalValue and any string that !equals(literalValue)
- // since it's not a member of the enum
- return BooleanLiteralType.valueOf(doRealOperation(literalValue, literalValue+"_")); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java
deleted file mode 100644
index 3fa99f472..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/EqualsBinaryRelationalOperator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the equals -- ==/eq EL binary operator
- *
- * @author cbateman
- *
- */
-/*package*/ class EqualsBinaryRelationalOperator extends
- EqualityRelationalBinaryOperator
-{
-
- EqualsBinaryRelationalOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) {
- super(diagnosticFactory, jsfVersion);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected boolean doRealOperation(Number firstArg, Number secondArg)
- {
- return firstArg.equals(secondArg);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected boolean doRealOperation(Boolean firstArg, Boolean secondArg)
- {
- return firstArg.equals(secondArg);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected boolean doRealOperation(String firstArg, String secondArg)
- {
- return firstArg.equals(secondArg);
- }
-
- protected String getOperationName()
- {
- return Messages.getString("EqualsBinaryRelationalOperator.OperationName"); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java
deleted file mode 100644
index edab570f8..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanEqRelationalBinaryOperator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Encapsulates the EL greater-than-eq operator -- ">="/ge
- *
- * @author cbateman
- *
- */
-/*package*/ class GreaterThanEqRelationalBinaryOperator extends
- LtGtRelationalBinaryOperator
-{
- GreaterThanEqRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected boolean doRealOperation(Number firstArg, Number secondArg)
- {
- return ((Comparable)firstArg).compareTo(secondArg) >= 0;
- }
-
- protected boolean doRealOperation(String firstArg, String secondArg)
- {
- return firstArg.compareTo(secondArg) >= 0;
- }
-
- protected String getOperationName()
- {
- return Messages.getString("GreaterThanEqRelationalBinaryOperator.OperationName"); //$NON-NLS-1$
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java
deleted file mode 100644
index 78a62a7a6..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/GreaterThanRelationalBinaryOperator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL greater than operator -- ">"/gt
- * @author cbateman
- *
- */
-/*package*/ class GreaterThanRelationalBinaryOperator extends
- LtGtRelationalBinaryOperator {
-
- GreaterThanRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion)
- {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected boolean doRealOperation(Number firstArg, Number secondArg)
- {
- return ((Comparable)firstArg).compareTo(secondArg) > 0;
- }
-
- protected boolean doRealOperation(String firstArg, String secondArg)
- {
- return firstArg.compareTo(secondArg) > 0;
- }
-
- protected String getOperationName()
- {
- return Messages.getString("GreaterThanRelationalBinaryOperator.OperationName"); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java
deleted file mode 100644
index 24dc5e2a5..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanEqRelationalBinaryOperator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-
-/**
- * Encapsulates the EL less-than-equal operator -- "<="/le
- *
- * @author cbateman
- *
- */
-/*package*/ class LessThanEqRelationalBinaryOperator extends
- LtGtRelationalBinaryOperator
-{
- LessThanEqRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion) {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected boolean doRealOperation(Number firstArg, Number secondArg)
- {
- return ((Comparable)firstArg).compareTo(secondArg) <= 0;
- }
-
- protected boolean doRealOperation(String firstArg, String secondArg)
- {
- return firstArg.compareTo(secondArg) <= 0;
- }
-
- protected String getOperationName()
- {
- return Messages.getString("LessThanEqRelationalBinaryOperator.OperationName"); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java
deleted file mode 100644
index 7b8e7ea7b..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LessThanRelationalBinaryOperator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * The "<"/"lt" less-than EL operator
- *
- * @author cbateman
- *
- */
-/*package*/ class LessThanRelationalBinaryOperator extends
- LtGtRelationalBinaryOperator
-{
- LessThanRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion)
- {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected boolean doRealOperation(Number firstArg, Number secondArg)
- {
- return ((Comparable)firstArg).compareTo(secondArg) < 0;
- }
-
- protected boolean doRealOperation(String firstArg, String secondArg)
- {
- return firstArg.compareTo(secondArg) < 0;
- }
-
- protected String getOperationName()
- {
- return Messages.getString("LessThanRelationalBinaryOperator.OperationName"); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java
deleted file mode 100644
index deb4e9b7f..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LogicalBinaryOperator.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents a logical binary operator per JSP.2.3.6.1 (logical and/or)
- *
- * @author cbateman
- *
- */
-/*package*/abstract class LogicalBinaryOperator extends BinaryOperator
-{
- LogicalBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- final boolean canCoerceFirstArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- final boolean canCoerceSecondArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- // if can't perform, must return null
- if (! (canCoerceFirstArg && canCoerceSecondArg))
- {
- return null;
- }
-
- Boolean firstArgResolvedValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- try
- {
- firstArgResolvedValue = ((LiteralType)firstArg).coerceToBoolean();
- }
- catch (TypeCoercionException tce)
- {
- // should never be throw due to already checking if can coerce
- throw new AssertionError("coercion already checked; this should never be reached"); //$NON-NLS-1$
- }
- }
-
- Boolean secondArgResolvedValue = null;
- if (secondArg instanceof LiteralType)
- {
- try
- {
- secondArgResolvedValue = ((LiteralType)secondArg).coerceToBoolean();
- }
- catch (TypeCoercionException tce)
- {
- // should never be throw due to already checking if can coerce
- throw new AssertionError("coercion already checked; this should never be reached"); //$NON-NLS-1$
- }
- }
-
- if (firstArgResolvedValue != null && secondArgResolvedValue != null)
- {
- boolean result =
- doRealOperation(firstArgResolvedValue, secondArgResolvedValue);
-
- return result ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE;
-
- }
-
- // otherwise, just return a boolean
- // result can only be an rvalue
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- final boolean canCoerceFirstArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- final boolean canCoerceSecondArg =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- if (!canCoerceFirstArg)
- {
- return _diagnosticFactory.
- create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN("first"); //$NON-NLS-1$
- //return new BasicDiagnostic(Diagnostic.ERROR, "", 0, "Cannot coerce first argument of "+readableOperatorName()+" to boolean", null);
- }
-
- if (!canCoerceSecondArg)
- {
- return _diagnosticFactory.
- create_BINARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN("first"); //$NON-NLS-1$
-
- //return new BasicDiagnostic(Diagnostic.ERROR, "", 0, "Cannot coerce second argument of "+readableOperatorName()+" to boolean", null);
- }
-
- if (firstArg instanceof LiteralType)
- {
- try
- {
- final Boolean boolValue =
- ((LiteralType)firstArg).coerceToBoolean();
-
- if (boolValue.booleanValue() == shortCircuitValue())
- {
- return _diagnosticFactory.
- create_BINARY_OP_FIRST_ARGUMENT_SHORT_CIRCUITS
- (shortCircuitValue(), readableOperatorName());
- }
- }
- catch (TypeCoercionException tce)
- {
- // should never be throw due to already checking if can coerce
- throw new AssertionError("coercion already checked; this should never be reached"); //$NON-NLS-1$
- }
- }
-
- if (secondArg instanceof LiteralType)
- {
- try
- {
- final Boolean boolValue =
- ((LiteralType)secondArg).coerceToBoolean();
-
- if (boolValue.booleanValue() == shortCircuitValue())
- {
- return _diagnosticFactory.
- create_BINARY_OP_SECOND_ARGUMENT_ALWAYS_EVAL_SAME
- (shortCircuitValue(), readableOperatorName());
- }
- }
- catch (TypeCoercionException tce)
- {
- // should never be throw due to already checking if can coerce
- throw new AssertionError("coercion already checked; this should never be reached"); //$NON-NLS-1$
- }
- }
-
- // otherwise, nothing to report
- return Diagnostic.OK_INSTANCE;
- }
-
- /**
- * @return a human readable name for the operator
- */
- protected abstract String readableOperatorName();
-
- /**
- * @return the boolean value on which the operator short-circuits
- */
- protected abstract boolean shortCircuitValue();
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of performing the operator to two actual values
- */
- protected abstract boolean doRealOperation(Boolean firstArg, Boolean secondArg);
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java
deleted file mode 100644
index 8d8445c5b..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/LtGtRelationalBinaryOperator.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.common.util.TypeUtil;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Encapsulates the EL binary operators "<", ">", "<=", ">="
- *
- * @author cbateman
- *
- */
-/*package*/ abstract class LtGtRelationalBinaryOperator extends RelationalBinaryOperator
-{
- LtGtRelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion)
- {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected abstract boolean doRealOperation(Number firstArg, Number secondArg);
-
- protected abstract boolean doRealOperation(String firstArg, String secondArg);
-
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- // JSP.2.3.5.6 step 2 if either operand is null, then always false
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- || TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return BooleanLiteralType.FALSE;
- }
-
- String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.6 step 3, if either is BigDecimal, promote both and compare
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.6, step 4 if either is a float or double, promote both to
- // double and compare
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.6, step 5 if either is a big integer, promote and compare
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.6, step 6 if either is Long or smaller, coerce both to Long
- if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType))
- {
- return handleNumericComparison(firstArg, secondArg, Long.class);
- }
-
- // JSP.2.3.5.7, step 7 if either is a string, coerce to string and
- // compare lexically
- if (TypeConstants.TYPE_STRING.equals(boxedFirstType)
- || TypeConstants.TYPE_STRING.equals(boxedSecondType))
- {
- return handleStringComparison(firstArg, secondArg);
- }
-
- // JSP.2.3.5.7, steps 8 and 9 -- if either one implements the
- // Comparable interface, then as far as we can determine statically
- // (compareTo may not work on the other arg, but who knows),
- // we are good
- if (firstArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE)
- || secondArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE))
- {
- if (checkIfIncompatibleEnums(firstArg, secondArg))
- {
- // error: no point in validating further since expr will probably throw an exception
- return null;
- }
-
- return new ValueType(Signature.SIG_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- // JSP.2.3.5.6, step 10 -- otherwise, error
- return null;
-
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.3.5.6 step 2 if either operand is null, then always false
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- || TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return _diagnosticFactory.
- create_BINARY_OP_EQUALITY_COMP_WITH_NULL_ALWAYS_EVAL_SAME(Messages.getString("LtGtRelationalBinaryOperator.ConstantName.False")); //$NON-NLS-1$
- }
-
- String boxedFirstType = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- String boxedSecondType = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.6 step 3, if either is BigDecimal, promote both and compare
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.6, step 4 if either is a float or double, promote both to
- // double and compare
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.6, step 5 if either is a big integer, promote and compare
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.6, step 6 if either is Long or smaller, coerce both to Long
- if (TypeConstants.TYPE_BOXED_LONG.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_LONG.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_INTEGER.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_SHORT.equals(boxedSecondType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedFirstType)
- || TypeConstants.TYPE_BOXED_BYTE.equals(boxedSecondType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedFirstType)
- || TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedSecondType))
- {
- return validateNumericComparison(firstArg, secondArg, Long.class);
- }
-
- // JSP.2.3.5.7, step 7 if either is a string, coerce to string and
- // compare lexically
- if (TypeConstants.TYPE_STRING.equals(boxedFirstType)
- || TypeConstants.TYPE_STRING.equals(boxedSecondType))
- {
- return validateStringComparison(firstArg, secondArg);
- }
-
- // JSP.2.3.5.7, steps 8 and 9 -- if either one implements the
- // Comparable interface, then as far as we can determine statically
- // (compareTo may not work on the other arg, but who knows),
- // we are good
- if (firstArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE)
- || secondArg.isInstanceOf(TypeConstants.TYPE_COMPARABLE))
- {
- Diagnostic diag = Diagnostic.OK_INSTANCE;
- if(checkIfIncompatibleEnums(firstArg, secondArg))
- {
- diag = _diagnosticFactory.create_BINARY_OP_COMPARISON_OF_ENUMS_INCOMPATIBLE();
- }
- return diag;
- }
-
- // JSP.2.3.5.6, step 10 -- otherwise, error
- return _diagnosticFactory.create_BINARY_OP_NO_AVAILABLE_TYPE_COERCION();
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return diagnostic if firstArg and secondArg are incompatible with each other
- * for compareTo purpose or OK if not
- */
- private boolean checkIfIncompatibleEnums(ValueType firstArg,
- ValueType secondArg)
- {
- if (firstArg.isEnumType()
- && secondArg.isEnumType()
- && !TypeUtil.isEnumsCompareCompatible(firstArg.getSignature()
- , secondArg.getSignature()))
- {
- return true;
- }
-
- return false;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java
deleted file mode 100644
index b346d9fcd..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MemberAccessorOperator.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.NullLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.SignatureBasedType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.context.symbol.IMethodSymbol;
-import org.eclipse.jst.jsf.context.symbol.IObjectSymbol;
-import org.eclipse.jst.jsf.context.symbol.IPropertySymbol;
-import org.eclipse.jst.jsf.context.symbol.ISymbol;
-import org.eclipse.jst.jsf.context.symbol.internal.util.IMethodSymbolBasedType;
-import org.eclipse.jst.jsf.context.symbol.internal.util.IObjectSymbolBasedValueType;
-import org.eclipse.jst.jsf.designtime.resolver.ISymbolContextResolver;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Super-class for all operators whose function is to access members of an EL
- * object. i.e. the "." and "[]" operators
- *
- * @author cbateman
- *
- */
-public abstract class MemberAccessorOperator
-{
- /**
- * The source file for the EL expression in which this operator is being
- * evaluated.
- */
- protected final IFile _file;
-
- /**
- * the common factory used to create diagnostics
- */
- protected final DiagnosticFactory _diagnosticFactory;
-
- /**
- * Used to resolve variables and properties.
- */
- protected final ISymbolContextResolver _contextResolver;
-
- // TODO: need to reconcile with BinaryOperator? performOperation must return
- // SignatureBasedType since it may return a method. This can't happen
- // with other operators (besides eqiv [])
- /**
- * @param file
- * @param diagnosticFactory
- * @param contextResolver
- */
- protected MemberAccessorOperator(final IFile file,
- final DiagnosticFactory diagnosticFactory, final ISymbolContextResolver contextResolver)
- {
- _file = file;
- _diagnosticFactory = diagnosticFactory;
- _contextResolver = contextResolver;
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of validating the dot operation with these arguments.
- */
- public Diagnostic validate(final ValueType firstArg, final ValueType secondArg)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
- if (!(firstArg instanceof IObjectSymbolBasedValueType))
- {
- throw new AssertionError(
- "The first argument of the member operator must always be a symbol resolvable value type"); //$NON-NLS-1$
- }
-
- if (TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return _diagnosticFactory
- .create_BINARY_OP_DOT_WITH_VALUEB_NULL(getOperatorName());
- }
-
- return validateObjectSymbolValue(
- (IObjectSymbolBasedValueType) firstArg, secondArg);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the diagnostic for member(firstArg, secondArg)
- */
- protected abstract Diagnostic validateObjectSymbolValue(
- IObjectSymbolBasedValueType firstArg, ValueType secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return a validation of a named property accessible base (map or bean)
- * given an a literal key argument
- */
- protected Diagnostic validateNamedPropertyAccessorBase(
- final IObjectSymbolBasedValueType firstArg, final LiteralType secondArg)
- {
- final IObjectSymbol curBaseSymbol = firstArg.getSymbol();
-
- final ISymbol nextSymbol =
- getMemberSymbol(firstArg.getSymbol(), secondArg
- .getLiteralValueRaw());
-
- // if the x in x.y is an unconstrained map an it returns
- // a java.lang.Object, then return null. We can't really say
- // anything meaningful about such a property anyway.
- // TODO: do we need to refine the type descriptor on such
- // a property object to make this more precise?
- if (curBaseSymbol.supportsCoercion(TypeConstants.TYPE_MAP)
- && nextSymbol instanceof IPropertySymbol
- && TypeConstants.TYPE_JAVAOBJECT
- .equals(((IPropertySymbol) nextSymbol)
- .getTypeDescriptor().getTypeSignature()))
- {
- // if we get a symbol back that's a generic object coming from a map
- // then stop validating; we can't tell anything for sure
- return Diagnostic.OK_INSTANCE;
- }
-
- if (nextSymbol == null)
- {
- return _diagnosticFactory.create_MEMBER_NOT_FOUND(secondArg
- .getLiteralValue(), firstArg.getSymbol().getName());
- }
-
- return Diagnostic.OK_INSTANCE;
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the resolved type for the operation or null if not computable
- */
- public SignatureBasedType performOperation(final ValueType firstArg,
- final ValueType secondArg)
- {
- if (!(firstArg instanceof IObjectSymbolBasedValueType))
- {
- return null;
- }
-
- // per JSP.2.3.4, if value-b is null, then return null (not literal
- // null)
- if (TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return null;
- }
-
- return handlePerformObjectSymbolValue(
- (IObjectSymbolBasedValueType) firstArg, secondArg);
- }
-
- /**
- * @param firstArg --
- * represents value-a (expr-a after step 1) in JSP.2.3.4
- * @param secondArg --
- * represents value-b (expr-b after step 3) in JSP.2.3.4
- * @return the new ValueType for this operation or null
- */
- protected abstract SignatureBasedType handlePerformObjectSymbolValue(
- IObjectSymbolBasedValueType firstArg, ValueType secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the resolved type for firstArg[secondArg] treating firstArg as a
- * type that uses a named property accessor (i.e. a map or bean but
- * not a list or array) or null if unresolved
- */
- protected SignatureBasedType handlePerformNamedPropertyAccessorBase(
- final IObjectSymbolBasedValueType firstArg, final LiteralType secondArg)
- {
- final ISymbol symbol =
- getMemberSymbol(firstArg.getSymbol(), secondArg
- .getLiteralValueRaw());
-
- if (symbol instanceof IPropertySymbol)
- {
- return new IObjectSymbolBasedValueType((IPropertySymbol) symbol);
- }
- else if (symbol instanceof IMethodSymbol)
- {
- return new IMethodSymbolBasedType((IMethodSymbol) symbol);
- }
-
- // fall-through and return null
- // per JSP2.3.4 steps 5 and 6, return null literal if map, null (error)
- // otherwise
- if (firstArg.isInstanceOf(TypeConstants.TYPE_MAP))
- {
- return NullLiteralType.SINGLETON;
- }
- return null;
- }
-
- /**
- * @param symbol
- * @param name
- * @return the member symbol of 'symbol' corresponding to 'name' or null if
- * there is no such member
- */
- protected final ISymbol getMemberSymbol(final IObjectSymbol symbol,
- final Object name)
- {
- ISymbol memberSymbol = getPropertySymbol(symbol, name);
-
- if (memberSymbol != null)
- {
- return memberSymbol;
- }
-
- memberSymbol = getMethodSymbol(symbol, name);
-
- // otherwise, see if it's a valid method
- if (memberSymbol != null)
- {
- return memberSymbol;
- }
-
- // if not a property or method, then not a valid member
- return null;
- }
-
- /**
- * @param symbol
- * @param name
- * @return the property symbol called name relative to 'symbol' or null if
- * one doesn't exist
- */
- protected final ISymbol getPropertySymbol(final ISymbol symbol,
- final Object name)
- {
- return _contextResolver.getProperty(symbol, name);
- }
-
- /**
- * @param symbol
- * @param name
- * @return the method symbol on 'symbol' corresponding to 'name' or null if
- * no such member
- */
- protected final IMethodSymbol getMethodSymbol(final IObjectSymbol symbol,
- final Object name)
- {
- return _contextResolver.getMethod(symbol, name);
- }
-
-
- /**
- * @return a user-readable name of the operator (i.e. dot or bracket)
- */
- protected abstract String getOperatorName();
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java
deleted file mode 100644
index 22c4c5618..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/Messages.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 Oracle Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class Messages {
- private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.validation.internal.el.operators.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
- .getBundle(BUNDLE_NAME);
-
- private Messages() {
- // no external instantiation
- }
-
- /**
- * @param key
- * @return the string or !key! if not found
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java
deleted file mode 100644
index 91705d9db..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MinusUnaryOperator.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.StringLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL unary operator '-' on a ValueType
- * as described by JSP.2.3.5.4
- *
- *
- * @author cbateman
- *
- */
-/*package*/class MinusUnaryOperator extends UnaryOperator
-{
- private static final String UNARY_MINUS = "unary minus"; //$NON-NLS-1$
-
- MinusUnaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- public Diagnostic validate(ValueType type)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(type.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
- // must coerce to numeric type
- try
- {
- // if coerceTypeNumber doesn't throw an exception, then
- // give the benefit of the doubt
- final String coercedType =
- TypeCoercer.
- coerceToNumber(TypeTransformer.
- transformBoxPrimitives(type.getSignature()));
-
- if (TypeCoercer.typeIsNull(coercedType))
- {
- // null always coerces to 0L on this operator
- return _diagnosticFactory.
- create_UNARY_OP_MINUS_ON_NULL_ALWAYS_ZERO();
- }
-
- // JSP.2.3.5.4, step 2 if BigDecimal or BigInteger, then can't be
- // literal and retains type
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(coercedType)
- || TypeConstants.TYPE_BIG_INTEGER.equals(coercedType))
- {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.4.5.4, step 3: if String
- // note, use uncoerced type, since type coercer will return null for strings
- if (TypeCoercer.typeIsString(type.getSignature()))
- {
- // if it's a string and we have the value, we can determine for
- // sure whether or not it's coercable to a number
- // per JSP.2.3.5.4 step 3.1
- if (type instanceof StringLiteralType)
- {
- String literalValue = ((LiteralType)type).getLiteralValue();
- if (literalValue.indexOf('.') > -1
- || literalValue.indexOf('e') > -1
- || literalValue.indexOf('E') > -1)
- {
- // if it coerces to double, then it's a double
- ((LiteralType)type).coerceToNumber(Double.class);
- // this is okay, because an expression like #{-3.3} can't be folded
- return Diagnostic.OK_INSTANCE;
- }
- // per JSP.2.3.5.4, step 3.2 try to coerce to long
- // if it coerces to long, then it's a long
- ((LiteralType)type).coerceToNumber(Long.class);
- // this is okay, because an expression like #{-3} can't be folded
- return Diagnostic.OK_INSTANCE;
- }
- // if non-literal string, warn that coercion to number is not
- // guaranteed since Long.valueOf and Double.valueOf
- // (unlike Boolean.valueOf) throw NumberFormatExceptions
- return _diagnosticFactory.create_UNARY_OP_STRING_CONVERSION_NOT_GUARANTEED(UNARY_MINUS);
- }
-
- // JSP.2.3.5.4, step 4, for all numeric types, retain type,
- // validate constant folding
- // note that this return true for big int and decimal, so those cases
- // must already have been handled.
- if (TypeCoercer.typeIsNumeric(coercedType))
- {
- // otherwise, we are fine
- return Diagnostic.OK_INSTANCE;
- }
-
- }
- catch (TypeCoercionException tce)
- {
- // fallthrough to error below
- }
- // otherwise, error
- return _diagnosticFactory.create_UNARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(UNARY_MINUS);
- }
-
- /**
- * Based on JSP.2.3.5.4
- *
- * @param type
- * @return type of type after a minus is applied or null if unknown
- */
- public ValueType performOperation(ValueType type)
- {
- try
- {
- final String boxedType =
- TypeTransformer.transformBoxPrimitives(type.getSignature());
- // check for valid type coercion
- String coercedType = TypeCoercer.coerceToNumber(boxedType);
-
- if (TypeCoercer.typeIsNull(coercedType))
- {
- // null always coerces to 0L on this operator
- return new IntegerLiteralType(0L);
- }
-
- // JSP.2.3.5.4, step 2 if BigDecimal or BigInteger, then can't be
- // literal and retains type
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(coercedType))
- {
- return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- else if (TypeConstants.TYPE_BIG_INTEGER.equals(coercedType))
- {
- return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- if (TypeCoercer.typeIsString(type.getSignature()))
- {
- // if it's string and we have the value, we can determine for
- // sure whether or not it's coercable to a number
- // per JSP.2.3.5.4 step 3
- if (type instanceof StringLiteralType)
- {
- String literalValue = ((LiteralType)type).getLiteralValue();
- if (literalValue.indexOf('.') > -1
- || literalValue.indexOf('e') > -1
- || literalValue.indexOf('E') > -1)
- {
- // if it coerces to double, then it's a double
- Number value = ((LiteralType)type).coerceToNumber(Double.class);
- return new FloatLiteralType(-1 * value.doubleValue());
- }
-
- // if it coerces to long, then it's a long
- Number value = ((LiteralType)type).coerceToNumber(Long.class);
- return new IntegerLiteralType(-1 * value.longValue());
- }
-
- // otherwise, just return a long typed value
- return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- // JSP.2.3.5.4
- // big integer and big decimal retain type
- // all numeric types retain type
- if (TypeCoercer.typeIsNumeric(boxedType))
- {
- // integer and float literals are special because -1 or -1.0
- // is syntically minusOp(1) and minusOp(1.0)
- if (type instanceof IntegerLiteralType)
- {
- return new IntegerLiteralType(-1 * ((IntegerLiteralType)type).coerceToNumber(Long.class).longValue());
- }
- else if (type instanceof FloatLiteralType)
- {
- return new FloatLiteralType(-1 * ((FloatLiteralType)type).coerceToNumber(Double.class).doubleValue());
- }
- return type;
- }
-
- // all other cases, return null
- // even is type represents a String, without it's value, we have
- // no idea how to coerce it without it's value
- // fall through and return null
- }
- catch (TypeCoercionException tce)
- {
- // do nothing, fall through and return null
- }
-
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java
deleted file mode 100644
index 0b6ac7d01..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/ModArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL modulo operator: % or mod
- * Based JSP.2.3.5.3
- *
- * @author cbateman
- *
- */
-/*package*/ class ModArithmeticBinaryOperator extends ArithmeticBinaryOperator
-{
- private static final String MODULO = "modulo"; //$NON-NLS-1$
-
- ModArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- // JSP.2.3.5.3, step 1 if both null, then return zero
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return IntegerLiteralType.ZERO;
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.3, step 2, if either arg is BigDecimal, Float, Double
- // or String (ignoring whether it is value coercable), then coerce
- // to Double and do op
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg))
- {
- // TODO: handle case where one is a literal or resolvable string value
- // that containss ".", "e" or "E"
- return performDouble(firstArg, secondArg);
- }
-
- // JSP.2.3.5.3, step 3, if either arg is a BigInteger, coerce
- // both to BigInteger
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return performBigInteger(firstArg, secondArg);
- }
-
- // JSP.2.3.5.3, step 4, otherwise try to perform as a Long op
- return performLong(firstArg, secondArg);
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg) {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.3.5.3, step 1 if both null, then return zero
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(MODULO);
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.3, step 2, if either arg is BigDecimal, Float, Double
- // or String (ignoring whether it is value coercable), then coerce
- // to Double and do op
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg)
- || TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg))
- {
- // TODO: handle case where one is a literal or resolvable string value
- // that containss ".", "e" or "E"
- return validateDouble(firstArg, secondArg);
- }
-
- // JSP.2.3.5.3, step 3, if either arg is a BigInteger, coerce
- // both to BigInteger
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return validateBigInteger(firstArg, secondArg);
- }
-
- // JSP.2.3.5.3, step 4, otherwise try to perform as a Long op
- return validateLong(firstArg, secondArg);
- }
-
- private ValueType performDouble(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
-
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class);
-
- if (secondValue.doubleValue() == 0.0)
- {
- // division by zero
- return null;
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- return new FloatLiteralType(
- doRealOperation(new Double(firstValue.doubleValue()),
- new Double(secondValue.doubleValue())).doubleValue());
- }
-
- // if we get to here, the coercion is valid, so a Double will be
- // returned
- return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException tce)
- {
- // could not coerce, so null
- return null;
- }
- }
-
- private ValueType performBigInteger(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- // check second arg for zero
- if (secondArg instanceof LiteralType)
- {
- if (((LiteralType)secondArg).coerceToNumber(BigInteger.class).equals(BigInteger.ZERO))
- {
- // division by zero
- return null;
- }
- }
-
- // since one of the args is BigInteger, they are not both literals,
- // so if we get to here, we have a successful mod of two
- // big integers to one big integer
- return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException tce)
- {
- // no coercion
- return null;
- }
- }
-
- private ValueType performLong(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
-
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Long.class);
-
- if (secondValue.longValue() == 0)
- {
- // division by zero
- return null;
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Long.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- return new IntegerLiteralType(
- doRealOperation(Long.valueOf(firstValue.longValue()),
- Long.valueOf(secondValue.longValue())).longValue());
- }
-
- // if we get to here, the coercion is valid, so a Long will be
- // returned
- return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException tce)
- {
- // could not coerce, so null
- return null;
- }
- }
-
- private Diagnostic validateDouble(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
-
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Double.class);
-
- if (secondValue.doubleValue() == 0.0)
- {
- // division by zero
- return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO();
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Double.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME
- (MODULO, Double.toString(
- firstValue.doubleValue()%secondValue.doubleValue()));
- }
-
- // if we get to here, the coercion is valid, so a Double will be
- // returned and everything is good
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException tce)
- {
- // could not coerce, so error
- return _diagnosticFactory.
- create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO);
- }
- }
-
- private Diagnostic validateBigInteger(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- // check second arg for zero
- if (secondArg instanceof LiteralType)
- {
- if (((LiteralType)secondArg).coerceToNumber(BigInteger.class).equals(BigInteger.ZERO))
- {
- // division by zero
- return _diagnosticFactory.create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO();
- }
- }
-
- // since one of the args is BigInteger, they are not both literals,
- // so if we get to here, we have a successful mod of two
- // big integers to one big integer
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException tce)
- {
- // no coercion
- return _diagnosticFactory.
- create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO);
- }
- }
-
- private Diagnostic validateLong(ValueType firstArg, ValueType secondArg)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number secondValue = null;
-
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(Long.class);
-
- if (secondValue.longValue() == 0)
- {
- // division by zero
- return _diagnosticFactory.
- create_BINARY_OP_POSSIBLE_DIVISION_BY_ZERO();
- }
- }
-
- Number firstValue = null;
-
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(Long.class);
- }
-
- if (firstValue != null && secondValue != null)
- {
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME
- (MODULO, Long.toString(firstValue.longValue()%secondValue.longValue()));
- }
-
- // if we get to here, the coercion is valid, so a Long will be
- // returned
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException tce)
- {
- // could not coerce, so error
- return _diagnosticFactory.
- create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(MODULO);
- }
- }
-
- protected Long doRealOperation(Long firstArg, Long secondArg) {
- return Long.valueOf(firstArg.longValue() % secondArg.longValue());
- }
-
- protected Double doRealOperation(Double firstArg, Double secondArg) {
- return new Double(firstArg.doubleValue() % secondArg.doubleValue());
- }
-
- protected BigDecimal doRealOperation(BigDecimal firstArg,
- BigDecimal secondArg) {
- return new BigDecimal(firstArg.doubleValue() % secondArg.doubleValue());
- }
-
- protected String getOperatorName() {
- return MODULO;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java
deleted file mode 100644
index 605ce470a..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/MultiplyArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL Multiply arithmetic binary operator "*"
- *
- * @author cbateman
- *
- */
-/*package*/ class MultiplyArithmeticBinaryOperator extends
- NoDivArithmeticBinaryOperator
-{
- private static final String MULTIPLICATION = "multiplication"; //$NON-NLS-1$
-
-
- MultiplyArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- protected Long doRealOperation(Long firstArg, Long secondArg)
- {
- return Long.valueOf(firstArg.longValue() * secondArg.longValue());
- }
-
- protected Double doRealOperation(Double firstArg, Double secondArg)
- {
- return new Double(firstArg.doubleValue() * secondArg.doubleValue());
- }
-
- protected BigDecimal doRealOperation(BigDecimal firstArg,
- BigDecimal secondArg)
- {
- return firstArg.multiply(secondArg);
- }
-
- protected String getOperatorName() {
- return MULTIPLICATION;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java
deleted file mode 100644
index 3b057545d..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NoDivArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jst.jsf.common.internal.types.FloatLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.IntegerLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents non-dividing arithmetic EL operators: +,-,*
- * Based on JSP.2.3.5.1
- *
- * @author cbateman
- *
- */
-/*package*/ abstract class NoDivArithmeticBinaryOperator extends ArithmeticBinaryOperator
-{
- NoDivArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- protected abstract Long doRealOperation(Long firstArg, Long secondArg);
-
- protected abstract Double doRealOperation(Double firstArg, Double secondArg);
-
- public ValueType performOperation(ValueType firstArg, ValueType secondArg)
- {
- // JSP.2.3.5.1, step 1, if either arg is null, return (Long) 0
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return new IntegerLiteralType(0);
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.1, step 2, if either arg is a BigDecimal, coerce to BigDecimal
- // and apply
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg))
- {
- return handleNumericArithmetic(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.1, step 3, if either arg is float or double or
- // a String containing "., e or E", then coerce if the other is
- // a big int, coerce up to BigDecimal, else to Double
- // Note: we are ignoring strings we can't resolve to figure out
- // if the contain "., e or E". Assume they always do
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg)
- ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg))
- {
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- // if the other operand is BigInteger, treat as BigDecimal
- return handleNumericArithmetic(firstArg, secondArg, BigDecimal.class);
- }
-
- // otherwise as double
- return handleNumericArithmetic(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.1, step 4, if one is a big integer, coerce to big integer
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return handleNumericArithmetic(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.1, step 5, otherwise, try to coerce to Long
- return handleNumericArithmetic(firstArg, secondArg, Long.class);
- }
-
- public Diagnostic validate(ValueType firstArg, ValueType secondArg)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(firstArg.getSignature()) ||
- TypeConstants.TYPE_JAVAOBJECT.equals(secondArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- // JSP.2.3.5.1, step 1, if either arg is null, return (Long) 0
- if (TypeCoercer.typeIsNull(firstArg.getSignature())
- && TypeCoercer.typeIsNull(secondArg.getSignature()))
- {
- return _diagnosticFactory.create_BINARY_OP_BOTH_OPERANDS_NULL(getOperatorName());
- }
-
- final String boxedFirstArg = TypeTransformer.transformBoxPrimitives(firstArg.getSignature());
- final String boxedSecondArg = TypeTransformer.transformBoxPrimitives(secondArg.getSignature());
-
- // JSP.2.3.5.1, step 2, if either arg is a BigDecimal, coerce to BigDecimal
- // and apply
- if (TypeConstants.TYPE_BIG_DOUBLE.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_DOUBLE.equals(boxedSecondArg))
- {
- return validateNumericArithmetic(firstArg, secondArg, BigDecimal.class);
- }
-
- // JSP.2.3.5.1, step 3, if either arg is float or double or
- // a String containing "., e or E", then coerce if the other is
- // a big int, coerce up to BigDecimal, else to Double
- // Note: we are ignoring strings we can't resolve to figure out
- // if the contain "., e or E". Assume they always do
- if (TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BOXED_DOUBLE.equals(boxedSecondArg)
- ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BOXED_FLOAT.equals(boxedSecondArg))
- {
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- ||TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- // if the other operand is BigInteger, treat as BigDecimal
- return validateNumericArithmetic(firstArg, secondArg, BigDecimal.class);
- }
-
- // otherwise as double
- return validateNumericArithmetic(firstArg, secondArg, Double.class);
- }
-
- // JSP.2.3.5.1, step 4, if one is a big integer, coerce to big integer
- if (TypeConstants.TYPE_BIG_INTEGER.equals(boxedFirstArg)
- || TypeConstants.TYPE_BIG_INTEGER.equals(boxedSecondArg))
- {
- return validateNumericArithmetic(firstArg, secondArg, BigInteger.class);
- }
-
- // JSP.2.3.5.1, step 5, otherwise, try to coerce to Long
- return validateNumericArithmetic(firstArg, secondArg, Long.class);
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @param numberType
- * @return a value type based on the result of the arithmetic operation
- */
- protected ValueType handleNumericArithmetic(ValueType firstArg, ValueType secondArg, Class numberType)
- {
- try
- {
-// final String coercedFirstArg =
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
-// final String coercedSecondArg =
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- if (firstArg instanceof LiteralType && secondArg instanceof LiteralType)
- {
- try
- {
- Number firstValue =
- ((LiteralType)firstArg).coerceToNumber(numberType);
- Number secondValue =
- ((LiteralType)secondArg).coerceToNumber(numberType);
-
- LiteralType result = null;
-
- if (numberType == Double.class)
- {
- Double resultValue =
- doRealOperation((Double)firstValue,
- (Double) secondValue);
- result = new FloatLiteralType(resultValue.doubleValue());
- }
- else if (numberType == Long.class)
- {
- Long resultValue =
- doRealOperation((Long) firstValue, (Long) secondValue);
- result = new IntegerLiteralType(resultValue.longValue());
- }
- else
- {
- throw new AssertionError("unsupport arithmetic upcast type"); //$NON-NLS-1$
- }
-
- return result;
- }
- catch (TypeCoercionException tce)
- {
- // could happen if two string literals passed
- return null;
- }
- }
-
- // if we get to here, then we have two valid numeric arith
- // types, but at least one is not a literal, so the best we can
- // say is that the return will be the same asthe type of numeric
- // coercion
- if (numberType == BigDecimal.class)
- {
- return new ValueType(TypeConstants.TYPE_BIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- else if (numberType == Double.class)
- {
- return new ValueType(Signature.SIG_DOUBLE, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- else if (numberType == BigInteger.class)
- {
- return new ValueType(TypeConstants.TYPE_BIG_INTEGER, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- else
- {
- return new ValueType(Signature.SIG_LONG, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- }
- catch (TypeCoercionException tce)
- {
- // coercion to number failed, so no go
- return null;
- }
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @param numberType
- * @return a diagnostic validating the arithmetic expr firstArg op secondArg
- */
- protected Diagnostic validateNumericArithmetic(ValueType firstArg, ValueType secondArg, Class numberType)
- {
- try
- {
-// final String coercedFirstArg =
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
-// final String coercedSecondArg =
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- if (firstArg instanceof LiteralType && secondArg instanceof LiteralType)
- {
- try
- {
- Number firstValue =
- ((LiteralType)firstArg).coerceToNumber(numberType);
- Number secondValue =
- ((LiteralType)secondArg).coerceToNumber(numberType);
-
- Number result = null;
-
- if (numberType == Double.class)
- {
- result =
- doRealOperation((Double)firstValue,
- (Double) secondValue);
- }
- else if (numberType == Long.class)
- {
- result =
- doRealOperation((Long) firstValue, (Long) secondValue);
- }
- else
- {
- throw new AssertionError("unsupport arithmetic upcast type"); //$NON-NLS-1$
- }
-
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME
- (getOperatorName(), result.toString());
- }
- catch (TypeCoercionException tce)
- {
- // could happen when two strings are passed
- return _diagnosticFactory.
- create_BINARY_OP_COULD_NOT_COERCE_LITERALS_TO_NUMBERS();
- }
- }
-
- // if we get to here, then we have two valid numeric arith
- // types, but at least one is not a literal
- // everything should be ok
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException tce)
- {
- // coercion to number failed, so no go
- return _diagnosticFactory.
- create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(getOperatorName());
- }
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java
deleted file mode 100644
index 1d6245426..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotEqualsBinaryRelationalOperator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the not equals -- "!="/ne EL binary operator
- * @author cbateman
- *
- */
-/*package*/ class NotEqualsBinaryRelationalOperator extends
- EqualityRelationalBinaryOperator {
-
- NotEqualsBinaryRelationalOperator(final DiagnosticFactory diagnosticFactory, String jsfVersion)
- {
- super(diagnosticFactory, jsfVersion);
- }
-
- protected boolean doRealOperation(Number firstArg, Number secondArg) {
- return !firstArg.equals(secondArg);
- }
-
- protected boolean doRealOperation(Boolean firstArg, Boolean secondArg) {
- return !firstArg.equals(secondArg);
- }
-
- protected boolean doRealOperation(String firstArg, String secondArg) {
- return !firstArg.equals(secondArg);
- }
-
- protected String getOperationName()
- {
- return Messages.getString("NotEqualsBinaryRelationalOperator.OperationName"); //$NON-NLS-1$
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java
deleted file mode 100644
index f8f09b22e..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/NotUnaryOperator.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents te EL unary operators "!" and "not" on a ValueType
- * as described by JSP.2.3.6.2
- *
- * @author cbateman
- *
- */
-/*package*/ class NotUnaryOperator extends UnaryOperator
-{
- NotUnaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- public Diagnostic validate(ValueType type)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(type.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
- boolean canCoerce =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(type.getSignature()));
-
- if (canCoerce)
- {
- // check for constant evaluation
- if (type instanceof LiteralType)
- {
- try
- {
- Boolean coercedValue = ((LiteralType)type).coerceToBoolean();
-
- // we are logically notting, so coerced is true, then false
- // if false then true
- return _diagnosticFactory.create_UNARY_OP_CONSTANT_EXPRESSION_EVAL_SAME_ID(
- "not" //$NON-NLS-1$
- , Boolean.valueOf(!coercedValue.booleanValue()).toString());
-
- }
- catch (TypeCoercionException tce)
- {
- throw new AssertionError("coerce should not throw exception"); //$NON-NLS-1$
- }
- }
-
- return Diagnostic.OK_INSTANCE;
- }
- return _diagnosticFactory.create_UNARY_OP_CANNOT_COERCE_ARGUMENT_TO_BOOLEAN();
- }
-
- public ValueType performOperation(ValueType type)
- {
- boolean canCoerce =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(type.getSignature()));
-
- if (canCoerce)
- {
- if (type instanceof LiteralType)
- {
- try
- {
- Boolean coercedValue = ((LiteralType)type).coerceToBoolean();
-
- // we are logically notting, so coerced is true, then false
- // if false then true
- return
- coercedValue.booleanValue() ?
- BooleanLiteralType.FALSE :
- BooleanLiteralType.TRUE;
- }
- catch (TypeCoercionException tce)
- {
- throw new AssertionError("coerce should not throw exception"); //$NON-NLS-1$
- }
- }
-
- return new ValueType(TypeConstants.TYPE_BOOLEAN, type.getAssignability());
- }
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java
deleted file mode 100644
index 4914704d8..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/OrBinaryOperator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Encapsulates the 'and'/'&&' boolean-AND operator
- * Based on JSP.2.3.6.1
- *
- * @author cbateman
- *
- */
-/*package*/class OrBinaryOperator extends LogicalBinaryOperator
-{
- OrBinaryOperator(DiagnosticFactory diagnosticFactory)
- {
- super(diagnosticFactory);
- }
-
- protected boolean doRealOperation(Boolean firstArg, Boolean secondArg)
- {
- return (firstArg.booleanValue() || secondArg.booleanValue());
- }
-
- protected String readableOperatorName()
- {
- return "logical-OR"; //$NON-NLS-1$
- }
-
- protected boolean shortCircuitValue()
- {
- // OR short-circuits on true
- return true;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java
deleted file mode 100644
index 924ec9854..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/RelationalBinaryOperator.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.BooleanLiteralType;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.core.IJSFCoreConstants;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-
-/**
- * Super-class of all relational binary ops - "==", "!=", "<", ">", "<=", ">="
- * @author cbateman
- *
- */
-/*package*/ abstract class RelationalBinaryOperator extends BinaryOperator
-{
- private final String _jsfVersion;
-
- RelationalBinaryOperator(final DiagnosticFactory diagnosticFactory, final String jsfVersion)
- {
- super(diagnosticFactory);
- _jsfVersion = jsfVersion;
- }
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected abstract boolean doRealOperation(Number firstArg, Number secondArg);
-
- /**
- * @param firstArg
- * @param secondArg
- * @return the result of the operation
- */
- protected abstract boolean doRealOperation(String firstArg, String secondArg);
-
- /**
- * @return the operation's user readable name
- */
- protected abstract String getOperationName();
-
- /**
- * Performs a the operation, casting both args to BigDecimal first
- *
- * @param firstArg
- * @param secondArg
- * @param numberType
- * @return the result of the comparison or null if indeterminate
- */
- protected ValueType handleNumericComparison(ValueType firstArg, ValueType secondArg, Class numberType)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstArg.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondArg.getSignature()));
-
- Number firstValue = null;
- if (firstArg instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstArg).coerceToNumber(numberType);
- }
-
- Number secondValue = null;
- if (secondArg instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondArg).coerceToNumber(numberType);
- }
-
- if (firstValue != null && secondValue != null)
- {
- boolean result = doRealOperation(firstValue, secondValue);
-
- return result ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE;
- }
-
- // if we get to here, we only know that both can be up cast to BigDecimal
- // and compared. This will yield a boolean result
- // this value cannot be lhs
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
- catch (TypeCoercionException tce)
- {
- // no valid coercion, so return null
- return null;
- }
- }
-
- /**
- * @param firstType
- * @param secondType
- * @param numberType
- * @return a diagnostic validating the relational comparison of firstType to secondType
- */
- protected Diagnostic validateNumericComparison(ValueType firstType, ValueType secondType, Class numberType)
- {
- try
- {
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(firstType.getSignature()));
- TypeCoercer.coerceToNumber(TypeTransformer.transformBoxPrimitives(secondType.getSignature()));
-
- Number firstValue = null;
- if (firstType instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstType).coerceToNumber(numberType);
- }
-
- Number secondValue = null;
- if (secondType instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondType).coerceToNumber(numberType);
- }
-
- if (firstValue != null && secondValue != null)
- {
- boolean result = doRealOperation(firstValue, secondValue);
-
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME
- (getOperationName(), Boolean.toString(result));
- }
-
- // if we get to here, we only know that both can be up cast to BigDecimal
- // and compared. This condition is okay
- return Diagnostic.OK_INSTANCE;
- }
- catch (TypeCoercionException tce)
- {
- // could not make numeric coercion for valid comparison
- return _diagnosticFactory.create_BINARY_OP_COULD_NOT_MAKE_NUMERIC_COERCION(getOperationName());
- }
- }
-
- /**
- * @param firstType
- * @param secondType
- * @return the result of the operation
- */
- protected ValueType handleStringComparison(ValueType firstType, ValueType secondType)
- {
- String firstValue = null;
-
- if (firstType instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstType).getLiteralValue();
- }
-
- String secondValue = null;
- if (secondType instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondType).getLiteralValue();
- }
-
- if (firstValue != null && secondValue != null)
- {
- boolean newValue = doRealOperation(firstValue, secondValue);
- return newValue ? BooleanLiteralType.TRUE : BooleanLiteralType.FALSE;
- }
-
- // if don't have all literals, just return boolean type
- return new ValueType(TypeConstants.TYPE_BOOLEAN, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- /**
- * @param firstType
- * @param secondType
- * @return a diagnostic validating the string comparison of firstType to secondType
- */
- protected Diagnostic validateStringComparison(ValueType firstType, ValueType secondType)
- {
- String firstValue = null;
-
- if (firstType instanceof LiteralType)
- {
- firstValue = ((LiteralType)firstType).getLiteralValue();
- }
-
- String secondValue = null;
- if (secondType instanceof LiteralType)
- {
- secondValue = ((LiteralType)secondType).getLiteralValue();
- }
-
- if (firstValue != null && secondValue != null)
- {
- boolean newValue = doRealOperation(firstValue, secondValue);
- return _diagnosticFactory.
- create_BINARY_OP_CONSTANT_EXPRESSION_ALWAYS_EVAL_SAME
- (getOperationName(), Boolean.toString(newValue));
- }
-
- // if don't have all literals, just return boolean type
- return Diagnostic.OK_INSTANCE;
- }
-
-
- /**
- * @return the current JSF version string
- */
- protected final String getJsfVersion() {
- return _jsfVersion;
- }
-
- /**
- * @return true if the JSF version for this operator is JSF 1.1 or 1.0
- */
- protected final boolean isPreJSF12()
- {
- return IJSFCoreConstants.JSF_VERSION_1_1.equals(_jsfVersion)
- || IJSFCoreConstants.JSF_VERSION_1_0.equals(_jsfVersion);
- }
-
- /**
- * @return true if the JSF version for this operator is JSF 1.2 or later
- */
- protected final boolean isJSF12OrLater()
- {
- return !isPreJSF12();
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java
deleted file mode 100644
index acdaeda13..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/SubtractArithmeticBinaryOperator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import java.math.BigDecimal;
-
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the EL arithmetic subtraction binary operator
- *
- * @author cbateman
- *
- */
-/*package*/ class SubtractArithmeticBinaryOperator extends
- NoDivArithmeticBinaryOperator
-{
-
- private static final String SUBTRACTION = "subtraction"; //$NON-NLS-1$
-
- SubtractArithmeticBinaryOperator(DiagnosticFactory diagnosticFactory) {
- super(diagnosticFactory);
- }
-
- protected Long doRealOperation(Long firstArg, Long secondArg)
- {
- return Long.valueOf(firstArg.longValue() - secondArg.longValue());
- }
-
- protected Double doRealOperation(Double firstArg, Double secondArg)
- {
- return new Double(firstArg.doubleValue() - secondArg.doubleValue());
- }
-
- protected BigDecimal doRealOperation(BigDecimal firstArg,
- BigDecimal secondArg)
- {
- return firstArg.subtract(secondArg);
- }
-
- protected String getOperatorName()
- {
- return SUBTRACTION;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java
deleted file mode 100644
index a6a36838a..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/TernaryChoiceOperator.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.common.internal.types.LiteralType;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercer;
-import org.eclipse.jst.jsf.common.internal.types.TypeCoercionException;
-import org.eclipse.jst.jsf.common.internal.types.TypeConstants;
-import org.eclipse.jst.jsf.common.internal.types.TypeTransformer;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-
-/**
- * Represents the ternary choice op in EL: a ? b :c
- * Based on JSP.2.3.8
- *
- * @author cbateman
- *
- */
-public class TernaryChoiceOperator
-{
- private final DiagnosticFactory _diagnosticFactory;
-
-
- /**
- * @param diagnosticFactory
- */
- public TernaryChoiceOperator(DiagnosticFactory diagnosticFactory)
- {
- super();
- _diagnosticFactory = diagnosticFactory;
- }
-
- /**
- * @param choiceArg
- * @param whenTrueArg
- * @param whenFalseArg
- * @return the result of the choice arguments or null if indeterminant
- */
- public ValueType perform(ValueType choiceArg, ValueType whenTrueArg, ValueType whenFalseArg)
- {
- final boolean isChoiceBoolean =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(choiceArg.getSignature()));
-
- if (isChoiceBoolean)
- {
- if (choiceArg instanceof LiteralType)
- {
- try
- {
- Boolean result = ((LiteralType)choiceArg).coerceToBoolean();
-
- if (result != null)
- {
- return result.booleanValue() ? whenTrueArg : whenFalseArg;
- }
- }
- catch (TypeCoercionException tce)
- {
- return null;
- }
- }
-
- final String boxedWhenTrueArg =
- TypeTransformer.transformBoxPrimitives(whenTrueArg.getSignature());
-
- final String boxedWhenFalseArg =
- TypeTransformer.transformBoxPrimitives(whenFalseArg.getSignature());
- // check if the two results are the same type
- // TODO: could increase accuracy by appoximating type:i.e. if both
- // are numeric etc.
- if (boxedWhenTrueArg.equals(boxedWhenFalseArg))
- {
- return new ValueType(whenTrueArg, IAssignable.ASSIGNMENT_TYPE_RHS);
- }
-
- // otherwise, we have no idea what the resulting type is
- return null;
- }
-
- // if choice is not boolean, then can't resolve
- return null;
- }
-
- /**
- * @param choiceArg
- * @return a diagnostic validating the choice expr with these arguments
- */
- public Diagnostic validate(ValueType choiceArg)
- {
- if (TypeConstants.TYPE_JAVAOBJECT.equals(choiceArg.getSignature())) {
- return Diagnostic.OK_INSTANCE;
- }
-
- final boolean isChoiceBoolean =
- TypeCoercer.canCoerceToBoolean(TypeTransformer.transformBoxPrimitives(choiceArg.getSignature()));
-
- if (isChoiceBoolean)
- {
- if (choiceArg instanceof LiteralType)
- {
- try
- {
- Boolean result = ((LiteralType)choiceArg).coerceToBoolean();
-
- if (result != null)
- {
- String whichSelected = result.booleanValue() ? "first" : "second"; //$NON-NLS-1$ //$NON-NLS-2$
- return _diagnosticFactory.
- create_TERNARY_OP_CHOICE_IS_ALWAYS_SAME
- (result.booleanValue(), whichSelected);
- }
- }
- catch (TypeCoercionException tce)
- {
- return _diagnosticFactory.
- create_TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN();
- }
- }
-
- // in both the case where the two arguments are the same and when
- // they are different types, the best we can say is "OK", since
- // we really don't know
- return Diagnostic.OK_INSTANCE;
- }
-
- // if choice is not boolean, then can't resolve
- return _diagnosticFactory.
- create_TERNARY_OP_CANNOT_COERCE_CHOICE_TO_BOOLEAN();
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java
deleted file mode 100644
index 5161e4650..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/UnaryOperator.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cameron Bateman/Oracle - initial API and implementation
- *
- ********************************************************************************/
-
-package org.eclipse.jst.jsf.validation.internal.el.operators;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.internal.types.ValueType;
-import org.eclipse.jst.jsf.validation.internal.el.diagnostics.DiagnosticFactory;
-import org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserConstants;
-import org.eclipse.jst.jsp.core.internal.java.jspel.Token;
-
-/**
- * Encapsulates an EL unary operator
- * @author cbateman
- *
- */
-public abstract class UnaryOperator
-{
- /**
- * The common factory used to construct diagnostics
- */
- protected final DiagnosticFactory _diagnosticFactory;
-
- /**
- * @param token
- * @return true if the token is a unary operator
- */
- public static boolean isUnaryOperator(Token token)
- {
- return (token.kind == JSPELParserConstants.MINUS)
- || (token.kind == JSPELParserConstants.NOT1)
- || (token.kind == JSPELParserConstants.NOT2)
- || (token.kind == JSPELParserConstants.EMPTY);
- }
-
- /**
- * @param token
- * @param diagnosticFactory
- * @return a new UnaryOperator instance matching token
- */
- public static UnaryOperator createUnaryOperator(Token token, DiagnosticFactory diagnosticFactory)
- {
- if (!isUnaryOperator(token))
- {
- throw new IllegalArgumentException("token must be a unary operator"); //$NON-NLS-1$
- }
-
- switch(token.kind)
- {
- case JSPELParserConstants.MINUS:
- return new MinusUnaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.NOT1:
- case JSPELParserConstants.NOT2:
- return new NotUnaryOperator(diagnosticFactory);
-
- case JSPELParserConstants.EMPTY:
- return new EmptyUnaryOperator(diagnosticFactory);
- }
-
- // should never get here because all four ops are covered
- throw new AssertionError();
- }
-
- /**
- * Constructor
- */
- UnaryOperator(DiagnosticFactory diagnosticFactory)
- {
- /* no construction or sub-classing outside package*/
- _diagnosticFactory = diagnosticFactory;
- }
-
- /**
- * If ValueType is a literal and the operation can be performed, then
- * the return must be a new LiteralType transformed using this operator.
- *
- * If ValueType is not a literal and the operaton can be performed, then
- * the return is a new ValueType transformed per the rules of the operator
- * (i.e. if it is a string type and the operator is "!", then the string
- * must be coerced to a boolean and this is what will be returned)
- *
- * If the operation cannot be performed on ValueType, return null
- *
- * @param type
- * @return a new value type after the operation is performed
- */
- public abstract ValueType performOperation(ValueType type);
-
-
- /**
- * @param type
- * @return a Diagnostic interpreting whether it is valid to perform the
- * operation on this type
- */
- public abstract Diagnostic validate(ValueType type);
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties
deleted file mode 100644
index ae40823e8..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/validation/internal/el/operators/messages.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2007 Oracle Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle Corporation - initial API and implementation
-###############################################################################
-EqualityRelationalBinaryOperator.FirstArgument=first
-EqualsBinaryRelationalOperator.OperationName=equals
-EqualityRelationalBinaryOperator.SecondArgument=second
-GreaterThanEqRelationalBinaryOperator.OperationName=greater than or equal to
-GreaterThanRelationalBinaryOperator.OperationName=greater than
-LessThanEqRelationalBinaryOperator.OperationName=less than or equal to
-LessThanRelationalBinaryOperator.OperationName=less than
-LtGtRelationalBinaryOperator.ConstantName.False=false
-NotEqualsBinaryRelationalOperator.OperationName=not equals
-BracketOperator.Name=bracket
-DotOperator.Name=dot

Back to the top