You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-commits@incubator.apache.org by jn...@apache.org on 2007/12/22 19:34:03 UTC

svn commit: r606479 [17/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...

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,103 @@
+/*
+ * 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 <pr...@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 LongConstant extends ConstantExpression implements
+        NumericExpression
+{
+    
+    private long _longValue;
+    
+    private TypeInfo _dataType=new TypeInfo();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LongConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        return _dataType.getIsArray();
+    }
+    
+    public LongConstant(long val)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
+
+        this._longValue = val;
+        _dataType.setType(TypeConstants.longType);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Long(_longValue);
+        }
+        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 = Long.toString(this._longValue);
+        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/MatchesRegExp.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java Sat Dec 22 11:33:46 2007
@@ -0,0 +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 Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+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 MatchesRegExp extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = MatchesRegExp.class.getName();
+    
+    private Pattern _regex = null;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MatchesRegExp";
+    
+    
+    
+    public MatchesRegExp(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MatchesRegExp");
+
+        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()+" "+ "MatchesRegExp");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String string = (String) _lhsExp.evaluate();
+            Pattern pattern = null;
+            if (_regex == null)
+            { // need to precompile the regex
+                pattern = Pattern.compile((String) _rhsExp.evaluate());
+            }
+            else
+            { // regex precompiled during construction
+                pattern = _regex;
+            }
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return Boolean.valueOf(pattern.matcher(string).matches());
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"invalid expression.");
+            
+            throw new SPLException("invalid expression.");
+        }
+    }
+    
+    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.booleanType);
+            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 = "MatchesRegExp("+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/Max.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Max.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Max.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Max.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.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.MultipleArgumentExpression;
+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 Max extends MultipleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Max.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Max";
+    
+    
+    
+    public Max(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Max");
+
+        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.");
+            }
+        }
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Max");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Iterator expIterator = this._expressions.iterator();
+            Number max = null;
+            while (expIterator.hasNext())
+            {
+                Expression exp = (Expression) expIterator.next();
+                Number evalResult = (Number) exp.evaluate();
+                
+                if (max == null)
+                {
+                    max = evalResult;
+                }
+                else
+                {
+                    if (ExpressionUtility.compare(evalResult, max) > 0)
+                    {
+                        max = evalResult;
+                    }
+                }
+            }
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return max;
+            
+        }
+        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");
+
+        Iterator expIterator = this._expressions.iterator();
+        TypeInfo currentDataType = new TypeInfo(TypeConstants.INVALID);
+        while (expIterator.hasNext())
+        {
+            Expression exp = (Expression) expIterator.next();
+            TypeInfo type = exp.getType();
+            if (!TypeResolver.isNumeric(type))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return false;
+            }
+            if (currentDataType.getType() == TypeConstants.INVALID)
+            {
+                currentDataType = type;
+            }
+            _dataType = TypeResolver.binaryNumericPromotionResolver(
+                    currentDataType, type);
+            
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return true;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String str = "MAX[ ";
+        Iterator iter = this._expressions.iterator();
+        while(iter.hasNext()) {
+        	str = str + ((Expression)iter.next()).toString() + (iter.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/MaxInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MaxInCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MaxInCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MaxInCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,182 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+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.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class MaxInCollection extends SingleArgumentExpression implements
+        Expression
+{
+    
+    public String className = MaxInCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MaxInCollection";
+    
+    
+    
+//    public boolean isArray()
+//    {
+//        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+//
+//        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+//     
+//        
+//        return _dataType.getIsArray();
+//    }
+    
+    public MaxInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MaxInCollection");
+
+       //System.out.println("MaxInCollection");
+        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());
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "MaxInCollection");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+       //System.out.println("MaxInCollection:evaluate");
+        // int type=this.dataType;
+       //System.out.println("this.exp class " + this.exp.getClass() + " type " + this.exp.getType());
+       // Expression expression = (Expression) this._exp;
+        // Double minNumeric=null;
+        // String minString=null;
+        // DateTime MinInterval=null;
+        Object max = 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;
+       //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 (max == null)
+                {
+                    max = resultObject;
+                }
+                
+                if (ExpressionUtility.compare(max, resultObject) < 0)
+                {
+                   //System.out.println("resultObject " + resultObject+ " is greater than max " + max+ "   so resetting max");
+                    max = resultObject;
+                }
+                else
+                {
+                   //System.out.println("resultObject " + resultObject+ " max not reset" + max);
+                    
+                }
+                
+            }
+           //System.out.println(max);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return max;
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+            throw new SPLException("result Array is empty");
+        }
+        
+    }
+    
+    /*
+     * public int getType() {
+     * 
+     * return this.dataType; }
+     */
+
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("MaxInCollection : 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");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "MaxInCollection("+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/MedianInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MedianInCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MedianInCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MedianInCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,209 @@
+/*
+ * 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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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 MedianInCollection extends SingleArgumentExpression implements
+        Expression
+{
+    
+    public String className = MedianInCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MedianInCollection";
+    
+    
+    
+    public MedianInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MedianInCollection");
+
+       //System.out.println("MedianInCollection");
+        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.copy(this._exp.getType());
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "MedianInCollection");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+       //System.out.println("MedianInCollection:evaluate");
+       //System.out.println("this.exp class " + this.exp.getClass() + " type " + this.exp.getType());
+        
+        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 (count.intValue() < 2)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result of expression is of size less than 2 hence median cannot be calculated");
+            throw new SPLException(
+                    "result of expression is of size less than 2 hence median cannot be calculated");
+        }
+        if ((resultArray != null) && (!resultArray.isEmpty()))
+        {
+            Collections.sort(resultArray);
+            if ((count.intValue() / 2) == (count.floatValue() / 2))
+            {
+               //System.out.println("size of collection is even " + count);
+                int medianElementPosition1 = (count.intValue()) / 2;
+                int medianElementPosition2 = medianElementPosition1 - 1;
+                Object medianElement1 = resultArray.get(medianElementPosition1);
+                Object medianElement2 = resultArray.get(medianElementPosition2);
+                Number sum = ExpressionUtility.plus((Number) medianElement1,
+                        (Number) medianElement2);
+                Number avg = ExpressionUtility.division(sum,
+                        (Number) new Integer(2));
+               //System.out.println("median is " + avg);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return avg;
+                
+            }
+            else if (((count.intValue() / 2) != (count.floatValue() / 2)))
+            {
+               //System.out.println("size of collection is odd " + count);
+                int medianElementPosition = (count.intValue() + 1) / 2;
+                medianElementPosition = medianElementPosition - 1;
+                Object median = resultArray.get(medianElementPosition);
+               //System.out.println("median is " + median);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return median;
+            }
+            
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+            throw new SPLException("result Array is empty");
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        return null;
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("MedianInCollection : 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 = "MedianInCollection("+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/MiddleSubstring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MiddleSubstring.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MiddleSubstring.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MiddleSubstring.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,703 @@
+/*
+ * 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.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.QuadrupleArgumentExpression;
+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 MiddleSubstring extends QuadrupleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = MiddleSubstring.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MiddleSubstring";
+    
+    
+    
+    public MiddleSubstring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MiddleSubstring");
+
+        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()+" "+ "MiddleSubstring");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String o1 = (String) _exp1.evaluate();
+            Object o2 = _exp2.evaluate();
+            Object o3 = _exp3.evaluate();
+            String o4 = (String) _exp4.evaluate();
+            
+            boolean leftToRight;
+            if (o4.equals("LeftToRight"))
+            {
+                leftToRight = true;
+            }
+            else if (o4.equals("RightToLeft"))
+            {
+                leftToRight = false;
+            }
+            else
+            {
+
+                logger.severe(
+                "Illegal direction argument.");
+             
+                throw new IllegalArgumentException(
+                        "Illegal direction argument.");
+            }
+            
+            if (o2 instanceof String)
+            {
+                if (o3 instanceof String)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return _middleSubstring(o1, (String) o2, (String) o3,
+                            leftToRight);
+                }
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return _middleSubstring(o1, (String) o2, ((Number) o3)
+                            .intValue(), leftToRight);
+                }
+            }
+            else
+            {
+                if (o3 instanceof String)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return _middleSubstring(o1, ((Number) o2).intValue(),
+                            (String) o3, leftToRight);
+                }
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return _middleSubstring(o1, ((Number) o2).intValue(),
+                            ((Number) o3).intValue(), leftToRight);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    /**
+     * Returns a specified middleSubstring from a string. With StringExpression,
+     * NumericExpression, NumericExpression, and Direction arguments, the
+     * arguments correspond to String, Offset, NumberChars, Direction. Offset
+     * indicates where you want the middle to begin, counting from left to right
+     * if Direction is LeftToRight, or counting from right to left if Direction
+     * is RightToLeft. For Direction LeftToRight, Offset 0 is just before the
+     * first character, offset 1 is between the first and the second character,
+     * and offset -1 is between the next-to-last and last character. For
+     * Direction RightToLeft, Offset 0 is one position after the last character
+     * (after the null character), Offset 1 is between the last character and
+     * the null character, and Offset -1 is between the second character and the
+     * third character. NumberChars indicates the number of characters that you
+     * want in the middle. If NumberChars is negative, the middle starts at
+     * Offset and continues from right to left. If NumberChars is positive, the
+     * middle starts at Offset and continues from left to right. Examples:
+     * MiddleSubstring(AutonomicComputing, 4,5, LeftToRight)=nomic,
+     * MiddleSubstring(AutonomicComputing, 4,5, RightToLeft)=ing,
+     * MiddleSubstring(AutonomicComputing, 4,-1, LeftToRight)=o,
+     * MiddleSubstring(AutonomicComputing, 8,-1, RightToLeft)=u,
+     * MiddleSubstring(AutonomicComputing, -1,5, LeftToRight)=g,
+     * MiddleSubstring(AutonomicComputing, -1,5, RightToLeft)=tonum,
+     * MiddleSubstring(AutonomicComputing, -1,-1, LeftToRight)=n,
+     * MiddleSubstring(AutonomicComputing, -1,-1, RightToLeft)=u,
+     * MiddleSubstring(AutonomicComputing, 19,5, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, 19,5, RightToLeft)=Auton. Note that
+     * for MiddleSubstring(AutonomicComputing, -1,5, RightToLeft)=tonum, the
+     * offset is -1 corresponding to between &quot;u&quot; and &quot;t&quot;
+     * (there is an anomoly in the way wrapping occurs for RightToLeft). Then 5
+     * characters are taken from left to right starting at the offset.
+     * 
+     * @param string
+     * @param offset
+     * @param numberChars
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _middleSubstring(String string, int offset,
+            int numberChars, boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+     
+        
+        int beginning;
+        int end;
+        int offsetpoint;
+        
+        if (directionLeftToRight)
+        {
+            if (offset < 0)
+            {
+                offsetpoint = string.length() + offset;
+                if (offsetpoint < 0)
+                {
+                    offsetpoint = 0;
+                }
+            }
+            else
+            {
+                offsetpoint = offset;
+            }
+        }
+        else
+        {
+            if (offset < 0)
+            {
+                offsetpoint = 1 - offset;
+            }
+            else
+            {
+                offsetpoint = string.length() - offset + 1;
+                if (offsetpoint < 0)
+                {
+                    offsetpoint = 0;
+                }
+            }
+        }
+        if (numberChars < 0)
+        {
+            beginning = offsetpoint + numberChars;
+            end = offsetpoint;
+        }
+        else
+        {
+            beginning = offsetpoint;
+            end = offsetpoint + numberChars;
+        }
+        
+        if (beginning < 0)
+        {
+            beginning = 0;
+        }
+        if (beginning > string.length())
+        {
+            beginning = string.length();
+        }
+        if (end > string.length())
+        {
+            end = string.length();
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+        if (beginning > end){
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+            return "";
+         
+        }
+           
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+         
+        return string.substring(beginning, end);
+    }
+    
+    /**
+     * Returns a specified middleSubstring from a string. With StringExpression,
+     * StringExpression, NumericExpression, and Direction arguments, the
+     * arguments correspond to String, StartString, NumberChars, Direction.
+     * StartString is a string that indicates where you want the middle to
+     * begin, always taking the first occurrence scanning from left to right if
+     * Direction is LeftToRight, or the first occurrence in of the StartString
+     * string scanning from right to left if Direction is RightToLeft. If
+     * NumberChars is positive, the middle starts with the first character
+     * left-to-right after the end of the StartString and continues for
+     * NumberChars characters. If NumberChars is negative, the middle starts
+     * with the first character to the left of the StartString and continues for
+     * NumberChars characters from right-to-left. If the StartString is not
+     * found, an empty string is returned. Examples:
+     * MiddleSubstring("AutonomicComputing", "om",5, LeftToRight)="icCom",
+     * MiddleSubstring("AutonomicComputing", "om",5, RightToLeft)="putin",
+     * MiddleSubstring("AutonomicComputing", "om",18,
+     * LeftToRight)="icComputing", MiddleSubstring("AutonomicComputing",
+     * "om",18, RightToLeft)="puting", MiddleSubstring("AutonomicComputing",
+     * "om",-1, LeftToRight)="", MiddleSubstring("AutonomicComputing", "om",-1,
+     * RightToLeft)="C", MiddleSubstring("AutonomicComputing", "bz",5,
+     * LeftToRight)="", MiddleSubstring("AutonomicComputing", "bz",5,
+     * RightToLeft)="", MiddleSubstring("AutonomicComputing", "bz",-1,
+     * LeftToRight)="", MiddleSubstring("AutonomicComputing", "bz",-1,
+     * RightToLeft)="", MiddleSubstring("AutonomicComputing", "bz",20,
+     * LeftToRight)="", MiddleSubstring("AutonomicComputing", "bz",20,
+     * RightToLeft)="". <br>
+     * 
+     * @param string
+     * @param startString
+     * @param numberChars
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _middleSubstring(String string, String startString,
+            int numberChars, boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+
+        
+        int beginning;
+        int end;
+        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()+" "+ "middleSubstring");
+                
+                return "";
+            }
+            if (numberChars < 0)
+            {
+                beginning = offsetpoint + numberChars;
+                end = offsetpoint;
+            }
+            else
+            {
+                offsetpoint += startString.length();
+                beginning = offsetpoint;
+                end = offsetpoint + numberChars;
+            }
+        }
+        else
+        {
+            offsetpoint = string.lastIndexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+                
+                return "";
+            }
+            if (numberChars < 0)
+            {
+                beginning = offsetpoint + numberChars;
+                end = offsetpoint;
+            }
+            else
+            {
+                offsetpoint += startString.length();
+                beginning = offsetpoint;
+                end = offsetpoint + numberChars;
+            }
+        }
+        
+        if (beginning < 0)
+        {
+            beginning = 0;
+        }
+        if (beginning > string.length())
+        {
+            beginning = string.length();
+        }
+        if (end > string.length())
+        {
+            end = string.length();
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+        if (beginning > end){
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+            return "";
+
+         
+        }
+          
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+         
+        return string.substring(beginning, end);
+    }
+    
+    /**
+     * Returns a specified middleSubstring from a string. With StringExpression,
+     * NumericExpression, StringExpression, and Direction arguments, the
+     * arguments correspond to String, Offset, EndString, Direction. Offset
+     * indicates where you want the middle to begin, counting from left to right
+     * if Direction is LeftToRight, or counting from right to left if Direction
+     * is RightToLeft. For Direction LeftToRight, Offset 0 is just before the
+     * first character, offset 1 is between the first and the second character,
+     * and offset -1 is between the next-to-last and last character. For
+     * Direction RightToLeft, Offset 0 is one position after the last character
+     * (after the null character), Offset 1 is between the last character and
+     * the null character, and Offset -1 is between the second character and the
+     * third character. EndString indicates the substring of the string that
+     * indicates the end of the middle and is searched in the given Direction
+     * from OffSet. MiddleSubstring returns all the characters between OffSet
+     * and EndString, not including any of the characters in EndString. If
+     * Direction is LeftToRight and EndString does not exist, then all
+     * characters from offset to the end of the string are returned. If
+     * Direction is RightToLeft and EndString is not found, then the empty
+     * string is returned. Examples: MiddleSubstring(AutonomicComputing, 4,om,
+     * LeftToRight)=n, MiddleSubstring(AutonomicComputing, 4,om,
+     * RightToLeft)=put, MiddleSubstring(AutonomicComputing, 7,om,
+     * LeftToRight)=icC, MiddleSubstring(AutonomicComputing, 7,om,
+     * RightToLeft)=, MiddleSubstring(AutonomicComputing, -1,om, LeftToRight)=g,
+     * MiddleSubstring(AutonomicComputing, -1,om, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, -1,bz, LeftToRight)=g,
+     * MiddleSubstring(AutonomicComputing, -1,bz, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, 4,bz, LeftToRight)=nomicComputing,
+     * MiddleSubstring(AutonomicComputing, 4,bz, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, 20,om, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, 20,om, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, 20,bz, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, 20,bz, RightToLeft)=<br> *
+     * 
+     * @param string
+     * @param offset
+     * @param endString
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _middleSubstring(String string, int offset,
+            String endString, boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+
+        
+        int beginning;
+        int end;
+        int offsetpoint;
+        
+        if (directionLeftToRight)
+        {
+            if (offset < 0)
+            {
+                offsetpoint = string.length() + offset;
+                if (offsetpoint < 0)
+                {
+                    offsetpoint = 0;
+                }
+            }
+            else
+            {
+                offsetpoint = offset;
+            }
+            if (offset > string.length()){
+
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+          
+                return "";
+            }
+            beginning = offsetpoint;
+            
+            end = string.indexOf(endString, offsetpoint);
+            if (end < 0)
+            {
+                end = string.length();
+            }
+            
+        }
+        else
+        {
+            if (offset < 0)
+            {
+                offsetpoint = 1 - offset;
+            }
+            else
+            {
+                offsetpoint = string.length() - offset;
+                if (offsetpoint < 0)
+                {
+                    offsetpoint = 0;
+                }
+            }
+            end = offsetpoint;
+            if (end < 0)
+            {
+                end = 0;
+            }
+            
+            int endStringLocation = string.lastIndexOf(endString, end);
+            if (endStringLocation < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+                
+                return "";
+            }
+            else
+            {
+                endStringLocation += endString.length();
+                if (endStringLocation > end)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+                    
+                    return "";
+                }
+                else
+                {
+                    beginning = endStringLocation;
+                }
+            }
+        }
+        
+        if (beginning < 0)
+        {
+            beginning = 0;
+        }
+        if (beginning > string.length())
+        {
+            beginning = string.length();
+        }
+        if (end > string.length())
+        {
+            end = string.length();
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+        if (beginning > end){
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+            return "";
+         
+        }
+           
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+            
+        return string.substring(beginning, end);
+    }
+    
+    /**
+     * Returns a specified middleSubstring from a string. With StringExpression,
+     * StringExpression, StringExpression, and Direction arguments, the
+     * arguments correspond to String, StartString, EndString, Direction.
+     * StartString is a string that indicates where you want the middle to
+     * begin, always taking the first occurrence scanning from left to right if
+     * Direction is LeftToRight, or the first occurrence in of the StartString
+     * string scanning from right to left if Direction is RightToLeft. The
+     * middle begins at the first character after the end of StartString in the
+     * given Direction. EndString indicates the substring of the string that
+     * indicates the end of the middle and is searched in the given Direction
+     * from StartString. MiddleSubstring returns all the characters between
+     * StartString and EndString, not including the StartString or EndString
+     * characters. If StartString is not found, an empty string is returned. If
+     * Direction is LeftToRight and EndString does not exist, then all
+     * characters from offset to the end of the string are returned. If
+     * Direction is RightToLeft and EndString is not found, all characters to
+     * the left of StartString are returned. Examples:
+     * MiddleSubstring(AutonomicComputing, om, om, LeftToRight)=icC,
+     * MiddleSubstring(AutonomicComputing, om, om, RightToLeft)=icC,
+     * MiddleSubstring(AutonomicComputing, bz, om, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, bz, om, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, om, bz, LeftToRight)=icComputing,
+     * MiddleSubstring(AutonomicComputing, om, bz, RightToLeft)=AutonomicC,
+     * MiddleSubstring(AutonomicComputing, bz, bz, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, bz, bz, RightToLeft)=,
+     * MiddleSubstring(AutonomicComputing, om, icC, LeftToRight)=,
+     * MiddleSubstring(AutonomicComputing, om, icC, RightToLeft)=icC.
+     * <p>
+     * 
+     * @param string
+     * @param startString
+     * @param endString
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _middleSubstring(String string, String startString,
+            String endString, boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+
+        
+        int beginning;
+        int end;
+        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()+" "+ "middleSubstring");
+                
+                return "";
+            }
+            offsetpoint += startString.length();
+            beginning = offsetpoint;
+            end = string.indexOf(endString, offsetpoint);
+            if (end < 0)
+            {
+                // did not find endString
+                end = string.length();
+            }
+        }
+        else
+        {
+            offsetpoint = string.lastIndexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the startString
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+                
+                return "";
+            }
+            end = offsetpoint;
+            if (offsetpoint < endString.length())
+            {
+                beginning = 0;
+            }
+            else
+            {
+                beginning = string.lastIndexOf(endString, offsetpoint
+                        - endString.length());
+                if (beginning < 0)
+                {
+                    // Did not find end string
+                    beginning = 0;
+                }
+                else
+                {
+                    beginning += endString.length();
+                }
+            }
+        }
+        
+        if (beginning < 0)
+        {
+            beginning = 0;
+        }
+        if (beginning > string.length())
+        {
+            beginning = string.length();
+        }
+        if (end > string.length())
+        {
+            end = string.length();
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+        if (beginning > end){
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+            return "";
+         
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "middleSubstring");
+           
+        return string.substring(beginning, end);
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType1 = _exp1.getType();
+        TypeInfo eType2 = _exp2.getType();
+        TypeInfo eType3 = _exp3.getType();
+        TypeInfo eType4 = _exp4.getType();
+        
+        if ((TypeResolver.isString(eType1) && TypeResolver.isNumeric(eType2)
+                && TypeResolver.isNumeric(eType3) && TypeResolver
+                .isString(eType4))
+                || (TypeResolver.isString(eType1)
+                        && TypeResolver.isNumeric(eType2)
+                        && TypeResolver.isString(eType3) && TypeResolver
+                        .isString(eType4))
+                || (TypeResolver.isString(eType1)
+                        && TypeResolver.isString(eType2)
+                        && TypeResolver.isNumeric(eType3) && TypeResolver
+                        .isString(eType4))
+                || (TypeResolver.isString(eType1)
+                        && TypeResolver.isString(eType2)
+                        && TypeResolver.isString(eType3) && TypeResolver
+                        .isString(eType4)))
+        {
+            _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 = "MiddleSubstring(" + this._exp1.toString() + ","
+				+ this._exp2.toString() + "," + this._exp3.toString() + ","
+				+ this._exp4.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/Min.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Min.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Min.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Min.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,160 @@
+/*
+ * 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.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.MultipleArgumentExpression;
+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;
+
+
+/**
+ * 
+ * @author Xiping Change Log: 1. 3/9/07: Neeraj Joshi: Changed constructor to
+ *         take a list to facilitate reflection in the expression factory 2.
+ *         3/9/07: Neeraj Joshi: Changed the method in which the return type is
+ *         determined
+ * 
+ */
+public class Min extends MultipleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Min.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Min";
+    
+    
+    
+    public Min(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Min");
+
+        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.");
+            }
+        }
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Min");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Iterator expIterator = this._expressions.iterator();
+            Number min = null;
+            while (expIterator.hasNext())
+            {
+                Expression exp = (Expression) expIterator.next();
+                Number evalResult = (Number) exp.evaluate();
+                
+                if (min == null)
+                {
+                    min = evalResult;
+                }
+                else
+                {
+                    if (ExpressionUtility.compare(evalResult, min) < 0)
+                    {
+                        min = evalResult;
+                    }
+                }
+            }
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return min;
+            
+        }
+        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");
+
+        Iterator expIterator = this._expressions.iterator();
+        TypeInfo currentDataType = new TypeInfo();
+        while (expIterator.hasNext())
+        {
+            Expression exp = (Expression) expIterator.next();
+            TypeInfo type = exp.getType();
+            if (!TypeResolver.isNumeric(type))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return false;
+            }
+            if (currentDataType.getType() == TypeConstants.INVALID)
+            {
+                currentDataType = type;
+            }
+            _dataType = TypeResolver.binaryNumericPromotionResolver(
+                    currentDataType, type);
+            
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return true;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String str = "MIN[ ";
+        Iterator iter = this._expressions.iterator();
+        while(iter.hasNext()) {
+        	str = str + ((Expression)iter.next()).toString() + (iter.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/MinInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MinInCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MinInCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/MinInCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,172 @@
+/*
+ * 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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+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.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class MinInCollection extends SingleArgumentExpression implements
+        Expression
+{
+    
+    public String className = MinInCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="MinInCollection";
+    
+    
+    
+    public MinInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MinInCollection");
+
+       //System.out.println("MinInCollection");
+        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());
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "MinInCollection");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+       //System.out.println("MinInCollection:evaluate");
+        // int type=this.dataType;
+       //System.out.println("this.exp class " + this.exp.getClass() + " type "+ this.exp.getType());
+        //Expression expression = (Expression) this._exp;
+        // Double minNumeric=null;
+        // String minString=null;
+        // DateTime MinInterval=null;
+        Object minimum = 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;
+       //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 (minimum == null)
+                {
+                    minimum = resultObject;
+                }
+                
+                if (ExpressionUtility.compare(minimum, resultObject) > 0)
+                {
+                   //System.out.println("resultObject " + resultObject+ " is lesser than minimum " + minimum+ "   so resetting minimum");
+                    minimum = resultObject;
+                }
+                else
+                {
+                   //System.out.println("resultObject " + resultObject + " minimum not reset" + minimum);
+                    
+                }
+                
+            }
+           //System.out.println(minimum);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return minimum;
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+            throw new SPLException("result Array is empty");
+        }
+        
+    }
+    
+    /*
+     * public int getType() {
+     * 
+     * return this.dataType; }
+     */
+
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("MinInCollection : 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");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="MinInCollection("+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/Mod.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Mod.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Mod.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Mod.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,174 @@
+/*
+ * 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.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 Mod extends DoubleArgumentExpression implements NumericExpression
+{
+    
+    public static final String className = Mod.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Mod";
+    
+    
+    
+    public Mod(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Mod");
+
+        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()+" "+ "Mod");
+        
+    }
+    
+    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");
+         
+            return remainder(lhs, rhs);
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public static Number remainder(Number o1, Number o2) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+
+        Number[] o = new Number[2];
+        o[0] = o1;
+        o[1] = o2;
+        
+        int resolvedType = TypeResolver.resolveType(o);
+        
+        if (resolvedType == TypeConstants.doubleType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Double(o1.doubleValue() % o2.doubleValue());
+        }
+        else if (resolvedType == TypeConstants.floatType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Float(o1.floatValue() % o2.floatValue());
+        }
+        else if (resolvedType == TypeConstants.longType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Long(o1.longValue() % o2.longValue());
+        }
+        else if (resolvedType == TypeConstants.intType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Integer(o1.intValue() % o2.intValue());
+        }
+        else if (resolvedType == TypeConstants.shortType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Short((short) (o1.shortValue() % o2.shortValue()));
+        }
+        else if (resolvedType == TypeConstants.byteType)
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "remainder");
+            
+            return new Byte((byte) (o1.byteValue() % o2.byteValue()));
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Illegal argument type.");
+            
+            throw new SPLException("Illegal argument type.");
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(lType) && TypeResolver.isNumeric(rType))
+        {
+            _dataType = TypeResolver
+                    .binaryNumericPromotionResolver(lType, rType);
+            this._dataType.setIsArray(false);
+            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=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/NotEqual.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/NotEqual.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/NotEqual.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/NotEqual.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,158 @@
+/*
+ * 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.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+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 NotEqual extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = NotEqual.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="NotEqual";
+    
+    
+    
+    public NotEqual(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "NotEqual");
+
+        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()+" "+ "NotEqual");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object lhsValue = _lhsExp.evaluate();
+            Object rhsValue = _rhsExp.evaluate();
+            
+            if (ExpressionUtility.compare(lhsValue, rhsValue) != 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.FALSE;
+            }
+        }
+        catch (Exception e)
+        {
+        	e.printStackTrace();
+            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();
+       //System.out.println("lType "+lType.getType());
+       //System.out.println("rType "+rType.getType());
+        
+        if(!lType.getIsArray() && !rType.getIsArray())
+        {	
+        	//System.out.println("rType and ltype are not arrays");
+            
+	        if (TypeResolver.isTypeAssignableForEquality(lType, rType))
+	        {
+	        	//System.out.println("TypeResolver.isTypeAssignableForEquality true");
+	            
+	            _dataType.setType(TypeConstants.booleanType);
+	            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	            
+	            return true;
+	        }
+	        else 
+	        {
+	        	//System.out.println("TypeResolver.isTypeAssignableForEquality false");
+	            
+	        }
+	        if (TypeResolver.isCalendar(lType) && TypeResolver.isCalendar(rType))
+	        {
+	        	//System.out.println("TypeResolver.isCalendar true");
+	            
+	            _dataType.setType(TypeConstants.booleanType);
+	            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	            
+	            return true;
+	        }
+	        else 
+	        {
+	        	//System.out.println("TypeResolver.isCalendar false");
+	            
+	        }
+        }
+        
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "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;
+    }
+    
+}