incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r611261 [13/43] - in /incubator/imperius/trunk: ./ imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/ imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src...
Date Fri, 11 Jan 2008 18:57:14 GMT
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AnyInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AnyInCollection.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AnyInCollection.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AnyInCollection.java Fri Jan 11 10:56:30 2008
@@ -1,450 +1,450 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <prabalig@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.IllegalParameterTypeException;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
-import org.apache.imperius.spl.parser.util.ExpressionUtility;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class AnyInCollection extends TripleArgumentExpression implements
-        Expression
-{
-    
-    public String className = InCollection.class.toString();
-    
-    public List expressionList = null;
-    
-    public String operationString = null;
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="AnyInCollection";
-    
-    
-    
-    public static final String LOR = "OR";
-    
-    public static final String LAND = "AND";
-    
-    public static final String BXOR = "XOR";
-    
-    public static final String NOT_EQUAL = "NOT_EQUAL";
-    
-    public static final String EQUAL = "EQUAL";
-    
-    public static final String LT = "LESS";
-    
-    public static final String GT = "GREATER";
-    
-    public static final String LE = "LESS_OR_EQUAL";
-    
-    public static final String GE = "GREATER_OR_EQUAL";
-    
-    public static final String PLUS = "PLUS";
-    
-    public static final String MINUS = "MINUS";
-    
-    public static final String STAR = "MULTIPLY";
-    
-    public static final String DIV = "DIVIDE";
-    
-    public AnyInCollection(List exprList, boolean evaluateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AnyInCollection");
-
-        
-        //System.out.println("AnyInCollection");
-        if (evaluateExpression)
-        {
-            //System.out.println("evaluateExpression " + evaluateExpression);
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: wrong data type passed in");
-                throw new SPLException(
-                        "validation error: wrong data type passed in "
-                                + this._dataType);
-            }
-        }
-        _dataType.setType(TypeConstants.booleanType);
-        this._dataType.setIsArray(false);
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AnyInCollection");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        //System.out.println("AnyInCollection:evaluate");
-        Expression lhsExpression = (Expression) this._lhsExp;
-        Expression rhsExpression = (Expression) this._rhsExp;
-        
-        if (rhsExpression.isArray())
-        {
-            //System.out.println("rhs is of type Basic Collection");
-            Object rhsResult = rhsExpression.evaluate();
-            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
-            if (!(rhsResult instanceof java.util.List))
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"rhsResult is not of type List");
-                throw new SPLException("rhsResult is not of type List");
-            }
-            Boolean result = Boolean.FALSE;
-            ArrayList rhsResultArray = (ArrayList) rhsResult;
-            //System.out.println("resultArray size " + rhsResultArray.size()+ " to string " + rhsResultArray.toString());
-            //System.out.println("LHS expression is of type "+ lhsExpression.getType());
-            if ((rhsResultArray != null) && (!rhsResultArray.isEmpty()))
-            {
-                Object lhsResult = (Object) lhsExpression.evaluate();
-                //System.out.println("lhsResult " + lhsResult.toString());
-                Iterator rhsResultIt = rhsResultArray.iterator();
-                while (rhsResultIt.hasNext())
-                {
-                    Object value = (Object) rhsResultIt.next();
-                    //System.out.println("rhsResult element " + value.toString());
-                    if (operationString.equalsIgnoreCase(LAND))
-                    {
-                        if ((!(value instanceof Boolean))
-                                || (!(lhsResult instanceof Boolean)))
-                        {
-                            logger.severe(
-                            "LHS or RHS result is not of type Boolean");
-                            throw new SPLException(
-                                    "LHS or RHS result is not of type Boolean");
-                        }
-                        else
-                        {
-                            Boolean Value1 = (Boolean) lhsResult;
-                            Boolean Value2 = (Boolean) value;
-                            boolean res = Value1.booleanValue()
-                                    && Value2.booleanValue();
-                            if (res)
-                            {
-                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                                
-                                return new Boolean(res);
-                            }
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(LOR))
-                    {
-                        if ((!(value instanceof Boolean))
-                                || (!(lhsResult instanceof Boolean)))
-                        {
-                            logger.severe(
-                            "LHS or RHS result is not of type Boolean");
-                            
-                            throw new SPLException(
-                                    "LHS or RHS result is not of type Boolean");
-                        }
-                        else
-                        {
-                            Boolean Value1 = (Boolean) lhsResult;
-                            Boolean Value2 = (Boolean) value;
-                            boolean res = Value1.booleanValue()
-                                    || Value2.booleanValue();
-                            if (res)
-                            {
-                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                                
-                                return new Boolean(res);
-                            }
-                        }
-                        
-                    }
-                    if (operationString.equalsIgnoreCase(BXOR))
-                    {
-                        if ((!(value instanceof Boolean))
-                                || (!(lhsResult instanceof Boolean)))
-                        {
-                            logger.severe(
-                            "LHS or RHS result is not of type Boolean");
-                            
-                            throw new SPLException(
-                                    "LHS or RHS result is not of type Boolean");
-                        }
-                        else
-                        {
-                            Boolean Value1 = (Boolean) lhsResult;
-                            Boolean Value2 = (Boolean) value;
-                            boolean res = (Value1.booleanValue() && !Value2
-                                    .booleanValue())
-                                    || (!Value1.booleanValue() && Value2
-                                            .booleanValue());
-                            if (res)
-                            {
-                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                                
-                                return new Boolean(res);
-                            }
-                        }
-                        
-                    }
-                    
-                    if (operationString.equalsIgnoreCase(EQUAL))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) == 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(NOT_EQUAL))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) != 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(GT))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) > 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(GE))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) >= 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(LT))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) < 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    if (operationString.equalsIgnoreCase(LE))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        if (ExpressionUtility.compare(Value2, Value1) <= 0)
-                        {
-                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                            
-                            return Boolean.TRUE;
-                        }
-                    }
-                    
-                    //System.out.println("did not match");
-                }
-                //System.out.println("no matches: Lhs not true for AnyInCollection");
-                result = Boolean.FALSE;
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-                
-                return result;
-            }
-            else
-            {
-                logger.severe(
-                "the RHS of AnyInCollection expression is null BasicCollection");
-                
-                throw new IllegalParameterTypeException(
-                        "the RHS of AnyInCollection expression is null BasicCollection");
-            }
-        }
-        else
-        {
-            logger.severe(
-            "the RHS of AnyInCollection expression should be of BasicCollection type");
-            
-            throw new IllegalParameterTypeException(
-                    "the RHS of AnyInCollection expression should be of BasicCollection type");
-        }
-        
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        //System.out.println("AnyInCollection : validate ");
-        Expression expression1 = (Expression) this._lhsExp;
-        Expression expression2 = (Expression) this._midExp;
-        Expression expression3 = (Expression) this._rhsExp;
-        TypeInfo leftType = expression1.getType();
-        TypeInfo middleType = expression2.getType();
-        TypeInfo rightType = expression3.getType();
-        
-        if (!expression3.getType().getIsArray())
-        {
-        	//System.out.println(" expression3.getType().getIsArray() "+expression3.getType().getIsArray());
-        	//System.out.println("expression3 "+expression3.getClass()+" "+expression3.toString());
-        	logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
-            
-            throw new SPLException("Last Expression should be a collection");
-        }
-        
-        if (expression1.isArray())
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"First Expression cannot be a collection");
-            
-            throw new SPLException("First Expression cannot be a collection");
-        }
-        
-        if (!TypeResolver.isString(middleType))
-        {
-            logger.severe(
-            "Middle Expression should be a string describing the Operation");
-            
-            throw new SPLException(
-                    "Middle Expression should be a string describing the Operation");
-        }
-        this.operationString = (String) expression2.evaluate();
-        if (this.operationString == null)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Operation string is null");
-            
-            throw new SPLException("Operation string is null");
-        }
-        if (this.operationString == null)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Operation type is "
-                    + this.operationString);
-            
-            throw new SPLException("Operation type is "
-                    + this.operationString);
-        }
-        
-        if (operationString.equalsIgnoreCase(LAND)
-                || operationString.equalsIgnoreCase(LOR)
-                || operationString.equalsIgnoreCase(BXOR))
-        {
-            if (TypeResolver.isBoolean(leftType))
-            {
-                if (TypeResolver.isBoolean(rightType))
-                {
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                    
-                }
-                else
-                {
-                    logger.severe(
-                    "LHS is of type Boolean but RHS is not of type Boolean");
-                    
-                    throw new SPLException(
-                            "LHS is of type Boolean but RHS is not of type Boolean");
-                }
-            }
-            else
-            {
-                logger.severe(
-                "Operation is of type Boolean but LHS is not of type boolean");
-                
-                throw new SPLException(
-                        "Operation is of type Boolean but LHS is not of type boolean");
-            }
-        }
-        else if (operationString.equalsIgnoreCase(EQUAL)
-                || operationString.equalsIgnoreCase(NOT_EQUAL)
-                || operationString.equalsIgnoreCase(GT)
-                || operationString.equalsIgnoreCase(GE)
-                || operationString.equalsIgnoreCase(LT)
-                || operationString.equalsIgnoreCase(LE))
-        {
-            
-            if (TypeResolver.isTypeAssignableForEquality(leftType, rightType))
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                
-                return true;
-            }
-            else if (TypeResolver.isTypeAssignableForRelation(leftType,
-                    rightType))
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                
-                return true;
-            }
-            else
-            {
-                logger.severe(
-                "types are not assignable for Relation or Equality");
-                
-                throw new SPLException(
-                        "types are not assignable for Relation or Equality");
-            }
-        }
-        else
-        {
-            logger.severe(
-            "operationString is not supported by AnyInCollection");
-            
-            throw new SPLException(
-                    "operationString is not supported by AnyInCollection");
-        }
-        
-    }
-
-	public String getReferenceTypeName() throws SPLException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
-        String str = "AnyInCollection("+ this._lhsExp.toString() +"," + this._midExp.toString() + "," + this._rhsExp.toString() + ")";
-        	
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.IllegalParameterTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class AnyInCollection extends TripleArgumentExpression implements
+        Expression
+{
+    
+    public String className = InCollection.class.toString();
+    
+    public List expressionList = null;
+    
+    public String operationString = null;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="AnyInCollection";
+    
+    
+    
+    public static final String LOR = "OR";
+    
+    public static final String LAND = "AND";
+    
+    public static final String BXOR = "XOR";
+    
+    public static final String NOT_EQUAL = "NOT_EQUAL";
+    
+    public static final String EQUAL = "EQUAL";
+    
+    public static final String LT = "LESS";
+    
+    public static final String GT = "GREATER";
+    
+    public static final String LE = "LESS_OR_EQUAL";
+    
+    public static final String GE = "GREATER_OR_EQUAL";
+    
+    public static final String PLUS = "PLUS";
+    
+    public static final String MINUS = "MINUS";
+    
+    public static final String STAR = "MULTIPLY";
+    
+    public static final String DIV = "DIVIDE";
+    
+    public AnyInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AnyInCollection");
+
+        
+        //System.out.println("AnyInCollection");
+        if (evaluateExpression)
+        {
+            //System.out.println("evaluateExpression " + evaluateExpression);
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: wrong data type passed in");
+                throw new SPLException(
+                        "validation error: wrong data type passed in "
+                                + this._dataType);
+            }
+        }
+        _dataType.setType(TypeConstants.booleanType);
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AnyInCollection");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        //System.out.println("AnyInCollection:evaluate");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        
+        if (rhsExpression.isArray())
+        {
+            //System.out.println("rhs is of type Basic Collection");
+            Object rhsResult = rhsExpression.evaluate();
+            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
+            if (!(rhsResult instanceof java.util.List))
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"rhsResult is not of type List");
+                throw new SPLException("rhsResult is not of type List");
+            }
+            Boolean result = Boolean.FALSE;
+            ArrayList rhsResultArray = (ArrayList) rhsResult;
+            //System.out.println("resultArray size " + rhsResultArray.size()+ " to string " + rhsResultArray.toString());
+            //System.out.println("LHS expression is of type "+ lhsExpression.getType());
+            if ((rhsResultArray != null) && (!rhsResultArray.isEmpty()))
+            {
+                Object lhsResult = (Object) lhsExpression.evaluate();
+                //System.out.println("lhsResult " + lhsResult.toString());
+                Iterator rhsResultIt = rhsResultArray.iterator();
+                while (rhsResultIt.hasNext())
+                {
+                    Object value = (Object) rhsResultIt.next();
+                    //System.out.println("rhsResult element " + value.toString());
+                    if (operationString.equalsIgnoreCase(LAND))
+                    {
+                        if ((!(value instanceof Boolean))
+                                || (!(lhsResult instanceof Boolean)))
+                        {
+                            logger.severe(
+                            "LHS or RHS result is not of type Boolean");
+                            throw new SPLException(
+                                    "LHS or RHS result is not of type Boolean");
+                        }
+                        else
+                        {
+                            Boolean Value1 = (Boolean) lhsResult;
+                            Boolean Value2 = (Boolean) value;
+                            boolean res = Value1.booleanValue()
+                                    && Value2.booleanValue();
+                            if (res)
+                            {
+                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                                
+                                return new Boolean(res);
+                            }
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(LOR))
+                    {
+                        if ((!(value instanceof Boolean))
+                                || (!(lhsResult instanceof Boolean)))
+                        {
+                            logger.severe(
+                            "LHS or RHS result is not of type Boolean");
+                            
+                            throw new SPLException(
+                                    "LHS or RHS result is not of type Boolean");
+                        }
+                        else
+                        {
+                            Boolean Value1 = (Boolean) lhsResult;
+                            Boolean Value2 = (Boolean) value;
+                            boolean res = Value1.booleanValue()
+                                    || Value2.booleanValue();
+                            if (res)
+                            {
+                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                                
+                                return new Boolean(res);
+                            }
+                        }
+                        
+                    }
+                    if (operationString.equalsIgnoreCase(BXOR))
+                    {
+                        if ((!(value instanceof Boolean))
+                                || (!(lhsResult instanceof Boolean)))
+                        {
+                            logger.severe(
+                            "LHS or RHS result is not of type Boolean");
+                            
+                            throw new SPLException(
+                                    "LHS or RHS result is not of type Boolean");
+                        }
+                        else
+                        {
+                            Boolean Value1 = (Boolean) lhsResult;
+                            Boolean Value2 = (Boolean) value;
+                            boolean res = (Value1.booleanValue() && !Value2
+                                    .booleanValue())
+                                    || (!Value1.booleanValue() && Value2
+                                            .booleanValue());
+                            if (res)
+                            {
+                                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                                
+                                return new Boolean(res);
+                            }
+                        }
+                        
+                    }
+                    
+                    if (operationString.equalsIgnoreCase(EQUAL))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) == 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(NOT_EQUAL))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) != 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(GT))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) > 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(GE))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) >= 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(LT))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) < 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    if (operationString.equalsIgnoreCase(LE))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        if (ExpressionUtility.compare(Value2, Value1) <= 0)
+                        {
+                            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                            
+                            return Boolean.TRUE;
+                        }
+                    }
+                    
+                    //System.out.println("did not match");
+                }
+                //System.out.println("no matches: Lhs not true for AnyInCollection");
+                result = Boolean.FALSE;
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            {
+                logger.severe(
+                "the RHS of AnyInCollection expression is null BasicCollection");
+                
+                throw new IllegalParameterTypeException(
+                        "the RHS of AnyInCollection expression is null BasicCollection");
+            }
+        }
+        else
+        {
+            logger.severe(
+            "the RHS of AnyInCollection expression should be of BasicCollection type");
+            
+            throw new IllegalParameterTypeException(
+                    "the RHS of AnyInCollection expression should be of BasicCollection type");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        //System.out.println("AnyInCollection : validate ");
+        Expression expression1 = (Expression) this._lhsExp;
+        Expression expression2 = (Expression) this._midExp;
+        Expression expression3 = (Expression) this._rhsExp;
+        TypeInfo leftType = expression1.getType();
+        TypeInfo middleType = expression2.getType();
+        TypeInfo rightType = expression3.getType();
+        
+        if (!expression3.getType().getIsArray())
+        {
+        	//System.out.println(" expression3.getType().getIsArray() "+expression3.getType().getIsArray());
+        	//System.out.println("expression3 "+expression3.getClass()+" "+expression3.toString());
+        	logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
+            
+            throw new SPLException("Last Expression should be a collection");
+        }
+        
+        if (expression1.isArray())
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"First Expression cannot be a collection");
+            
+            throw new SPLException("First Expression cannot be a collection");
+        }
+        
+        if (!TypeResolver.isString(middleType))
+        {
+            logger.severe(
+            "Middle Expression should be a string describing the Operation");
+            
+            throw new SPLException(
+                    "Middle Expression should be a string describing the Operation");
+        }
+        this.operationString = (String) expression2.evaluate();
+        if (this.operationString == null)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Operation string is null");
+            
+            throw new SPLException("Operation string is null");
+        }
+        if (this.operationString == null)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Operation type is "
+                    + this.operationString);
+            
+            throw new SPLException("Operation type is "
+                    + this.operationString);
+        }
+        
+        if (operationString.equalsIgnoreCase(LAND)
+                || operationString.equalsIgnoreCase(LOR)
+                || operationString.equalsIgnoreCase(BXOR))
+        {
+            if (TypeResolver.isBoolean(leftType))
+            {
+                if (TypeResolver.isBoolean(rightType))
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                    
+                }
+                else
+                {
+                    logger.severe(
+                    "LHS is of type Boolean but RHS is not of type Boolean");
+                    
+                    throw new SPLException(
+                            "LHS is of type Boolean but RHS is not of type Boolean");
+                }
+            }
+            else
+            {
+                logger.severe(
+                "Operation is of type Boolean but LHS is not of type boolean");
+                
+                throw new SPLException(
+                        "Operation is of type Boolean but LHS is not of type boolean");
+            }
+        }
+        else if (operationString.equalsIgnoreCase(EQUAL)
+                || operationString.equalsIgnoreCase(NOT_EQUAL)
+                || operationString.equalsIgnoreCase(GT)
+                || operationString.equalsIgnoreCase(GE)
+                || operationString.equalsIgnoreCase(LT)
+                || operationString.equalsIgnoreCase(LE))
+        {
+            
+            if (TypeResolver.isTypeAssignableForEquality(leftType, rightType))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return true;
+            }
+            else if (TypeResolver.isTypeAssignableForRelation(leftType,
+                    rightType))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return true;
+            }
+            else
+            {
+                logger.severe(
+                "types are not assignable for Relation or Equality");
+                
+                throw new SPLException(
+                        "types are not assignable for Relation or Equality");
+            }
+        }
+        else
+        {
+            logger.severe(
+            "operationString is not supported by AnyInCollection");
+            
+            throw new SPLException(
+                    "operationString is not supported by AnyInCollection");
+        }
+        
+    }
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "AnyInCollection("+ this._lhsExp.toString() +"," + this._midExp.toString() + "," + this._rhsExp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AnyInCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ApplyToCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ApplyToCollection.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ApplyToCollection.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ApplyToCollection.java Fri Jan 11 10:56:30 2008
@@ -1,294 +1,294 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <prabalig@in.ibm.com>
- *
- */
-
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.IllegalParameterTypeException;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
-import org.apache.imperius.spl.parser.util.ExpressionUtility;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class ApplyToCollection extends TripleArgumentExpression implements
-        Expression
-{
-    
-    public String className = InCollection.class.toString();
-    
-    public List _expressionList = null;
-    
-    public String _operationString = null;
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="ApplyToCollection";
-    
-    
-    
-    public static final String PLUS = "PLUS";
-    
-    public static final String MINUS = "MINUS";
-    
-    public static final String STAR = "MULTIPLY";
-    
-    public static final String DIV = "DIVIDE";
-    
-    public ApplyToCollection(List exprList, boolean evaluateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ApplyToCollection");
-
-        _dataType.setType(TypeConstants.booleanType);
-        this._dataType.setIsArray(false);
-        //System.out.println("ApplyToCollection");
-        if (evaluateExpression)
-        {
-            //System.out.println("evaluateExpression " + evaluateExpression);
-            if (!validate())
-            {
-
-                logger.severe
-               ("validation error: wrong data type passed in"+ this._dataType);
-                throw new SPLException(
-                        "validation error: wrong data type passed in "
-                                + this._dataType);
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ApplyToCollection");
-        
-        // this.dataType=TypeConstants.numericType;
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        //System.out.println("ApplyToCollection:evaluate");
-        Expression lhsExpression = (Expression) this._lhsExp;
-        Expression rhsExpression = (Expression) this._rhsExp;
-        
-        if (rhsExpression.isArray())
-        {
-            //System.out.println("rhs is of type Basic Collection");
-            Object rhsResult = rhsExpression.evaluate();
-            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
-            if (!(rhsResult instanceof java.util.List))
-            {
-                //System.out.println("rhsResult is not of type List");
-                throw new SPLException("rhsResult is not of type List");
-            }
-            List resultList = new ArrayList();
-            ArrayList rhsResultArray = (ArrayList) rhsResult;
-            //System.out.println("resultArray size " + rhsResultArray.size()+ " to string " + rhsResultArray.toString());
-            //System.out.println("LHS expression is of type "+ lhsExpression.getType());
-            if ((rhsResultArray != null) && (!rhsResultArray.isEmpty()))
-            {
-                Object lhsResult = (Object) lhsExpression.evaluate();
-                //System.out.println("lhsResult " + lhsResult.toString());
-                Iterator rhsResultIt = rhsResultArray.iterator();
-                while (rhsResultIt.hasNext())
-                {
-                    Object value = (Object) rhsResultIt.next();
-                    //System.out.println("rhsResult element " + value.toString());
-                    
-                    if (_operationString.equalsIgnoreCase(DIV))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        Object res = ExpressionUtility.division(
-                                (Number) Value2, (Number) Value1);
-                        //System.out.println("result" + res.toString());
-                        resultList.add(res);
-                    }
-                    if (_operationString.equalsIgnoreCase(PLUS))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        Object res = ExpressionUtility.plus((Number) Value1,
-                                (Number) Value2);
-                        resultList.add(res);
-                    }
-                    if (_operationString.equalsIgnoreCase(MINUS))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        Object res = ExpressionUtility.minus((Number) Value2,
-                                (Number) Value1);
-                        resultList.add(res);
-                    }
-                    if (_operationString.equalsIgnoreCase(STAR))
-                    {
-                        Object Value1 = lhsResult;
-                        Object Value2 = value;
-                        Object res = ExpressionUtility.multiplication(
-                                (Number) Value2, (Number) Value1);
-                        resultList.add(res);
-                    }
-                    
-                }
-
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-             
-                return resultList;
-            }
-            else
-            {
-                logger.severe(
-                "the RHS of ApplyToCollection expression is null BasicCollection");
-                
-                throw new IllegalParameterTypeException(
-                        "the RHS of ApplyToCollection expression is null BasicCollection");
-            }
-        }
-        else
-        {
-            logger.severe(
-            "the RHS of ApplyToCollection expression should be of BasicCollection type");
-            
-            
-            throw new IllegalParameterTypeException(
-                    "the RHS of ApplyToCollection expression should be of BasicCollection type");
-        }
-        
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        //System.out.println("ApplyToCollection : validate ");
-        Expression expression1 = (Expression) this._lhsExp;
-        Expression expression2 = (Expression) this._midExp;
-        Expression expression3 = (Expression) this._rhsExp;
-        TypeInfo leftType = expression1.getType();
-        TypeInfo middleType = expression2.getType();
-        TypeInfo rightType = expression3.getType();
-        
-        if (!expression3.isArray())
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
-            
-            throw new SPLException("Last Expression should be a collection");
-        }
-        
-        if (expression1.isArray())
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"First Expression cannot be a collection");
-            
-            throw new SPLException("First Expression cannot be a collection");
-        }
-        
-        if (!TypeResolver.isString(middleType))
-        {
-            logger.severe(
-            "Middle Expression should be a string describing the Operation");
-            
-            throw new SPLException(
-                    "Middle Expression should be a string describing the Operation");
-        }
-        this._operationString = (String) expression2.evaluate();
-        if (this._operationString == null)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Operation string is null");
-            
-            throw new SPLException("Operation string is null");
-        }
-        if (this._operationString == null)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Operation type is "
-                    + this._operationString);
-            
-            throw new SPLException("Operation type is "
-                    + this._operationString);
-        }
-        
-        if (_operationString.equalsIgnoreCase(DIV)
-                || _operationString.equalsIgnoreCase(PLUS)
-                || _operationString.equalsIgnoreCase(MINUS)
-                || _operationString.equalsIgnoreCase(STAR))
-        {
-            
-            if (TypeResolver.isNumeric(leftType))
-            {
-                if (TypeResolver.isNumeric(rightType))
-                {
-                    this._dataType = TypeResolver
-                            .binaryNumericPromotionResolver(leftType, rightType);
-                   _dataType.setIsArray(true);
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                }
-                else
-                {
-                    logger.severe(
-                    "RHS is not numeric, and hence not applicable to ApplyToCollection");
-                    
-                    
-                    throw new SPLException(
-                            "RHS is not numeric, and hence not applicable to ApplyToCollection");
-                }
-            }
-            else
-            {
-                logger.severe(
-                "LHS is not numeric, and hence not applicable to ApplyToCollection");
-                
-                
-                throw new SPLException(
-                        "LHS is not numeric, and hence not applicable to ApplyToCollection");
-            }
-        }
-        else
-        {
-            logger.severe(
-            "operationString is not supported by ApplyToCollection");
-            throw new SPLException(
-                    "operationString is not supported by ApplyToCollection");
-        }
-    }
-
-	public String getReferenceTypeName() throws SPLException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
-        String str = "ApplyToCollection("+ this._lhsExp.toString() + "," + this._midExp.toString() + "," + this._rhsExp.toString() + ")";
-        	
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.IllegalParameterTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ApplyToCollection extends TripleArgumentExpression implements
+        Expression
+{
+    
+    public String className = InCollection.class.toString();
+    
+    public List _expressionList = null;
+    
+    public String _operationString = null;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ApplyToCollection";
+    
+    
+    
+    public static final String PLUS = "PLUS";
+    
+    public static final String MINUS = "MINUS";
+    
+    public static final String STAR = "MULTIPLY";
+    
+    public static final String DIV = "DIVIDE";
+    
+    public ApplyToCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ApplyToCollection");
+
+        _dataType.setType(TypeConstants.booleanType);
+        this._dataType.setIsArray(false);
+        //System.out.println("ApplyToCollection");
+        if (evaluateExpression)
+        {
+            //System.out.println("evaluateExpression " + evaluateExpression);
+            if (!validate())
+            {
+
+                logger.severe
+               ("validation error: wrong data type passed in"+ this._dataType);
+                throw new SPLException(
+                        "validation error: wrong data type passed in "
+                                + this._dataType);
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ApplyToCollection");
+        
+        // this.dataType=TypeConstants.numericType;
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        //System.out.println("ApplyToCollection:evaluate");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        
+        if (rhsExpression.isArray())
+        {
+            //System.out.println("rhs is of type Basic Collection");
+            Object rhsResult = rhsExpression.evaluate();
+            //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
+            if (!(rhsResult instanceof java.util.List))
+            {
+                //System.out.println("rhsResult is not of type List");
+                throw new SPLException("rhsResult is not of type List");
+            }
+            List resultList = new ArrayList();
+            ArrayList rhsResultArray = (ArrayList) rhsResult;
+            //System.out.println("resultArray size " + rhsResultArray.size()+ " to string " + rhsResultArray.toString());
+            //System.out.println("LHS expression is of type "+ lhsExpression.getType());
+            if ((rhsResultArray != null) && (!rhsResultArray.isEmpty()))
+            {
+                Object lhsResult = (Object) lhsExpression.evaluate();
+                //System.out.println("lhsResult " + lhsResult.toString());
+                Iterator rhsResultIt = rhsResultArray.iterator();
+                while (rhsResultIt.hasNext())
+                {
+                    Object value = (Object) rhsResultIt.next();
+                    //System.out.println("rhsResult element " + value.toString());
+                    
+                    if (_operationString.equalsIgnoreCase(DIV))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        Object res = ExpressionUtility.division(
+                                (Number) Value2, (Number) Value1);
+                        //System.out.println("result" + res.toString());
+                        resultList.add(res);
+                    }
+                    if (_operationString.equalsIgnoreCase(PLUS))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        Object res = ExpressionUtility.plus((Number) Value1,
+                                (Number) Value2);
+                        resultList.add(res);
+                    }
+                    if (_operationString.equalsIgnoreCase(MINUS))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        Object res = ExpressionUtility.minus((Number) Value2,
+                                (Number) Value1);
+                        resultList.add(res);
+                    }
+                    if (_operationString.equalsIgnoreCase(STAR))
+                    {
+                        Object Value1 = lhsResult;
+                        Object Value2 = value;
+                        Object res = ExpressionUtility.multiplication(
+                                (Number) Value2, (Number) Value1);
+                        resultList.add(res);
+                    }
+                    
+                }
+
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+             
+                return resultList;
+            }
+            else
+            {
+                logger.severe(
+                "the RHS of ApplyToCollection expression is null BasicCollection");
+                
+                throw new IllegalParameterTypeException(
+                        "the RHS of ApplyToCollection expression is null BasicCollection");
+            }
+        }
+        else
+        {
+            logger.severe(
+            "the RHS of ApplyToCollection expression should be of BasicCollection type");
+            
+            
+            throw new IllegalParameterTypeException(
+                    "the RHS of ApplyToCollection expression should be of BasicCollection type");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        //System.out.println("ApplyToCollection : validate ");
+        Expression expression1 = (Expression) this._lhsExp;
+        Expression expression2 = (Expression) this._midExp;
+        Expression expression3 = (Expression) this._rhsExp;
+        TypeInfo leftType = expression1.getType();
+        TypeInfo middleType = expression2.getType();
+        TypeInfo rightType = expression3.getType();
+        
+        if (!expression3.isArray())
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Last Expression should be a collection");
+            
+            throw new SPLException("Last Expression should be a collection");
+        }
+        
+        if (expression1.isArray())
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"First Expression cannot be a collection");
+            
+            throw new SPLException("First Expression cannot be a collection");
+        }
+        
+        if (!TypeResolver.isString(middleType))
+        {
+            logger.severe(
+            "Middle Expression should be a string describing the Operation");
+            
+            throw new SPLException(
+                    "Middle Expression should be a string describing the Operation");
+        }
+        this._operationString = (String) expression2.evaluate();
+        if (this._operationString == null)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Operation string is null");
+            
+            throw new SPLException("Operation string is null");
+        }
+        if (this._operationString == null)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Operation type is "
+                    + this._operationString);
+            
+            throw new SPLException("Operation type is "
+                    + this._operationString);
+        }
+        
+        if (_operationString.equalsIgnoreCase(DIV)
+                || _operationString.equalsIgnoreCase(PLUS)
+                || _operationString.equalsIgnoreCase(MINUS)
+                || _operationString.equalsIgnoreCase(STAR))
+        {
+            
+            if (TypeResolver.isNumeric(leftType))
+            {
+                if (TypeResolver.isNumeric(rightType))
+                {
+                    this._dataType = TypeResolver
+                            .binaryNumericPromotionResolver(leftType, rightType);
+                   _dataType.setIsArray(true);
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                }
+                else
+                {
+                    logger.severe(
+                    "RHS is not numeric, and hence not applicable to ApplyToCollection");
+                    
+                    
+                    throw new SPLException(
+                            "RHS is not numeric, and hence not applicable to ApplyToCollection");
+                }
+            }
+            else
+            {
+                logger.severe(
+                "LHS is not numeric, and hence not applicable to ApplyToCollection");
+                
+                
+                throw new SPLException(
+                        "LHS is not numeric, and hence not applicable to ApplyToCollection");
+            }
+        }
+        else
+        {
+            logger.severe(
+            "operationString is not supported by ApplyToCollection");
+            throw new SPLException(
+                    "operationString is not supported by ApplyToCollection");
+        }
+    }
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "ApplyToCollection("+ this._lhsExp.toString() + "," + this._midExp.toString() + "," + this._rhsExp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ApplyToCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AssignmentExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AssignmentExpression.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AssignmentExpression.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AssignmentExpression.java Fri Jan 11 10:56:30 2008
@@ -1,129 +1,129 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * 
- * @author Xiping Change Log: 3/9/07: Neeraj Joshi: Changed signature to take a
- *         list of expressions and boolean This will help in reflection
- * 
- */
-
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.exceptions.TypesNotAssignableException;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-
-public class AssignmentExpression extends DoubleArgumentExpression
-{
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="AssignmentExpression";
-    
-    
-    
-    public AssignmentExpression(List exprList, boolean evaluateExpression)
-            throws SPLException
-    {
-        
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AssignmentExpression");
-
-        validate();
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AssignmentExpression");
-        
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        
-        Object rhsResult = _rhsExp.evaluate();
-        // code to insert rhs into the symbol table
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-        
-        return rhsResult;
-    }
-    
-    // @Override
-    public TypeInfo getType()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
-     
-        
-        return _dataType;
-    }
-    
-    // @Override
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo lType = _lhsExp.getType();
-        TypeInfo rType = _rhsExp.getType();
-        if (!TypeResolver.isTypeAssignableForEquality(lType, rType))
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"Types not compatible");
-            throw new TypesNotAssignableException("Types not compatible");
-        }
-        _dataType.copy(rType);
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-        
-        return true;
-    }
-    
-    public Expression getLHSExpression() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getLHSExpression");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getLHSExpression");
-     
-        return this._lhsExp;
-    }
-    
-    public Expression getRHSExpression() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRHSExpression");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRHSExpression");
-     
-        return this._rhsExp;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
-        String str = this._lhsExp.toString() + " = " + this._rhsExp.toString();
-        	
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * 
+ * @author Xiping Change Log: 3/9/07: Neeraj Joshi: Changed signature to take a
+ *         list of expressions and boolean This will help in reflection
+ * 
+ */
+
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.exceptions.TypesNotAssignableException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class AssignmentExpression extends DoubleArgumentExpression
+{
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="AssignmentExpression";
+    
+    
+    
+    public AssignmentExpression(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AssignmentExpression");
+
+        validate();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AssignmentExpression");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        
+        Object rhsResult = _rhsExp.evaluate();
+        // code to insert rhs into the symbol table
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        return rhsResult;
+    }
+    
+    // @Override
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        
+        return _dataType;
+    }
+    
+    // @Override
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        if (!TypeResolver.isTypeAssignableForEquality(lType, rType))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Types not compatible");
+            throw new TypesNotAssignableException("Types not compatible");
+        }
+        _dataType.copy(rType);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        return true;
+    }
+    
+    public Expression getLHSExpression() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getLHSExpression");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getLHSExpression");
+     
+        return this._lhsExp;
+    }
+    
+    public Expression getRHSExpression() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRHSExpression");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRHSExpression");
+     
+        return this._rhsExp;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = this._lhsExp.toString() + " = " + this._rhsExp.toString();
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/AssignmentExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message