incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r606479 [18/30] - in /incubator/imperius/trunk/trunk: ./ modules/ modules/imperius-javaspl/ modules/imperius-javaspl/resources/ modules/imperius-javaspl/resources/samples/ modules/imperius-javaspl/resources/samples/computersystem/ modules/i...
Date Sat, 22 Dec 2007 19:34:03 GMT
Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Power.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Power.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Power.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Power.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,132 @@
+/*
+ * 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 Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Power extends DoubleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Power.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Power";
+    
+    
+    
+    public Power(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Power");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Power");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+  try
+        {
+            Number lhs = (Number) _lhsExp.evaluate();
+            Number rhs = (Number) _rhsExp.evaluate();
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            Number res = _pow(lhs, rhs); 
+            return res;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation errro: " + e.toString());
+            
+            
+            throw new SPLException("evaluation errro: " + e.toString());
+        }
+    }
+    
+    private Number _pow(Number base, Number exponent)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "pow");
+        
+        Number result = new Double(Math.pow(base.doubleValue(), exponent.doubleValue()));
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "pow");
+     
+        return result;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isNumeric(lType) && TypeResolver.isNumeric(rType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="Power("+this._lhsExp.toString()+","+ this._rhsExp.toString() + ")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Product.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Product.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Product.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Product.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,207 @@
+/*
+ * 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 Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+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 Product extends DoubleArgumentExpression implements
+NumericExpression
+{
+    
+    public static final String className = Product.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Product";
+    
+    
+    
+    public Product(List exprList, boolean validateExpression)
+    throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass, "Product");
+        
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass, "Product");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass, "evaluate");
+        
+        try
+        {
+            if(logger.isLoggable(Level.FINE))
+                logger.fine("LHS*RHS "+_lhsExp.toString()+" * "+_rhsExp.toString());
+            
+            Number lhs = (Number) _lhsExp.evaluate();
+            Number rhs = (Number) _rhsExp.evaluate();
+            
+            
+            
+            if(logger.isLoggable(Level.FINE))
+                logger.fine("LHS,RHS::"+lhs+","+rhs);
+            
+            Number result = ExpressionUtility.multiplication(lhs, rhs);
+            
+            if(logger.isLoggable(Level.FINE))
+                logger.fine("product result ::"+lhs+" * "+rhs+"="+result);
+            logger.exiting(sourceClass, "evaluate");
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+//    private Number _product(Number o1, Number o2) throws SPLException
+//    {
+//        logger.entering(sourceClass, "evaluate");
+//        
+//        Number[] o = new Number[2];
+//        o[0] = o1;
+//        o[1] = o2;
+//        
+//        if((o1!=null)&&(o2!=null))
+//        {
+//            
+//            //if (resolvedType == TypeConstants.doubleType)
+//            //{
+//            
+//            
+//            Double result=new Double(o1.doubleValue() * o2.doubleValue());
+//            if(logger.isLoggable(Level.FINE))
+//                logger.fine("result "+result);
+//            logger.exiting(sourceClass, "evaluate");
+//            
+//            return result;
+//            /* }
+//            else if (resolvedType == TypeConstants.floatType)
+//            {
+//                logger.exiting(sourceClass, "evaluate");
+//                
+//                Float result=new Float(o1.floatValue() * o2.floatValue());
+//                if(logger.isLoggable(Level.FINE))
+//                    logger.fine("result "+result);
+//                
+//                return result;
+//            }
+//            else if (resolvedType == TypeConstants.longType)
+//            {
+//                logger.exiting(sourceClass, "evaluate");
+//                
+//                Long result=new Long(o1.longValue() * o2.longValue());
+//                if(logger.isLoggable(Level.FINE))
+//                    logger.fine("result "+result);
+//                
+//                return result;
+//            }
+//            else if (resolvedType == TypeConstants.intType)
+//            {
+//                logger.exiting(sourceClass, "evaluate");
+//                
+//                Long result=new Long(o1.intValue() * o2.intValue());
+//                if(logger.isLoggable(Level.FINE))
+//                    logger.fine("result "+result);
+//                
+//                return result;
+//            }
+//            else
+//            {
+//                logger.exiting(sourceClass, "evaluate");
+//                
+//                Integer result=new Integer(o1.byteValue() * o2.byteValue());
+//                if(logger.isLoggable(Level.FINE))
+//                    logger.fine("result "+result);
+//                
+//                return result;
+//            }*/
+//        }
+//        else
+//        {
+//            logger.severe(Thread.currentThread().getName()+" "+"operand is null  LHS="+o1+" RHS="+o2);
+//            
+//            throw new SPLException("operand is null  LHS="+o1+" RHS="+o2);
+//        }
+//    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass, "validate");
+        
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isNumeric(lType) && TypeResolver.isNumeric(rType))
+        {
+            //dataType = TypeResolver
+            // .binaryNumericPromotionResolver(lType, rType);
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass, "validate");
+            
+            return true;
+        }
+        
+        logger.exiting(sourceClass, "validate");
+        
+        return false;
+    }
+    
+    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;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReplaceSubstring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReplaceSubstring.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReplaceSubstring.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReplaceSubstring.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,164 @@
+/*
+ * 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 Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.StringExpression;
+import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ReplaceSubstring extends TripleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = ReplaceSubstring.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ReplaceSubstring";
+    
+    
+    
+    public ReplaceSubstring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ReplaceSubstring");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ReplaceSubstring");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String o1 = (String) _lhsExp.evaluate();
+            String o2 = (String) _midExp.evaluate();
+            String o3 = (String) _rhsExp.evaluate();
+
+            
+            String result = _replaceSubstring(o1, o2, o3);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    /**
+     * Returns a string resulting from replacing all instances of the
+     * fromSubstring with toSubstring in a given string.
+     * <p>
+     * 
+     * @param baseString
+     *            base string
+     * @param fromSubstring
+     *            substring to replace
+     * @param toSubstring
+     *            substring to put in place of fromSubtring
+     * @return the new string
+     */
+    private String _replaceSubstring(String baseString,
+            String fromSubstring, String toSubstring)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "replaceSubstring");
+
+        String result = "";
+        int fromLength = fromSubstring.length();
+        
+        int pos = baseString.indexOf(fromSubstring);
+        int lastpos = 0;
+        while (pos >= 0)
+        {
+            result += baseString.substring(lastpos, pos) + toSubstring;
+            lastpos = pos + fromLength;
+            pos = baseString.indexOf(fromSubstring, lastpos);
+        }
+        if (lastpos < baseString.length())
+        {
+            result += baseString.substring(lastpos, baseString.length());
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "replaceSubstring");
+        
+        return result;
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo mType = _midExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !mType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isString(lType) && TypeResolver.isString(mType)
+                && TypeResolver.isString(rType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="ReplaceSubstring("+this._lhsExp.toString()+","+ this._midExp.toString() + ","+this._rhsExp.toString() + ")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReturnValues.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReturnValues.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReturnValues.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ReturnValues.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,83 @@
+/*
+ * 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 Wang
+ *
+ */
+
+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.evaluator.impl.ReturnObjectStore;
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.MultipleArgumentExpression;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ReturnValues extends MultipleArgumentExpression  
+{
+
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ReturnValues";
+
+	public ReturnValues(List exprList, boolean validateExpression) 
+	{
+		super(exprList);
+		
+	}
+
+	public Object evaluate() throws SPLException 
+	{
+		List resultList = new ArrayList();
+		Iterator expIt = _expressions.iterator();
+		while (expIt.hasNext())
+		{
+			Expression exp = (Expression)expIt.next();
+			Object result = exp.evaluate();
+			resultList.add(result);
+		}
+		
+		
+		ReturnObjectStore.addReturnValues(resultList);
+		return new Integer(0);
+	}
+
+	public boolean validate() throws SPLException 
+	{
+		
+		return true;
+	}
+	
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        Iterator exprIter = this._expressions.iterator();
+        String str = "[";
+        while(exprIter.hasNext()) {
+        	str = str + ((Expression)exprIter.next()).toString() + (exprIter.hasNext()?", ":"]");
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,307 @@
+/*
+ * 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 Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.StringExpression;
+import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class RightSubstring extends TripleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = RightSubstring.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="RightSubstring";
+    
+    
+    
+    public RightSubstring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String o1 = (String) _lhsExp.evaluate();
+            Object o2 = _midExp.evaluate();
+            String o3 = (String) _rhsExp.evaluate();
+            
+            boolean leftToRight;
+            if (o3.equals("LeftToRight"))
+            {
+                leftToRight = true;
+            }
+            else if (o3.equals("RightToLeft"))
+            {
+                leftToRight = false;
+            }
+            else
+            {
+                logger.severe(
+                "Illegal direction argument.");
+                throw new IllegalArgumentException(
+                        "Illegal direction argument.");
+            }
+            if (o2 instanceof String)
+            {
+            	String result = _rightSubstring(o1, (String) o2, leftToRight); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+            else
+            {
+            	String result = _rightSubstring(o1, ((Number) o2).intValue(), leftToRight);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + toString());
+            
+            throw new SPLException("evaluation error: " + toString());
+        }
+    }
+    
+    /**
+     * Returns a <code>String</code> representation of this
+     * <code>Expression</code> in a format
+     * <code>[ RightSubstring (Expression1)  (Expression2)  (Expression3) (LeftToRight | RightToLeft) ]</code>.
+     * <p>
+     * 
+     * @return a String representation of this <code>Expression</code>
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+     
+       // return " RightSubstring (" + super.toString() + " ) ";
+        return " RightSubstring (" + _lhsExp.toString() + "," 
+        	+ _midExp.toString() + "," + _rhsExp.toString() + " ) ";
+    }
+    
+    /**
+     * Returns a specified RightSubstring from a string. If directionLeftToRight
+     * is true, numberChars is the number of characters to return from the end
+     * of the string. If the number is 2, the last two characters of the string
+     * are returned; if the number is 5, the last five characters are returned,
+     * and so on. If the number is negative, the entire string is returned. If
+     * instead directionLeftToRight is false, numberChars counting from left to
+     * right is the number of characters to skip. All the characters to the
+     * right of that number are returned. If the number is negative, the empty
+     * string is returned.<br>
+     * Examples: RightSubstring("AutonomicComputing", 4, LeftToRight) = "ting".
+     * RightSubstring("AutonomicComputing", 4, RightToLeft) = "nomicComputing".
+     * <p>
+     * 
+     * @param string
+     * @param numberChars
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _rightSubstring(String string, int numberChars,
+            boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+
+        
+        if (directionLeftToRight)
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return string;
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return string;
+            }
+            else
+            {
+            	String result = string.substring(string.length() - numberChars, string
+                        .length()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+                
+                return result; 
+            }
+        }
+        else
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                
+                String result = string.substring(numberChars, string.length());
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+                return result;
+            }
+        }
+    }
+    
+    /**
+     * Returns a specified RightSubstring from a string. RightSubstring returns
+     * the characters from the String to the right of the startString, not
+     * including the startString characters. If directionLeftToRight is true,
+     * then it finds StartString by searching the string from left to right. If
+     * directionLeftToRight is false, then it finds startString by searching the
+     * String from right to left. In either case, if the StartString is not
+     * found in the String, then the empty string is returned. <br>
+     * 
+     * Examples: RightSubstring("AutonomicComputing", "om",
+     * LeftToRight)="icComputing" RightSubstring("AutonomicComputing", "om",
+     * RightToLeft)="puting".
+     * <p>
+     * 
+     * @param string
+     * @param startString
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _rightSubstring(String string, String startString,
+            boolean directionLeftToRight)
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+
+        int offsetpoint; // Position of the beginning of the startString
+        
+        if (directionLeftToRight)
+        {
+            offsetpoint = string.indexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                // found string
+                offsetpoint += startString.length();
+            }
+        }
+        else
+        {
+            offsetpoint = string.lastIndexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                offsetpoint += startString.length();
+            }
+        }
+        if (offsetpoint > string.length())
+        {
+            // no characters after string
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+            
+            return "";
+        }
+        else
+        {
+        	String result = string.substring(offsetpoint, string.length()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+            
+            return result;
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo mType = _midExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !mType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isString(lType)
+                && (TypeResolver.isString(mType) || TypeResolver
+                        .isNumeric(mType)) && TypeResolver.isString(rType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Rint.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Rint.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Rint.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Rint.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,124 @@
+/*
+ * 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 Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Rint extends SingleArgumentExpression implements NumericExpression
+{
+    
+    public static final String className = Rint.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Rint";
+    
+    
+    
+    public Rint(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            
+            Number result = _rint((Number) _exp.evaluate());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _rint(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rint");
+        Number result = new Double(Math.rint(o.doubleValue()));
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rint" + result);
+     
+        return result;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="RINT("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Round.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Round.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Round.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Round.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,164 @@
+/*
+ * 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 Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.IllegalExpressionTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Round extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Round.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Round";
+    
+    
+    
+    public Round(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Round");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Round");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	Number result = _round((Number) _exp.evaluate()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _round(Number o1) throws IllegalExpressionTypeException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "round");
+
+        Number[] o = new Number[1];
+        o[0] = o1;
+        
+        int resolvedType = TypeResolver.resolveType(o);
+        
+        if (resolvedType == TypeConstants.doubleType)
+        {
+            long roundVal = Math.round(o1.doubleValue());
+            
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Long(roundVal);
+        }
+        else if (resolvedType == TypeConstants.floatType)
+        {
+            int roundVal = Math.round(o1.floatValue());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Integer(roundVal);
+        }
+        else
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Integer(o1.intValue());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType))
+        {
+            int tp = eType.getType();
+            if (tp == TypeConstants.doubleType)
+            {
+                _dataType.setType(TypeConstants.longType);
+                
+            }
+            else if (tp == TypeConstants.floatType)
+            {
+                _dataType.setType(TypeConstants.intType);
+                
+            }
+            else
+            {
+                _dataType.setType(TypeConstants.intType);
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="ROUND("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,218 @@
+/*
+ * 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.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SdInCollection extends SingleArgumentExpression implements
+        Expression
+{
+    
+    public String className = SdInCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="SdInCollection";
+    
+    
+    
+    public SdInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
+
+       //System.out.println("SdInCollection");
+        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);
+            }
+        }
+        
+        this._dataType.copy(this._exp.getType());
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+       //System.out.println("SdInCollection:evaluate");
+       //System.out.println("this.exp class " + this.exp.getClass() + " type "+ this.exp.getType());
+        Object squareSum = null;
+        Object sum = null;
+        Object expResult = this._exp.evaluate();
+        if (!(expResult instanceof java.util.List))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result of expression is not of type List");
+            throw new SPLException(
+                    "result of expression is not of type List");
+        }
+        ArrayList resultArray = (ArrayList) expResult;
+        Integer count = new Integer(resultArray.size());
+       //System.out.println("resultArray size " + resultArray.size() + " to string " + resultArray.toString());
+        ////System.out.println("resultArray is of type "+expression.getType());
+        if ((resultArray != null) && (!resultArray.isEmpty()))
+        {
+            Iterator resultIt = resultArray.iterator();
+            while (resultIt.hasNext())
+            {
+                Object resultObject = resultIt.next();
+               //System.out.println("resultObject,class " + resultObject + " " + resultObject.getClass());
+                if (sum == null)
+                {
+                    sum = resultObject;
+                    
+                }
+                else
+                {
+                   //System.out .println("Adding resultObject to SdInCollection is " + resultObject + "  " + sum);
+                    sum = ExpressionUtility.plus((Number) sum,
+                            (Number) resultObject);
+                }
+                Object square = ExpressionUtility.multiplication(
+                        (Number) resultObject, (Number) resultObject);
+                if (squareSum == null)
+                {
+                    squareSum = square;
+                    
+                }
+                else
+                {
+                   //System.out .println("Adding resultObject to SdInCollection is "+ resultObject + "  " + sum);
+                    squareSum = ExpressionUtility.plus((Number) square,
+                            (Number) squareSum);
+                }
+                
+            }
+            double mean = ((Number) sum).doubleValue() / resultArray.size();
+            Number squareSumByCount = ExpressionUtility.division(
+                    (Number) squareSum, (Number) count);
+            Double meanSquare = new Double(mean * mean);
+            Number subtractionResult = ExpressionUtility.minus(
+                    squareSumByCount, (Number) meanSquare);
+           //System.out.println("current SdInCollection is "+ Math.sqrt(subtractionResult.doubleValue()));
+            Number result = new Double(Math.sqrt(subtractionResult.doubleValue())); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+            
+        }
+        else
+        {
+
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+            throw new SPLException("result Array is empty");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("SdInCollection : validate ");
+       //System.out.println("this.exp.getClass() " + this.exp.getClass() + " type " + this.exp.getType());
+        
+        if (!this._exp.isArray())
+        {
+           //System.out.println("expression is not a valid BasicCollectExpression");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        
+        else
+        {
+           //System.out.println("expression is a valid BasicCollectExpression");
+            switch (this._exp.getType().getType())
+            {
+                case TypeConstants.byteType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.doubleType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.floatType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.intType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.longType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.numericType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.shortType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                default:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                    return false;
+            }
+            
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="SdInCollection("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.ConstantExpression;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ShortConstant extends ConstantExpression implements
+        NumericExpression
+{
+    
+    private short _shortValue;
+    
+    private TypeInfo _dataType=new TypeInfo();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ShortConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        
+        return false;
+    }
+    
+    public ShortConstant(short val)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
+
+        this._shortValue = val;
+        _dataType.setType(TypeConstants.shortType);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+     
+        return new Short(_shortValue);
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        return _dataType;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str=Short.toString(this._shortValue);
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,125 @@
+/*
+ * 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 Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SquareRoot extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = SquareRoot.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="SquareRoot";
+    
+    
+    
+    public SquareRoot(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	Number result = _sqrt((Number) _exp.evaluate()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _sqrt(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sqrt");
+        Number result = new Double(Math.sqrt(o.doubleValue()));
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sqrt" + result);
+     
+        return result;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "SquareRoot(" +this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,117 @@
+/*
+ * 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 Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.expressions.StringExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class StartsWith extends DoubleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = StartsWith.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="StartsWith";
+    
+    
+    
+    public StartsWith(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String s0 = (String) _lhsExp.evaluate();
+            String s1 = (String) _rhsExp.evaluate();
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return new Boolean(s0.startsWith(s1));
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !rType.getIsArray() && 
+        		TypeResolver.isString(lType) && TypeResolver.isString(rType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "startsWith(" +this._lhsExp.toString()+","+ this._rhsExp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringConstant.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringConstant.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringConstant.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,109 @@
+/*
+ * 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.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.ConstantExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class StringConstant extends ConstantExpression
+{
+    
+    private String stringValue;
+    
+    public TypeInfo _dataType = new TypeInfo();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="StringConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        return false;
+    }
+    
+    public StringConstant(String s)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StringConstant");
+
+        
+        s = s.substring(1, s.length() - 1);
+        this.stringValue = s;
+        _dataType.setType(TypeConstants.stringType);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StringConstant");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new String(stringValue);
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        return _dataType;
+    }
+    
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str=this.stringValue;
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringLength.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringLength.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringLength.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/StringLength.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,114 @@
+/*
+ * 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.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class StringLength extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = StringLength.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="StringLength";
+    
+    
+    
+    public StringLength(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StringLength");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StringLength");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	Number result = new Integer(((String) _exp.evaluate()).length()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.intType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "StringLength("+this._exp.toString() +")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SubCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SubCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SubCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/SubCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,195 @@
+/*
+ * 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.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.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SubCollection extends DoubleArgumentExpression implements
+        Expression
+{
+    
+    // private BasicCollectionExpression basicCollection=null;
+    public String className = SubCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="SubCollection";
+    
+    
+    
+    public SubCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SubCollection");
+
+       //System.out.println("SubCollection");
+        // this.basicCollection=new BasicCollectionExpression(exprList,new
+        // SPLSymbolTable());
+        
+        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);
+            }
+            
+        }
+        this._dataType.setType(TypeConstants.booleanType);
+       
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SubCollection");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+       //System.out.println("SubCollection:evaluate");
+        Object lhsResult = this._lhsExp.evaluate();
+        Object rhsResult = this._rhsExp.evaluate();
+        if (!(lhsResult instanceof java.util.List))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"lhsResult is not of type List");
+            throw new SPLException("lhsResult is not of type List");
+        }
+        else
+        {
+           //System.out.println("lhsResult is of type List");
+        }
+        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");
+        }
+        else
+        {
+           //System.out.println("rhsResult is of type List");
+        }
+        
+        List lhsResultarray = (List) lhsResult;
+        List rhsResultarray = (List) rhsResult;
+        Boolean result = Boolean.FALSE;
+        if (lhsResultarray.size() > rhsResultarray.size())
+        {
+            result = Boolean.FALSE;
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return result;
+        }
+        Iterator lhsResultarrayIt = lhsResultarray.iterator();
+        while (lhsResultarrayIt.hasNext())
+        {
+            Object lhsResultarrayElement = lhsResultarrayIt.next();
+           //System.out.println("element from Lhs ResultArray " + lhsResultarrayElement + "  " + lhsResultarrayElement.getClass());
+            if (!(rhsResultarray.contains(lhsResultarrayElement)))
+            {
+               //System.out.println("element does not exists in RHS List");
+                result = Boolean.FALSE;
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            {
+               //System.out.println("element exists in RHS List");
+            }
+            
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+     
+        return Boolean.TRUE;
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("SubCollection : validate ");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        if ((lhsExpression == null) || (rhsExpression == null))
+        {
+           //System.out.println("SubCollection : One or more expressions are null ");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        if (!TypeResolver.areTypesEqual(lhsExpression.getType(),rhsExpression.getType()))
+        {
+           //System.out.println("SubCollection : lhs Type !=rhs Type " + lhsExpression.getType() + ":" + rhsExpression.getType());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        if (lhsExpression.isArray())
+        {
+           //System.out.println("lhsExpression.getType() ==TypeConstants.basicCollectionType");
+            if (rhsExpression.isArray())
+            {
+               //System.out.println("rhsExpression.getType() ==TypeConstants.basicCollectionType");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return true;
+                
+            }
+            else
+            {
+               //System.out.println("rhsExpression.getType() !=TypeConstants.basicCollectionType");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return false;
+            }
+        }
+        else
+        {
+           //System.out.println("lhsExpression.getType() !=TypeConstants.basicCollectionType");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "SubCollection("+this._lhsExp.toString() + ","+ this._rhsExp.toString()+")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}



Mime
View raw message