incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r606479 [19/30] - in /incubator/imperius/trunk/trunk: ./ modules/ modules/imperius-javaspl/ modules/imperius-javaspl/resources/ modules/imperius-javaspl/resources/samples/ modules/imperius-javaspl/resources/samples/computersystem/ modules/i...
Date Sat, 22 Dec 2007 19:34:03 GMT
Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Substring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Substring.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Substring.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Substring.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,271 @@
+/*
+ * 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.Expression;
+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.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Substring implements StringExpression
+{
+    
+    public static final String className = Substring.class.getName();
+    
+    private Expression _lhsExp;
+    
+    private Expression _midExp;
+    
+    private Expression _rhsExp;
+    
+    private TypeInfo _dataType= new TypeInfo();;
+    
+    private boolean _isArray = false;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Substring";
+    
+    
+    
+    public boolean isArray()
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        return _isArray;
+    }
+    
+    public Substring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Substring");
+
+        if (exprList != null)
+        {
+            if (exprList.size() == 3)
+            {
+                Expression l = (Expression) exprList.get(0);
+                Expression m = (Expression) exprList.get(1);
+                Expression r = (Expression) exprList.get(2);
+                if (l == null)
+                { 
+                    logger.severe(
+                    "left hand side expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "left hand side expression passed in is null.");
+                }
+                
+                if (m == null)
+                { 
+                    logger.severe(
+                    "middle expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "middle expression passed in is null.");
+                }
+                
+                if (r == null)
+                {
+                    logger.severe(
+                "right hand side expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "right hand side expression passed in is null.");
+                }
+                
+                this._lhsExp = l;
+                this._midExp = m;
+                this._rhsExp = r;
+                
+            }
+            else if (exprList.size() == 2)
+            {
+                Expression l = (Expression) exprList.get(0);
+                Expression m = (Expression) exprList.get(1);
+                
+                if (l == null)
+                { 
+                    logger.severe(
+                "left hand side expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "left hand side expression passed in is null.");
+                }
+                
+                if (m == null)
+                { 
+                    logger.severe(
+                    "middle expression passed in is null.");
+                    throw new IllegalArgumentException(
+                            "middle expression passed in is null.");
+                }
+                
+                this._lhsExp = l;
+                this._midExp = m;
+                this._rhsExp = null;
+                
+            }
+            else
+            { 
+                logger.severe(
+                "number of parameters passed is not 3.");
+                throw new IllegalArgumentException(
+                        "number of parameters passed is not 3.");
+            }
+        }
+        else
+        { 
+            logger.severe(Thread.currentThread().getName()+" "+"parameters passed are null.");
+            throw new IllegalArgumentException("parameters passed are null.");
+        }
+        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()+" "+ "Substring");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	String result = "";
+            String o1 = (String) _lhsExp.evaluate();
+            Number o2 = (Number) _midExp.evaluate();
+            if (_rhsExp != null)
+            {
+                Number o3 = (Number) _rhsExp.evaluate();
+                result = o1.substring(((Integer) o2).intValue(), ((Integer) o3)
+                        .intValue());
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+            else
+            {
+            	result = o1.substring(((Integer) o2).intValue());
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo mType = _midExp.getType();
+        
+        _dataType.setType(TypeConstants.stringType);
+        if(!lType.getIsArray() && !mType.getIsArray())
+        {	
+	        if (_rhsExp != null)
+	        {
+	        	TypeInfo rType = _rhsExp.getType();
+	            if (!rType.getIsArray() && TypeResolver.isString(lType) && 
+	            		TypeResolver.isNumeric(mType) && 
+	            		TypeResolver.isNumeric(rType))
+	            {
+	                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	                
+	                return true;
+	            }
+	        }
+	        else
+	        {
+	            if (TypeResolver.isString(lType) && TypeResolver.isNumeric(mType))
+	            {
+	                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+	                
+	                return true;
+	            }
+	        }
+        }    
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public TypeInfo getType() throws SPLException
+    {
+        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 className=this.getClass().getName();
+        
+        String str=className.substring(className.lastIndexOf(".")+1, className.length())+"( ";
+        if(this._lhsExp!=null){
+            str+=this._lhsExp.toString();
+        }
+        if(this._midExp!=null){
+            str+=this._midExp.toString();
+        }
+        if(this._rhsExp!=null){
+            str+=this._rhsExp.toString();
+        }
+        str+=" )";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Subtraction.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Subtraction.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Subtraction.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Subtraction.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,161 @@
+/*
+ * 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.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 Subtraction extends DoubleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Subtraction.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Subtraction";
+    
+    
+    
+    public Subtraction(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Subtraction");
+
+        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()+" "+ "Subtraction");
+        
+    }
+    
+    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 minus(lhs, rhs);
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private static Number minus(Number o1, Number o2) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "minus");
+
+        
+        Number[] o = new Number[2];
+        o[0] = o1;
+        o[1] = o2;
+        
+        int resolvedType = TypeResolver.resolveType(o);
+        
+        if (resolvedType == TypeConstants.doubleType)
+        {
+            double result = o1.doubleValue() - o2.doubleValue();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "minus");
+            
+            return new Double(result);
+        }
+        else if (resolvedType == TypeConstants.floatType)
+        {
+            float result = o1.floatValue() - o2.floatValue();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "minus");
+            
+            return new Float(result);
+        }
+        else if (resolvedType == TypeConstants.longType)
+        {
+            long result = o1.longValue() - o2.longValue();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "minus");
+            
+            return new Long(result);
+        }
+        else
+        {
+            int result = o1.intValue() - o2.intValue();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "minus");
+            
+            return new Integer(result);
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isNumeric(lType) && TypeResolver.isNumeric(rType))
+        {
+            _dataType = TypeResolver
+                    .binaryNumericPromotionResolver(lType, rType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= this._lhsExp.toString() + "-" + this._rhsExp.toString();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Sum.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Sum.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Sum.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Sum.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,195 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Sum extends SingleArgumentExpression implements Expression
+{
+    
+    public String className = Sum.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Sum";
+    
+    
+    
+    public Sum(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Sum");
+
+        //System.out.println("Sum");
+        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(_exp.getType());
+        this._dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Sum");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        //System.out.println("Sum:evaluate");
+        //System.out.println("this.exp class " + this.exp.getClass() + " type "+ this.exp.getType());
+        Object sum = null;
+        Object expResult = this._exp.evaluate();
+        if (!(expResult instanceof java.util.List))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result of expression is not of type List");
+            throw new SPLException(
+                    "result of expression is not of type List");
+        }
+        ArrayList resultArray = (ArrayList) expResult;
+        //System.out.println("resultArray size " + resultArray.size()+ " to string " + resultArray.toString());
+        ////System.out.println("resultArray is of type "+expression.getType());
+        if ((resultArray != null) && (!resultArray.isEmpty()))
+        {
+            Iterator resultIt = resultArray.iterator();
+            while (resultIt.hasNext())
+            {
+                Object resultObject = resultIt.next();
+                //System.out.println("resultObject,class " + resultObject + " " + resultObject.getClass());
+                if (sum == null)
+                {
+                    sum = resultObject;
+                }
+                else
+                {
+                    //System.out.println("Adding resultObject to sum is "+ resultObject + "  " + sum);
+                    sum = ExpressionUtility.plus((Number) sum,
+                            (Number) resultObject);
+                }
+                //System.out.println("current sum is " + sum);
+            }
+            //System.out.println("sum " + sum);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate "+sum);
+            
+            return sum;
+        }
+        else
+        {
+
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+         
+            throw new SPLException("result Array is empty");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        //System.out.println("Sum : 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");
+        	boolean result = TypeResolver.isNumeric(_exp.getType());
+        	return result;
+            /*switch (this._exp.getType())
+            {
+            	TypeResol
+                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 retStr= "SUM("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToBoolean.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToBoolean.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToBoolean.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToBoolean.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,173 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 ToBoolean extends SingleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = ToBoolean.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToBoolean";
+    
+    
+    
+    public ToBoolean(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToBoolean");
+
+        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()+" "+ "ToBoolean");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+           //System.out.println("after evaluation :" + obj.toString());
+            
+            if (_dataType.getType() == TypeConstants.doubleType)
+            {
+                // Necessary because double works differently
+                Double number = (Double) obj;
+                if (number.doubleValue() > 0 || number.doubleValue() < 0)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return new Boolean(true);
+                }
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return new Boolean(false);
+                }
+            }
+            else if (_dataType.getType() == TypeConstants.floatType)
+            {
+                // Necessary because float works differently
+                Float number = (Float) obj;
+                if (number.floatValue() > 0 || number.floatValue() < 0)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return new Boolean(true);
+                }
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return new Boolean(false);
+                }
+            }
+            else if (obj instanceof Number)
+            {
+                if (((Number) obj).longValue() == 0){
+
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    return new Boolean(false);
+                 
+                }
+                 
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return new Boolean(true);
+                }
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return new Boolean((String) obj);
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+       //System.out.println("validating : " + _exp.getType());
+        
+        if (!eType.getIsArray() && 
+        		TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        else
+        {
+           //System.out.println("validation failure: " + _exp.toString() + _exp.getClass());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toBoolean("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToLower.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToLower.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToLower.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToLower.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+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 ToLower extends SingleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = ToLower.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToLower";
+    
+    
+    
+    public ToLower(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToLower");
+
+        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()+" "+ "ToLower");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            String result = (((String) obj).toLowerCase()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        if (TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toLower("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToMilliseconds.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToMilliseconds.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToMilliseconds.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToMilliseconds.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 <prabalig@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.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 ToMilliseconds extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToMilliseconds.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToMilliseconds";
+    
+    
+    
+    public ToMilliseconds(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToMilliseconds");
+
+        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()+" "+ "ToMilliseconds");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        /*
+         * this method returns an integer number corresponding to the day of the
+         * month where the first day of the month has value 1. The parser and
+         * validator should ensure the argument is of type calendar type.
+         */
+        try
+        {
+            Calendar calendar = (Calendar) _exp.evaluate();
+            Number  result = new Long(calendar.getTime().getTime());  
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+        {
+            _dataType.setType(TypeConstants.longType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toMilliseconds("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL32.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL32.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL32.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL32.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 <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ToREAL32 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToREAL32.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToREAL32";
+    
+    
+    
+    public ToREAL32(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToREAL32");
+
+        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()+" "+ "ToREAL32");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            if (obj instanceof Number)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return new Float(((Number) obj).floatValue());
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return new Float((String) obj);
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.floatType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toREAL32("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL64.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL64.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL64.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToREAL64.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,130 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class ToREAL64 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToREAL64.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToREAL64";
+    
+    
+    
+    public ToREAL64(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToREAL64");
+
+        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()+" "+ "ToREAL64");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        try
+        {
+            Object obj = _exp.evaluate();
+            
+            if (obj instanceof Number)
+            {
+            	Number result = new Double(((Number) obj).doubleValue()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                
+                return result; 
+            }
+            else
+            {
+            	Number result = new Double((String) obj);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                
+                // must be string type
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toREAL64("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT16.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT16.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT16.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT16.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 Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ToSINT16 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToSINT16.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToSINT16";
+    
+    
+    
+    public ToSINT16(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToSINT16");
+
+        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()+" "+ "ToSINT16");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            Short result = null;
+            if (obj instanceof Number)
+            {
+            	result = new Short(((Number) obj).shortValue()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result; 
+            }
+            else
+            {
+            	result = new Short((String) obj);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                // must be string type
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.shortType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toSINT16("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT32.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT32.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT32.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT32.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 Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ToSINT32 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToSINT32.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToSINT32";
+    
+    
+    
+    public ToSINT32(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToSINT32");
+
+        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()+" "+ "ToSINT32");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            Integer result = null;
+            if (obj instanceof Number)
+            {
+            	result = new Integer(((Number) obj).intValue()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            {
+            	result = new Integer((String) obj); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                // must be string type
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.intType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toSINT32("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT64.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT64.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT64.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT64.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,126 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ToSINT64 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToSINT64.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToSINT64";
+    
+    
+    
+    public ToSINT64(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToSINT64");
+
+        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()+" "+ "ToSINT64");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            Long result = null;
+            if (obj instanceof Number)
+            {
+            	result = new Long(((Number) obj).longValue()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+            else
+            {
+            	result = new Long((String) obj); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                // must be string type
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.longType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toSINT64("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT8.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT8.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT8.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToSINT8.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 <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ToSINT8 extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = ToSINT8.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToSINT8";
+    
+    
+    
+    public ToSINT8(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToSINT8");
+
+        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()+" "+ "ToSINT8");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            Object obj = _exp.evaluate();
+            Byte result = null;
+            if (obj instanceof Number)
+            {
+            	result = new Byte(((Number) obj).byteValue()); 
+                
+            }
+            else
+            {
+            	result = new Byte((String) obj);
+                
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.byteType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toSINT8("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToString.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToString.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToString.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToString.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,120 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+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 ToString extends SingleArgumentExpression implements
+        StringExpression
+{
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToString";
+    
+    
+    
+    public ToString(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToString");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(
+                "validation error: has wrong data type passed in.");
+                
+                throw new SPLException(
+                        "validation error: has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ToString");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	String result = null;
+            Object obj = _exp.evaluate();
+            if (obj instanceof Number)
+            {
+            	result = (((Number) obj).toString()); 
+                 
+            }
+            else
+            {
+            	result = (((Boolean) obj).toString()); 
+                 
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        if (TypeResolver.isNumeric(eType) || TypeResolver.isBoolean(eType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toString("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToUpper.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToUpper.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToUpper.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ToUpper.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+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 ToUpper extends SingleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = ToUpper.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ToUpper";
+    
+    
+    
+    public ToUpper(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ToUpper");
+
+        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()+" "+ "ToUpper");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+   
+        try
+        {
+            Object obj = _exp.evaluate();
+            String result = (((String) obj).toUpperCase()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        if (TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "toUpper("+this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/UnaryMinusExpression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/UnaryMinusExpression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/UnaryMinusExpression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/UnaryMinusExpression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,130 @@
+/*
+ * 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 <jneeraj@us.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class UnaryMinusExpression extends SingleArgumentExpression implements
+        NumericExpression
+{
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="UnaryMinusExpression";
+    
+    
+    
+    public UnaryMinusExpression(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "UnaryMinusExpression");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(
+                "validation error: wrong data type passed in.");
+                
+                throw new SPLException(
+                        "validation error: wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "UnaryMinusExpression");
+        
+    }
+    
+    // @Override
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        // TODO Auto-generated method stub
+        Object n = _exp.evaluate();
+        Number result = null;
+        if (_dataType.getType() == TypeConstants.longType)
+        {
+            long s = ((Long) n).shortValue();
+            result = new Long(-s);
+
+           
+        }
+        else if (_dataType.getType() == TypeConstants.floatType)
+        {
+            float f = ((Float) n).floatValue();
+            result = new Float(-f);
+            
+        }
+        else if (_dataType.getType() == TypeConstants.doubleType)
+        {
+            double f = ((Double) n).doubleValue();
+            result = new Double(-f);
+          
+        }
+        else
+        {
+            int i = ((Integer) n).intValue();
+            result = new Integer(-i);
+          
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+        
+        return result;
+        
+        // n = 0 - n;
+        // return null;
+    }
+    
+    // @Override
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        if (TypeResolver.isNumeric(_exp.getType()))
+        {
+            _dataType.copy(_exp.getType());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        // TODO Auto-generated method stub
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= this._exp.toString() + "(...--...)";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}



Mime
View raw message