incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r611261 [25/43] - in /incubator/imperius/trunk: ./ imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/ imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/ imperius-splcore/src...
Date Fri, 11 Jan 2008 18:57:14 GMT
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/RightSubstring.java Fri Jan 11 10:56:30 2008
@@ -1,307 +1,307 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.StringExpression;
-import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class RightSubstring extends TripleArgumentExpression implements
-        StringExpression
-{
-    
-    public static final String className = RightSubstring.class.getName();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="RightSubstring";
-    
-    
-    
-    public RightSubstring(List exprList, boolean validateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
-
-        if (validateExpression)
-        {
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
-                        + " has wrong data type passed in.");
-                
-                throw new SPLException("validation error: " + className
-                        + " has wrong data type passed in.");
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        try
-        {
-            String o1 = (String) _lhsExp.evaluate();
-            Object o2 = _midExp.evaluate();
-            String o3 = (String) _rhsExp.evaluate();
-            
-            boolean leftToRight;
-            if (o3.equals("LeftToRight"))
-            {
-                leftToRight = true;
-            }
-            else if (o3.equals("RightToLeft"))
-            {
-                leftToRight = false;
-            }
-            else
-            {
-                logger.severe(
-                "Illegal direction argument.");
-                throw new IllegalArgumentException(
-                        "Illegal direction argument.");
-            }
-            if (o2 instanceof String)
-            {
-            	String result = _rightSubstring(o1, (String) o2, leftToRight); 
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
-                
-                return result;
-            }
-            else
-            {
-            	String result = _rightSubstring(o1, ((Number) o2).intValue(), leftToRight);
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
-                
-                return result;
-            }
-        }
-        catch (Exception e)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + toString());
-            
-            throw new SPLException("evaluation error: " + toString());
-        }
-    }
-    
-    /**
-     * Returns a <code>String</code> representation of this
-     * <code>Expression</code> in a format
-     * <code>[ RightSubstring (Expression1)  (Expression2)  (Expression3) (LeftToRight | RightToLeft) ]</code>.
-     * <p>
-     * 
-     * @return a String representation of this <code>Expression</code>
-     * @see java.lang.Object#toString()
-     */
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-     
-       // return " RightSubstring (" + super.toString() + " ) ";
-        return " RightSubstring (" + _lhsExp.toString() + "," 
-        	+ _midExp.toString() + "," + _rhsExp.toString() + " ) ";
-    }
-    
-    /**
-     * Returns a specified RightSubstring from a string. If directionLeftToRight
-     * is true, numberChars is the number of characters to return from the end
-     * of the string. If the number is 2, the last two characters of the string
-     * are returned; if the number is 5, the last five characters are returned,
-     * and so on. If the number is negative, the entire string is returned. If
-     * instead directionLeftToRight is false, numberChars counting from left to
-     * right is the number of characters to skip. All the characters to the
-     * right of that number are returned. If the number is negative, the empty
-     * string is returned.<br>
-     * Examples: RightSubstring("AutonomicComputing", 4, LeftToRight) = "ting".
-     * RightSubstring("AutonomicComputing", 4, RightToLeft) = "nomicComputing".
-     * <p>
-     * 
-     * @param string
-     * @param numberChars
-     * @param directionLeftToRight
-     * 
-     * @return the resulting substring
-     */
-    private String _rightSubstring(String string, int numberChars,
-            boolean directionLeftToRight)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-
-        
-        if (directionLeftToRight)
-        {
-            if (numberChars < 0)
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return string;
-            }
-            else if (numberChars > string.length())
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return string;
-            }
-            else
-            {
-            	String result = string.substring(string.length() - numberChars, string
-                        .length()); 
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
-                
-                return result; 
-            }
-        }
-        else
-        {
-            if (numberChars < 0)
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return "";
-            }
-            else if (numberChars > string.length())
-            {
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return "";
-            }
-            else
-            {
-                
-                String result = string.substring(numberChars, string.length());
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
-                return result;
-            }
-        }
-    }
-    
-    /**
-     * Returns a specified RightSubstring from a string. RightSubstring returns
-     * the characters from the String to the right of the startString, not
-     * including the startString characters. If directionLeftToRight is true,
-     * then it finds StartString by searching the string from left to right. If
-     * directionLeftToRight is false, then it finds startString by searching the
-     * String from right to left. In either case, if the StartString is not
-     * found in the String, then the empty string is returned. <br>
-     * 
-     * Examples: RightSubstring("AutonomicComputing", "om",
-     * LeftToRight)="icComputing" RightSubstring("AutonomicComputing", "om",
-     * RightToLeft)="puting".
-     * <p>
-     * 
-     * @param string
-     * @param startString
-     * @param directionLeftToRight
-     * 
-     * @return the resulting substring
-     */
-    private String _rightSubstring(String string, String startString,
-            boolean directionLeftToRight)
-    {
-
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-
-        int offsetpoint; // Position of the beginning of the startString
-        
-        if (directionLeftToRight)
-        {
-            offsetpoint = string.indexOf(startString);
-            if (offsetpoint < 0)
-            {
-                // Did not find the string
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return "";
-            }
-            else
-            {
-                // found string
-                offsetpoint += startString.length();
-            }
-        }
-        else
-        {
-            offsetpoint = string.lastIndexOf(startString);
-            if (offsetpoint < 0)
-            {
-                // Did not find the string
-                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-                
-                return "";
-            }
-            else
-            {
-                offsetpoint += startString.length();
-            }
-        }
-        if (offsetpoint > string.length())
-        {
-            // no characters after string
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
-            
-            return "";
-        }
-        else
-        {
-        	String result = string.substring(offsetpoint, string.length()); 
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
-            
-            return result;
-        }
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo lType = _lhsExp.getType();
-        TypeInfo mType = _midExp.getType();
-        TypeInfo rType = _rhsExp.getType();
-        
-        if (!lType.getIsArray() && !mType.getIsArray() && !rType.getIsArray() &&
-        		TypeResolver.isString(lType)
-                && (TypeResolver.isString(mType) || TypeResolver
-                        .isNumeric(mType)) && TypeResolver.isString(rType))
-        {
-            _dataType.setType(TypeConstants.stringType);
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return true;
-        }
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-     
-        return false;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.StringExpression;
+import org.apache.imperius.spl.parser.expressions.TripleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class RightSubstring extends TripleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = RightSubstring.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="RightSubstring";
+    
+    
+    
+    public RightSubstring(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "RightSubstring");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String o1 = (String) _lhsExp.evaluate();
+            Object o2 = _midExp.evaluate();
+            String o3 = (String) _rhsExp.evaluate();
+            
+            boolean leftToRight;
+            if (o3.equals("LeftToRight"))
+            {
+                leftToRight = true;
+            }
+            else if (o3.equals("RightToLeft"))
+            {
+                leftToRight = false;
+            }
+            else
+            {
+                logger.severe(
+                "Illegal direction argument.");
+                throw new IllegalArgumentException(
+                        "Illegal direction argument.");
+            }
+            if (o2 instanceof String)
+            {
+            	String result = _rightSubstring(o1, (String) o2, leftToRight); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+            else
+            {
+            	String result = _rightSubstring(o1, ((Number) o2).intValue(), leftToRight);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+                
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + toString());
+            
+            throw new SPLException("evaluation error: " + toString());
+        }
+    }
+    
+    /**
+     * Returns a <code>String</code> representation of this
+     * <code>Expression</code> in a format
+     * <code>[ RightSubstring (Expression1)  (Expression2)  (Expression3) (LeftToRight | RightToLeft) ]</code>.
+     * <p>
+     * 
+     * @return a String representation of this <code>Expression</code>
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+     
+       // return " RightSubstring (" + super.toString() + " ) ";
+        return " RightSubstring (" + _lhsExp.toString() + "," 
+        	+ _midExp.toString() + "," + _rhsExp.toString() + " ) ";
+    }
+    
+    /**
+     * Returns a specified RightSubstring from a string. If directionLeftToRight
+     * is true, numberChars is the number of characters to return from the end
+     * of the string. If the number is 2, the last two characters of the string
+     * are returned; if the number is 5, the last five characters are returned,
+     * and so on. If the number is negative, the entire string is returned. If
+     * instead directionLeftToRight is false, numberChars counting from left to
+     * right is the number of characters to skip. All the characters to the
+     * right of that number are returned. If the number is negative, the empty
+     * string is returned.<br>
+     * Examples: RightSubstring("AutonomicComputing", 4, LeftToRight) = "ting".
+     * RightSubstring("AutonomicComputing", 4, RightToLeft) = "nomicComputing".
+     * <p>
+     * 
+     * @param string
+     * @param numberChars
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _rightSubstring(String string, int numberChars,
+            boolean directionLeftToRight)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+
+        
+        if (directionLeftToRight)
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return string;
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return string;
+            }
+            else
+            {
+            	String result = string.substring(string.length() - numberChars, string
+                        .length()); 
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+                
+                return result; 
+            }
+        }
+        else
+        {
+            if (numberChars < 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else if (numberChars > string.length())
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                
+                String result = string.substring(numberChars, string.length());
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+                return result;
+            }
+        }
+    }
+    
+    /**
+     * Returns a specified RightSubstring from a string. RightSubstring returns
+     * the characters from the String to the right of the startString, not
+     * including the startString characters. If directionLeftToRight is true,
+     * then it finds StartString by searching the string from left to right. If
+     * directionLeftToRight is false, then it finds startString by searching the
+     * String from right to left. In either case, if the StartString is not
+     * found in the String, then the empty string is returned. <br>
+     * 
+     * Examples: RightSubstring("AutonomicComputing", "om",
+     * LeftToRight)="icComputing" RightSubstring("AutonomicComputing", "om",
+     * RightToLeft)="puting".
+     * <p>
+     * 
+     * @param string
+     * @param startString
+     * @param directionLeftToRight
+     * 
+     * @return the resulting substring
+     */
+    private String _rightSubstring(String string, String startString,
+            boolean directionLeftToRight)
+    {
+
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+
+        int offsetpoint; // Position of the beginning of the startString
+        
+        if (directionLeftToRight)
+        {
+            offsetpoint = string.indexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                // found string
+                offsetpoint += startString.length();
+            }
+        }
+        else
+        {
+            offsetpoint = string.lastIndexOf(startString);
+            if (offsetpoint < 0)
+            {
+                // Did not find the string
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+                
+                return "";
+            }
+            else
+            {
+                offsetpoint += startString.length();
+            }
+        }
+        if (offsetpoint > string.length())
+        {
+            // no characters after string
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring");
+            
+            return "";
+        }
+        else
+        {
+        	String result = string.substring(offsetpoint, string.length()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rightSubstring" + result);
+            
+            return result;
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo mType = _midExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !mType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isString(lType)
+                && (TypeResolver.isString(mType) || TypeResolver
+                        .isNumeric(mType)) && TypeResolver.isString(rType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Rint.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Rint.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Rint.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Rint.java Fri Jan 11 10:56:30 2008
@@ -1,124 +1,124 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class Rint extends SingleArgumentExpression implements NumericExpression
-{
-    
-    public static final String className = Rint.class.getName();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="Rint";
-    
-    
-    
-    public Rint(List exprList, boolean validateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
-
-        if (validateExpression)
-        {
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
-                        + " has wrong data type passed in.");
-                
-                throw new SPLException("validation error: " + className
-                        + " has wrong data type passed in.");
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        try
-        {
-            
-            Number result = _rint((Number) _exp.evaluate());
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
-            return result;
-        }
-        catch (Exception e)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-            
-            throw new SPLException("evaluation error: " + e.toString());
-        }
-    }
-    
-    private Number _rint(Number o)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rint");
-        Number result = new Double(Math.rint(o.doubleValue()));
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rint" + result);
-     
-        return result;
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo eType = _exp.getType();
-        
-        // dataType = TypeConstants.numericType;
-        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
-        {
-            _dataType.setType(TypeConstants.doubleType);
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return true;
-        }
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-     
-        return false;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        
-        String str="RINT("+this._exp.toString()+")";
-        
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Rint extends SingleArgumentExpression implements NumericExpression
+{
+    
+    public static final String className = Rint.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Rint";
+    
+    
+    
+    public Rint(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Rint");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            
+            Number result = _rint((Number) _exp.evaluate());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _rint(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "rint");
+        Number result = new Double(Math.rint(o.doubleValue()));
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "rint" + result);
+     
+        return result;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="RINT("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Round.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Round.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Round.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Round.java Fri Jan 11 10:56:30 2008
@@ -1,164 +1,164 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- * @modified Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.IllegalExpressionTypeException;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class Round extends SingleArgumentExpression implements
-        NumericExpression
-{
-    
-    public static final String className = Round.class.getName();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="Round";
-    
-    
-    
-    public Round(List exprList, boolean validateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Round");
-
-        if (validateExpression)
-        {
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
-                        + " has wrong data type passed in.");
-                
-                throw new SPLException("validation error: " + className
-                        + " has wrong data type passed in.");
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Round");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        try
-        {
-        	Number result = _round((Number) _exp.evaluate()); 
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-            
-            return result;
-        }
-        catch (Exception e)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-            
-            throw new SPLException("evaluation error: " + e.toString());
-        }
-    }
-    
-    private Number _round(Number o1) throws IllegalExpressionTypeException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "round");
-
-        Number[] o = new Number[1];
-        o[0] = o1;
-        
-        int resolvedType = TypeResolver.resolveType(o);
-        
-        if (resolvedType == TypeConstants.doubleType)
-        {
-            long roundVal = Math.round(o1.doubleValue());
-            
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
-            
-            return new Long(roundVal);
-        }
-        else if (resolvedType == TypeConstants.floatType)
-        {
-            int roundVal = Math.round(o1.floatValue());
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
-            
-            return new Integer(roundVal);
-        }
-        else
-        {
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
-            
-            return new Integer(o1.intValue());
-        }
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo eType = _exp.getType();
-        
-        // dataType = TypeConstants.numericType;
-        if (TypeResolver.isNumeric(eType))
-        {
-            int tp = eType.getType();
-            if (tp == TypeConstants.doubleType)
-            {
-                _dataType.setType(TypeConstants.longType);
-                
-            }
-            else if (tp == TypeConstants.floatType)
-            {
-                _dataType.setType(TypeConstants.intType);
-                
-            }
-            else
-            {
-                _dataType.setType(TypeConstants.intType);
-            }
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return true;
-        }
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-     
-        return false;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        
-        String str="ROUND("+this._exp.toString()+")";
-        
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.IllegalExpressionTypeException;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Round extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = Round.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Round";
+    
+    
+    
+    public Round(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Round");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Round");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	Number result = _round((Number) _exp.evaluate()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _round(Number o1) throws IllegalExpressionTypeException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "round");
+
+        Number[] o = new Number[1];
+        o[0] = o1;
+        
+        int resolvedType = TypeResolver.resolveType(o);
+        
+        if (resolvedType == TypeConstants.doubleType)
+        {
+            long roundVal = Math.round(o1.doubleValue());
+            
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Long(roundVal);
+        }
+        else if (resolvedType == TypeConstants.floatType)
+        {
+            int roundVal = Math.round(o1.floatValue());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Integer(roundVal);
+        }
+        else
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "round");
+            
+            return new Integer(o1.intValue());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(eType))
+        {
+            int tp = eType.getType();
+            if (tp == TypeConstants.doubleType)
+            {
+                _dataType.setType(TypeConstants.longType);
+                
+            }
+            else if (tp == TypeConstants.floatType)
+            {
+                _dataType.setType(TypeConstants.intType);
+                
+            }
+            else
+            {
+                _dataType.setType(TypeConstants.intType);
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="ROUND("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SdInCollection.java Fri Jan 11 10:56:30 2008
@@ -1,218 +1,218 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <prabalig@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.ExpressionUtility;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class SdInCollection extends SingleArgumentExpression implements
-        Expression
-{
-    
-    public String className = SdInCollection.class.toString();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="SdInCollection";
-    
-    
-    
-    public SdInCollection(List exprList, boolean evaluateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
-
-       //System.out.println("SdInCollection");
-        if (evaluateExpression)
-        {
-           //System.out.println("evaluateExpression " + evaluateExpression);
-            if (!validate())
-            {
-
-                logger.severe(
-                        "validation error: wrong data type passed in "
-                        + this._dataType);
-             
-                throw new SPLException(
-                        "validation error: wrong data type passed in "
-                                + this._dataType);
-            }
-        }
-        
-        this._dataType.copy(this._exp.getType());
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
-        
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-       //System.out.println("SdInCollection:evaluate");
-       //System.out.println("this.exp class " + this.exp.getClass() + " type "+ this.exp.getType());
-        Object squareSum = null;
-        Object sum = null;
-        Object expResult = this._exp.evaluate();
-        if (!(expResult instanceof java.util.List))
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"result of expression is not of type List");
-            throw new SPLException(
-                    "result of expression is not of type List");
-        }
-        ArrayList resultArray = (ArrayList) expResult;
-        Integer count = new Integer(resultArray.size());
-       //System.out.println("resultArray size " + resultArray.size() + " to string " + resultArray.toString());
-        ////System.out.println("resultArray is of type "+expression.getType());
-        if ((resultArray != null) && (!resultArray.isEmpty()))
-        {
-            Iterator resultIt = resultArray.iterator();
-            while (resultIt.hasNext())
-            {
-                Object resultObject = resultIt.next();
-               //System.out.println("resultObject,class " + resultObject + " " + resultObject.getClass());
-                if (sum == null)
-                {
-                    sum = resultObject;
-                    
-                }
-                else
-                {
-                   //System.out .println("Adding resultObject to SdInCollection is " + resultObject + "  " + sum);
-                    sum = ExpressionUtility.plus((Number) sum,
-                            (Number) resultObject);
-                }
-                Object square = ExpressionUtility.multiplication(
-                        (Number) resultObject, (Number) resultObject);
-                if (squareSum == null)
-                {
-                    squareSum = square;
-                    
-                }
-                else
-                {
-                   //System.out .println("Adding resultObject to SdInCollection is "+ resultObject + "  " + sum);
-                    squareSum = ExpressionUtility.plus((Number) square,
-                            (Number) squareSum);
-                }
-                
-            }
-            double mean = ((Number) sum).doubleValue() / resultArray.size();
-            Number squareSumByCount = ExpressionUtility.division(
-                    (Number) squareSum, (Number) count);
-            Double meanSquare = new Double(mean * mean);
-            Number subtractionResult = ExpressionUtility.minus(
-                    squareSumByCount, (Number) meanSquare);
-           //System.out.println("current SdInCollection is "+ Math.sqrt(subtractionResult.doubleValue()));
-            Number result = new Double(Math.sqrt(subtractionResult.doubleValue())); 
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
-            
-            return result;
-            
-        }
-        else
-        {
-
-            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
-            throw new SPLException("result Array is empty");
-        }
-        
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-       //System.out.println("SdInCollection : validate ");
-       //System.out.println("this.exp.getClass() " + this.exp.getClass() + " type " + this.exp.getType());
-        
-        if (!this._exp.isArray())
-        {
-           //System.out.println("expression is not a valid BasicCollectExpression");
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return false;
-        }
-        
-        else
-        {
-           //System.out.println("expression is a valid BasicCollectExpression");
-            switch (this._exp.getType().getType())
-            {
-                case TypeConstants.byteType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.doubleType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.floatType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.intType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.longType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.numericType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                case TypeConstants.shortType:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                    
-                    return true;
-                default:
-                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-                
-                    return false;
-            }
-            
-        }
-        
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        
-        String str="SdInCollection("+this._exp.toString()+")";
-        
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SdInCollection extends SingleArgumentExpression implements
+        Expression
+{
+    
+    public String className = SdInCollection.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="SdInCollection";
+    
+    
+    
+    public SdInCollection(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
+
+       //System.out.println("SdInCollection");
+        if (evaluateExpression)
+        {
+           //System.out.println("evaluateExpression " + evaluateExpression);
+            if (!validate())
+            {
+
+                logger.severe(
+                        "validation error: wrong data type passed in "
+                        + this._dataType);
+             
+                throw new SPLException(
+                        "validation error: wrong data type passed in "
+                                + this._dataType);
+            }
+        }
+        
+        this._dataType.copy(this._exp.getType());
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SdInCollection");
+        
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+       //System.out.println("SdInCollection:evaluate");
+       //System.out.println("this.exp class " + this.exp.getClass() + " type "+ this.exp.getType());
+        Object squareSum = null;
+        Object sum = null;
+        Object expResult = this._exp.evaluate();
+        if (!(expResult instanceof java.util.List))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"result of expression is not of type List");
+            throw new SPLException(
+                    "result of expression is not of type List");
+        }
+        ArrayList resultArray = (ArrayList) expResult;
+        Integer count = new Integer(resultArray.size());
+       //System.out.println("resultArray size " + resultArray.size() + " to string " + resultArray.toString());
+        ////System.out.println("resultArray is of type "+expression.getType());
+        if ((resultArray != null) && (!resultArray.isEmpty()))
+        {
+            Iterator resultIt = resultArray.iterator();
+            while (resultIt.hasNext())
+            {
+                Object resultObject = resultIt.next();
+               //System.out.println("resultObject,class " + resultObject + " " + resultObject.getClass());
+                if (sum == null)
+                {
+                    sum = resultObject;
+                    
+                }
+                else
+                {
+                   //System.out .println("Adding resultObject to SdInCollection is " + resultObject + "  " + sum);
+                    sum = ExpressionUtility.plus((Number) sum,
+                            (Number) resultObject);
+                }
+                Object square = ExpressionUtility.multiplication(
+                        (Number) resultObject, (Number) resultObject);
+                if (squareSum == null)
+                {
+                    squareSum = square;
+                    
+                }
+                else
+                {
+                   //System.out .println("Adding resultObject to SdInCollection is "+ resultObject + "  " + sum);
+                    squareSum = ExpressionUtility.plus((Number) square,
+                            (Number) squareSum);
+                }
+                
+            }
+            double mean = ((Number) sum).doubleValue() / resultArray.size();
+            Number squareSumByCount = ExpressionUtility.division(
+                    (Number) squareSum, (Number) count);
+            Double meanSquare = new Double(mean * mean);
+            Number subtractionResult = ExpressionUtility.minus(
+                    squareSumByCount, (Number) meanSquare);
+           //System.out.println("current SdInCollection is "+ Math.sqrt(subtractionResult.doubleValue()));
+            Number result = new Double(Math.sqrt(subtractionResult.doubleValue())); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+            
+        }
+        else
+        {
+
+            logger.severe(Thread.currentThread().getName()+" "+"result Array is empty");
+            throw new SPLException("result Array is empty");
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+       //System.out.println("SdInCollection : validate ");
+       //System.out.println("this.exp.getClass() " + this.exp.getClass() + " type " + this.exp.getType());
+        
+        if (!this._exp.isArray())
+        {
+           //System.out.println("expression is not a valid BasicCollectExpression");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        
+        else
+        {
+           //System.out.println("expression is a valid BasicCollectExpression");
+            switch (this._exp.getType().getType())
+            {
+                case TypeConstants.byteType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.doubleType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.floatType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.intType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.longType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.numericType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                case TypeConstants.shortType:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                    
+                    return true;
+                default:
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                    return false;
+            }
+            
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str="SdInCollection("+this._exp.toString()+")";
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ShortConstant.java Fri Jan 11 10:56:30 2008
@@ -1,94 +1,94 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <prabalig@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.ConstantExpression;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class ShortConstant extends ConstantExpression implements
-        NumericExpression
-{
-    
-    private short _shortValue;
-    
-    private TypeInfo _dataType=new TypeInfo();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="ShortConstant";
-    
-    
-    
-    public boolean isArray()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
-     
-        
-        return false;
-    }
-    
-    public ShortConstant(short val)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
-
-        this._shortValue = val;
-        _dataType.setType(TypeConstants.shortType);
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-     
-        return new Short(_shortValue);
-    }
-    
-    public TypeInfo getType()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
-     
-        return _dataType;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        
-        String str=Short.toString(this._shortValue);
-        
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return str;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.ConstantExpression;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ShortConstant extends ConstantExpression implements
+        NumericExpression
+{
+    
+    private short _shortValue;
+    
+    private TypeInfo _dataType=new TypeInfo();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ShortConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        
+        return false;
+    }
+    
+    public ShortConstant(short val)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
+
+        this._shortValue = val;
+        _dataType.setType(TypeConstants.shortType);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ShortConstant");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+     
+        return new Short(_shortValue);
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        return _dataType;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str=Short.toString(this._shortValue);
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/SquareRoot.java Fri Jan 11 10:56:30 2008
@@ -1,125 +1,125 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- * @modified Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class SquareRoot extends SingleArgumentExpression implements
-        NumericExpression
-{
-    
-    public static final String className = SquareRoot.class.getName();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="SquareRoot";
-    
-    
-    
-    public SquareRoot(List exprList, boolean validateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
-
-        if (validateExpression)
-        {
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
-                        + " has wrong data type passed in.");
-                
-                throw new SPLException("validation error: " + className
-                        + " has wrong data type passed in.");
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        try
-        {
-        	Number result = _sqrt((Number) _exp.evaluate()); 
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
-            
-            return result;
-        }
-        catch (Exception e)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-            
-            throw new SPLException("evaluation error: " + e.toString());
-        }
-    }
-    
-    private Number _sqrt(Number o)
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sqrt");
-        Number result = new Double(Math.sqrt(o.doubleValue()));
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sqrt" + result);
-     
-        return result;
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo eType = _exp.getType();
-        
-        // dataType = TypeConstants.numericType;
-        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
-        {
-            _dataType.setType(TypeConstants.doubleType);
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return true;
-        }
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-     
-        return false;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        String retStr= "SquareRoot(" +this._exp.toString() + ")";
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return retStr;
-    }
-
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class SquareRoot extends SingleArgumentExpression implements
+        NumericExpression
+{
+    
+    public static final String className = SquareRoot.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="SquareRoot";
+    
+    
+    
+    public SquareRoot(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "SquareRoot");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	Number result = _sqrt((Number) _exp.evaluate()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + result);
+            
+            return result;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    private Number _sqrt(Number o)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sqrt");
+        Number result = new Double(Math.sqrt(o.doubleValue()));
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sqrt" + result);
+     
+        return result;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+        {
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "SquareRoot(" +this._exp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+
+    
+}

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

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/StartsWith.java Fri Jan 11 10:56:30 2008
@@ -1,117 +1,117 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.expressions.StringExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class StartsWith extends DoubleArgumentExpression implements
-        StringExpression
-{
-    
-    public static final String className = StartsWith.class.getName();
-    
-    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
-    private static final String sourceClass="StartsWith";
-    
-    
-    
-    public StartsWith(List exprList, boolean validateExpression)
-            throws SPLException
-    {
-        super(exprList);
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
-
-        if (validateExpression)
-        {
-            if (!validate())
-            {
-                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
-                        + " has wrong data type passed in.");
-                
-                throw new SPLException("validation error: " + className
-                        + " has wrong data type passed in.");
-            }
-        }
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
-        
-    }
-    
-    public Object evaluate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-        try
-        {
-            String s0 = (String) _lhsExp.evaluate();
-            String s1 = (String) _rhsExp.evaluate();
-
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-         
-            return new Boolean(s0.startsWith(s1));
-        }
-        catch (Exception e)
-        {
-            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-            
-            throw new SPLException("evaluation error: " + e.toString());
-        }
-    }
-    
-    public boolean validate() throws SPLException
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
-        TypeInfo lType = _lhsExp.getType();
-        TypeInfo rType = _rhsExp.getType();
-        
-        if (!lType.getIsArray() && !rType.getIsArray() && 
-        		TypeResolver.isString(lType) && TypeResolver.isString(rType))
-        {
-            _dataType.setType(TypeConstants.stringType);
-            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-            
-            return true;
-        }
-
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-     
-        return false;
-    }
-    
-    public String toString()
-    {
-        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-        String retStr= "startsWith(" +this._lhsExp.toString()+","+ this._rhsExp.toString() + ")";
-        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-       
-        return retStr;
-    }
-    
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.expressions.StringExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class StartsWith extends DoubleArgumentExpression implements
+        StringExpression
+{
+    
+    public static final String className = StartsWith.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="StartsWith";
+    
+    
+    
+    public StartsWith(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
+
+        if (validateExpression)
+        {
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+                        + " has wrong data type passed in.");
+                
+                throw new SPLException("validation error: " + className
+                        + " has wrong data type passed in.");
+            }
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "StartsWith");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String s0 = (String) _lhsExp.evaluate();
+            String s1 = (String) _rhsExp.evaluate();
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return new Boolean(s0.startsWith(s1));
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        if (!lType.getIsArray() && !rType.getIsArray() && 
+        		TypeResolver.isString(lType) && TypeResolver.isString(rType))
+        {
+            _dataType.setType(TypeConstants.stringType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String retStr= "startsWith(" +this._lhsExp.toString()+","+ this._rhsExp.toString() + ")";
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return retStr;
+    }
+    
+}

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



Mime
View raw message