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 [16/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/GreaterOrEqual.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/GreaterOrEqual.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/GreaterOrEqual.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/GreaterOrEqual.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,146 @@
+/*
+ * 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 GreaterOrEqual extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = GreaterOrEqual.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="GreaterOrEqual";
+    
+    
+    
+    public GreaterOrEqual(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GreaterOrEqual");
+
+        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()+" "+ "GreaterOrEqual");
+        
+    }
+    
+    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)
+        {
+            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");
+        boolean validated = false;
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !rType.getIsArray() && 
+        		TypeResolver.isTypeAssignableForRelation(lType, rType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            validated = true;
+        }
+        if (!lType.getIsArray() && !rType.getIsArray() && 
+        		(TypeResolver.isCalendar(lType)) && 
+        		(TypeResolver.isCalendar(rType)))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            validated = true;
+        }
+        
+        if(!validated)
+        {
+        	throw new SPLException("Invalid input types " + lType + rType + " for greaterorequal");
+        }
+        
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return validated;
+    }
+    
+    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/InCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/InCollection.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/InCollection.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/InCollection.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,212 @@
+/*
+ * 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.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.IllegalParameterTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class InCollection extends DoubleArgumentExpression implements
+        Expression
+{
+    
+    public String className = InCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="InCollection";
+    
+    
+    
+    public InCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "InCollection");
+
+        this._dataType.setType(TypeConstants.booleanType);
+        this._dataType.setIsArray(false);
+       //System.out.println("InCollection");
+        if (evaluateExpression)
+        {
+           //System.out.println("evaluateExpression " + evaluateExpression);
+            if (!validate())
+            {
+
+                logger.severe(
+                        "validation error: wrong data type passed in "
+                        + this._dataType);
+             
+                throw new SPLException(
+                        "validation error: wrong data type passed in "
+                                + this._dataType);
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "InCollection");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+     
+       //System.out.println("InCollection:evaluate");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        if (rhsExpression.isArray())
+        {
+           //System.out.println("rhs is of type Basic Collection");
+            Object rhsResult = rhsExpression.evaluate();
+           //System.out.println("rhsResult , class " + rhsResult + " "+ rhsResult.getClass());
+            if (!(rhsResult instanceof java.util.List))
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"rhsResult is not of type List");
+                throw new SPLException("rhsResult is not of type List");
+            }
+            // BasicCollectionExpression
+            // expression=(BasicCollectionExpression)rhsExpression;
+            Boolean result = Boolean.FALSE;
+            ArrayList rhsResultArray = (ArrayList) rhsResult;
+           //System.out.println("resultArray size " + rhsResultArray.size()+ " to string " + rhsResultArray.toString());
+            ////System.out.println("resultArray is of type
+            // "+expression.getType());
+           //System.out.println("LHS expression is of type "+ lhsExpression.getType());
+            if ((rhsResultArray != null) && (!rhsResultArray.isEmpty()))
+            {
+                Object lhsResult = (Object) lhsExpression.evaluate();
+                // String lhsResultString=lhsResult.toString();
+               //System.out.println("lhsResult " + lhsResult.toString());
+                Iterator rhsResultIt = rhsResultArray.iterator();
+                while (rhsResultIt.hasNext())
+                {
+                    Object value = (Object) rhsResultIt.next();
+                    // String valueString=value.toString();
+                   //System.out.println("rhsResult element " + value.toString());
+                    if (ExpressionUtility.compare(lhsResult, value) == 0)
+                    {
+                       //System.out.println("InCollection:true");
+                        result = Boolean.TRUE;
+                        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                        
+                        return result;
+                    }
+                    
+                    /*
+                     *System.out.println("rhs Array value "+value.toString());
+                     * if(valueString.compareTo(lhsResultString)==0){
+                     *System.out.println("InCollection:true");
+                     * result=Boolean.TRUE; return result; }
+                     */
+                   //System.out.println("did not match");
+                }
+               //System.out.println("no matches: Lhs not inCollection");
+                result = Boolean.FALSE;
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            { 
+                logger.severe(
+                "the RHS of InCollection expression is null BasicCollection");
+                throw new IllegalParameterTypeException(
+                        "the RHS of InCollection expression is null BasicCollection");
+            }
+        }
+        else
+        {
+            logger.severe(
+            "the RHS of InCollection expression should be of BasicCollection type");
+            
+            throw new IllegalParameterTypeException(
+                    "the RHS of InCollection expression should be of BasicCollection type");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("InCollection : validate ");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        
+        if (rhsExpression.isArray())
+        {
+            if (lhsExpression.getType().getType() != rhsExpression.getType().getType())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                throw new SPLException(
+                        "lhsExpression.getType()!=rhsExpression.getType()");
+            }
+           //System.out.println("rhs is of type BasicCollection ,class=" + rhsExpression.getClass() + "   "+ rhsExpression.toString());
+            /*
+             * BasicCollectionExpression
+             * rhsBasicCollectionExpression=(BasicCollectionExpression)rhsExpression;
+             * System.out.println("lhs Type() : rhsBasicCollection
+             * CollectionType() "+lhsExpression.getType() +" :
+             * "+rhsBasicCollectionExpression.getCollectionType());
+             * if(lhsExpression.getType()
+             * !=rhsBasicCollectionExpression.getCollectionType()){
+             * System.out.println("Validation:false "); return false; } else{
+             * System.out.println("validation: true lhs:rhs
+             * "+lhsExpression.getType()+":"+rhsBasicCollectionExpression.getCollectionType());
+             * 
+             * return true; }
+             */
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        else
+        {
+           //System.out.println("RHS of InCollection is not of type Basic Collection, returning false(Validation)");
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            return false;
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "InCollection("+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/IntegerConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IntegerConstant.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IntegerConstant.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IntegerConstant.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,102 @@
+/*
+ * 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 IntegerConstant extends ConstantExpression implements
+        NumericExpression
+{
+    
+    private int integerValue;
+    
+    public TypeInfo _dataType = new TypeInfo(TypeConstants.intType);
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="IntegerConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        
+        return _dataType.getIsArray();
+    }
+    
+    public IntegerConstant(int val)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "IntegerConstant");
+       
+        this.integerValue = val;
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "IntegerConstant");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Integer(integerValue);
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation errro: " + e.toString());
+            
+            throw new SPLException("evaluation errro: " + 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=Integer.toString(this.integerValue);
+        
+        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/IsAfter.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsAfter.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsAfter.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsAfter.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,121 @@
+/*
+ * 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.Calendar;
+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.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class IsAfter extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = IsAfter.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="IsAfter";
+    
+    
+    
+    public IsAfter(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "IsAfter");
+
+        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()+" "+ "IsAfter");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Calendar o1 = (Calendar) _lhsExp.evaluate();
+            Calendar o2 = (Calendar) _rhsExp.evaluate();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Boolean(o1.after(o2));
+        }
+        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.isCalendar(lType) && TypeResolver.isCalendar(rType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        else
+        {
+        	throw new SPLException("Invalid input types " + lType + rType + "for isAfter");
+        }
+
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "isAfter("+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/IsBefore.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsBefore.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsBefore.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsBefore.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,121 @@
+/*
+ * 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.Calendar;
+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.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class IsBefore extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = IsBefore.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="IsBefore";
+    
+    
+    
+    public IsBefore(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "IsBefore");
+
+        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()+" "+ "IsBefore");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Calendar o1 = (Calendar) _lhsExp.evaluate();
+            Calendar o2 = (Calendar) _rhsExp.evaluate();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Boolean(o1.before(o2));
+        }
+        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.isCalendar(lType) && TypeResolver.isCalendar(rType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        else
+        {
+        	throw new SPLException("Invalid input types " + lType + rType + "for isbefore");
+        }
+
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "isBefore("+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/IsWithin.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsWithin.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsWithin.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/IsWithin.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.Calendar;
+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.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 IsWithin extends TripleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = IsWithin.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="IsWithin";
+    
+    
+    
+    public IsWithin(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "IsWithin");
+
+        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()+" "+ "IsWithin");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Boolean(_isWithin((Calendar) _lhsExp.evaluate(),
+                    (Calendar) _midExp.evaluate(), (Calendar) _rhsExp.evaluate()));
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private boolean _isWithin(Calendar date, Calendar startDate, Calendar endDate)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isWithin");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isWithin");
+     
+        return !(date.before(startDate) || date.after(endDate));
+    }
+    
+    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.isCalendar(lType) && TypeResolver.isCalendar(mType)
+                && TypeResolver.isCalendar(rType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        else
+        {
+        	throw new SPLException("Invalid input types " + lType + rType + mType + "for isWithin");
+        }
+
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "isWithin("+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/LeftSubstring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LeftSubstring.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LeftSubstring.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LeftSubstring.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,274 @@
+/*
+ * 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.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 LeftSubstring extends TripleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = LeftSubstring.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LeftSubstring";
+    
+    
+    
+    public LeftSubstring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LeftSubstring");
+
+        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()+" "+ "LeftSubstring");
+        
+    }
+    
+    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)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                String sub = _leftSubstring(o1, (String) o2, leftToRight); 
+                return sub;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                String sub = _leftSubstring(o1, ((Number) o2).intValue(), leftToRight); 
+                return sub;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    /**
+     * Returns a specified LeftSubstring from a string. If
+     * directionLeftToRight=true, numberChars is the number of characters to
+     * return starting from the left. If the number is 2, the first two
+     * characters of the string are returned; if the number is 5, the first five
+     * characters are returned, and so on. If the number is negative, the entire
+     * string is returned. If instead the directionLeftToRight=false,
+     * numberChars is the number of characters to skip counting from right to
+     * left. All the characters to the left of that number of characters are
+     * returned. If the number is negative, the empty string is returned.<br>
+     * Examples: LeftSubstring("AutonomicComputing", 4, LeftToRight) = "Auto".
+     * LeftSubstring("AutonomicComputing", 4, RightToLeft) = "AutonomicCompu".
+     * 
+     * @param string
+     * @param numberChars
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _leftSubstring(String string, int numberChars,
+            boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+
+        
+        if (directionLeftToRight)
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return string;
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return string;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return string.substring(0, numberChars);
+            }
+        }
+        else
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return "";
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return string;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return string.substring(0, string.length() - numberChars);
+            }
+        }
+    }
+    
+    /**
+     * Returns a specified LeftSubstring from a string. LeftSubstring returns
+     * the characters from the String the left of the startString, not including
+     * the startString characters. If directionLeftToRight=true, then it finds
+     * startString by searching the String from left to right. If
+     * directionLeftToRight=false, then it finds StartString by searching the
+     * String from right to left. If the StartString is not found in the String,
+     * then an empty string is returned.<br>
+     * Examples: LeftSubstring("AutonomicComputing", "om", LeftToRight)="Auton"
+     * LeftSubstring("AutonomicComputing", "om", RightToLeft)="AutonomicC"
+     * 
+     * @param string
+     * @param startString
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _leftSubstring(String string, String startString,
+            boolean directionLeftToRight)
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+
+        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()+" "+ "leftSubstring");
+                
+                return "";
+            }
+        }
+        else
+        {
+            offsetpoint = string.lastIndexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+                
+                return "";
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "leftSubstring");
+        
+        return string.substring(0, offsetpoint);
+    }
+    
+    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;
+        }
+        else
+        {
+        	throw new SPLException("Invalid input types " + lType + rType + mType + "for leftsubstring");
+        }
+
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "LeftSubstring("+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/Less.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Less.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Less.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Less.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,143 @@
+/*
+ * 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 Less extends DoubleArgumentExpression implements BooleanExpression
+{
+    
+    public static final String className = Less.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="DoubleArgumentExpression";
+    
+    
+    
+    public Less(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Less");
+
+        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()+" "+ "Less");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+           //System.out.println("Less::LHS type: RHS type ::" + lhsExp.getType()+ ":" + rhsExp.getType());
+            Object lhsValue = _lhsExp.evaluate();
+            Object rhsValue = _rhsExp.evaluate();
+           //System.out.println("Less::after Evaluation LHS: RHS ::" + lhsValue+ ":" + rhsValue);
+            
+            if (ExpressionUtility.compare(lhsValue, rhsValue) < 0)
+            {
+               //System.out.println("Less::True");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+            else
+            {
+               //System.out.println("Less::False");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.FALSE;
+            }
+        }
+        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();
+       //System.out.println("Less:validate:TypeResolver.isNumeric(lType)"+ TypeResolver.isNumeric(lType));
+       //System.out.println("Less:validate:TypeResolver.isNumeric(rType)"+ TypeResolver.isNumeric(rType));
+        if(!lType.getIsArray() && !rType.getIsArray())
+        {	
+	        if (TypeResolver.isTypeAssignableForRelation(lType, rType))
+	        {
+	            _dataType.setType(TypeConstants.booleanType);
+	            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	            
+	            return true;
+	        }
+	        if ((TypeResolver.isCalendar(lType))
+	                && (TypeResolver.isCalendar(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 = 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/LessOrEqual.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,138 @@
+/*
+ * 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 LessOrEqual extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = LessOrEqual.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LessOrEqual";
+    
+    
+    
+    public LessOrEqual(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LessOrEqual");
+
+        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()+" "+ "LessOrEqual");
+        
+    }
+    
+    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)
+        {
+            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:rType " + lType + " " + rType);
+        if(!lType.getIsArray() && !rType.getIsArray())
+        {	
+	        if (TypeResolver.isTypeAssignableForRelation(lType, rType))
+	        {
+	            _dataType.setType(TypeConstants.booleanType);
+	            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	            
+	            return true;
+	        }
+	        if ((TypeResolver.isCalendar(lType))
+	                && (TypeResolver.isCalendar(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 = 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/Ln.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Ln.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Ln.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Ln.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,121 @@
+/*
+ * 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 Ln extends SingleArgumentExpression implements NumericExpression
+{
+    
+    public static final String className = Ln.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Ln";
+    
+    
+    
+    public Ln(List exprList, boolean validateExpression) throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return log((Number) _exp.evaluate());
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public static Number log(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
+     
+        return new Double(Math.log(o.doubleValue()));
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        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 = "Ln("+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/Log10.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Log10.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Log10.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Log10.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
+ * @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 Log10 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Log10.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Log10";
+    
+    
+    
+    public Log10(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Log10");
+
+        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()+" "+ "Log10");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return log((Number) _exp.evaluate());
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public static Number log(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
+     
+        return new Double(Math.log(o.doubleValue()) / Math.log(10));
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        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 = "Log10(" + 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/LogicalAnd.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,118 @@
+/*
+ * 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.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalAnd extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = LogicalAnd.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LogicalAnd";
+    
+    
+    
+    public LogicalAnd(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalAnd");
+
+        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()+" "+ "LogicalAnd");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+            boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return new Boolean(left && right);
+        }
+        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.isBoolean(lType) && TypeResolver.isBoolean(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 = 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/LogicalNot.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,127 @@
+/*
+ * 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.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 LogicalNot extends SingleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = LogicalNot.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LogicalNot";
+    
+    
+    
+    public LogicalNot(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalNot");
+
+        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()+" "+ "LogicalNot");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            if (((Boolean) _exp.evaluate()).booleanValue()){
+
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                return Boolean.FALSE;
+             
+            }
+                
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+        }
+        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");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        TypeInfo eType = _exp.getType();
+        
+        if (!eType.getIsArray() && TypeResolver.isBoolean(eType))
+        {
+            _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 = "LogicalNot("+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/LogicalOr.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.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 Prashant Baliga <pr...@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.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 LogicalOr extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = LogicalOr.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LogicalOr";
+    
+    
+    
+    public LogicalOr(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
+     
+        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()+" "+ "LogicalOr");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+           //System.out.println("Logical OR::LHS type: RHS type ::"+ lhsExp.getType() + ":" + rhsExp.getType());
+            boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+            boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+           //System.out.println("Logical OR::after Evaluation LHS: RHS ::"+ left + ":" + right);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Boolean(left || right);
+        }
+        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();
+       //System.out.println("Logical OR:validate:TypeResolver.isBoolean(lType)"+ TypeResolver.isBoolean(lType));
+       //System.out.println("Logical OR:validate:TypeResolver.isBoolean(rType)"+ TypeResolver.isBoolean(rType));
+        
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(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 = 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/LogicalXor.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.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 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.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalXor extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = LogicalXor.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="LogicalXor";
+    
+    
+    
+    public LogicalXor(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalXor");
+
+        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()+" "+ "LogicalXor");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+            boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+            boolean result = false;
+            if ((left && !right) || (!left && right))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                result = true;
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return new Boolean(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 lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(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 = "LogicalXor("+this._lhsExp.toString() + "," + this._rhsExp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+}