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 [14/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/ContainsOnlyLetters.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,133 @@
+/*
+ * 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 ContainsOnlyLetters extends SingleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = ContainsOnlyLetters.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ContainsOnlyLetters";
+    
+    
+    
+    public ContainsOnlyLetters(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLetters");
+
+        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()+" "+ "ContainsOnlyLetters");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String s0 = (String) _exp.evaluate();
+            
+            if (s0.length() == 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+            
+            for (int i = 0; i < s0.length(); i++)
+            {
+                if (!Character.isLetter(s0.charAt(i)))
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return Boolean.FALSE;
+                }
+            }
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return Boolean.TRUE;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        if (TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "ContainsOnlyLetters("+ this._exp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,133 @@
+/*
+ * 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 ContainsOnlyLettersOrDigits extends SingleArgumentExpression
+        implements BooleanExpression
+{
+    
+    public static final String className = ContainsOnlyLettersOrDigits.class
+            .getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="ContainsOnlyLettersOrDigits";
+    
+    
+    
+    public ContainsOnlyLettersOrDigits(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLettersOrDigits");
+
+        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()+" "+ "ContainsOnlyLettersOrDigits");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            String s0 = (String) _exp.evaluate();
+            
+            if (s0.length() == 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+            
+            for (int i = 0; i < s0.length(); i++)
+            {
+                if (!Character.isLetterOrDigit(s0.charAt(i)))
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                    
+                    return Boolean.FALSE;
+                }
+            }
+
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+         
+            return Boolean.TRUE;
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo eType = _exp.getType();
+        
+        if (TypeResolver.isString(eType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "ContainsOnlyLettersOrDigits( "+ this._exp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTime.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTime.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTime.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTime.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,864 @@
+/*
+ * 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.NoSuchElementException;
+import java.util.StringTokenizer;
+import java.util.TimeZone;
+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.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+/**
+ * This class implements a for xsd:dateTime.
+ * <p>
+ * 
+ * It
+ * <ul>
+ * <li>supports http://www.w3.org/TR/1998/NOTE-datetime-19980827
+ * <li>supports version without - and : in date/time (see for example)
+ * http://www.cl.cam.ac.uk/~mgk25/iso-time.html
+ * <li> does not support week modifiers etc.
+ * </ul>
+ * 
+ * 
+ * @author Policy Toolkit Team
+ */
+public class DateTime implements Expression
+{
+    
+      
+    private int _timeZoneMinuteOffset = 0;
+    
+    private int _timeZoneMillisOffset = 0;
+    
+    private String _timeZoneString = "GMT";
+    
+    private int _millis = -1;
+    
+    private int _second = -1;
+    
+    private int _minute = -1;
+    
+    private int _hour = -1;
+    
+    private int _day = -1;
+    
+    private int _month = -1;
+    
+    private int _year = -1;
+    
+    private boolean eraAD = true;
+    
+    public boolean isArray = false;
+    
+    private TypeInfo _dataType = null;
+    
+    private static int UTC_MULTIPLIER = 60000;
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="DateTime";
+    
+    
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        
+        return isArray;
+    }
+    
+    public DateTime(String splDateTime) throws SPLException
+    {
+    	logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "DateTime");
+        
+       
+        //System.out.println(" date string :" + dateStringGeneric);
+       // Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(GMT));
+        
+        // CIM date format yyyymmddHHMMSS.mmmmmmsUUU
+        String dateString = splDateTime.replace('*', '0');
+        
+        String YEAR = dateString.substring(0, 4);
+        String MONTH = dateString.substring(4, 6);
+        String DAY_OF_MONTH = dateString.substring(6, 8);
+        String HOUR_OF_DAY = dateString.substring(8, 10);
+        String MINUTE = dateString.substring(10, 12);
+        String SECOND = dateString.substring(12, 14);// leaving out '.'
+        String MILLISECOND = dateString.substring(15, 18);// leaving out the
+                                                            // last 3 digits as
+                                                            // microsecond is
+                                                            // not supported,
+                                                            // restricting to
+                                                            // millisecond
+        String sign = dateString.substring(21, 22);// can be '+' or '-'
+        String utcOffset = dateString.substring(22, 25);// needs to converted to
+                                                        // GMT
+            
+        
+        _year = Integer.parseInt(YEAR);
+        _month = Integer.parseInt(MONTH);
+        _day = Integer.parseInt(DAY_OF_MONTH);
+        _hour = Integer.parseInt(HOUR_OF_DAY);
+        //System.out.println("MINUTE "+MINUTE);
+        _minute = Integer.parseInt(MINUTE);
+        //System.out.println("_minute "+_minute);
+        
+        _second = Integer.parseInt(SECOND);
+        _millis = Integer.parseInt(MILLISECOND);
+        
+        int timeZoneMinuteOffset = Integer.parseInt(utcOffset);
+        int hrs = timeZoneMinuteOffset / 60;
+        _timeZoneString = _timeZoneString + sign + hrs;
+        
+        int zoneOffsetMilliseconds = timeZoneMinuteOffset * UTC_MULTIPLIER;
+         
+        if (sign.equalsIgnoreCase("-"))
+        {
+            zoneOffsetMilliseconds = 0 - zoneOffsetMilliseconds;
+            timeZoneMinuteOffset = 0 - timeZoneMinuteOffset;
+        }
+        _timeZoneMinuteOffset = timeZoneMinuteOffset;
+        _timeZoneMillisOffset = zoneOffsetMilliseconds;
+        //System.out.println("created calendar");
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "DateTime");
+        
+       
+    }
+    
+    public String getTimeZoneString()
+    {
+    	return _timeZoneString;
+    }
+    
+    public static boolean isDateTimeString(String dateStringGeneric)
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isDateTimeString");
+
+
+		//System.out.println("*****Checking to see if string is datetime"+dateStringGeneric);
+		String dateStr=dateStringGeneric.substring(1, dateStringGeneric.length()-1);
+		//System.out.println("*****Checking to see if string is dateStr"+dateStr);
+
+		dateStr = dateStr.replace('*', '0');
+		//System.out.println("*****Checking to see if string is dateStr"+dateStr+dateStr.length());
+
+		if(dateStr.length()!=25)
+		{
+			return false;
+		}
+		String YEAR = dateStr.substring(0, 4);
+		String MONTH = dateStr.substring(4, 6);
+		String DAY_OF_MONTH = dateStr.substring(6, 8);
+		String HOUR_OF_DAY = dateStr.substring(8, 10);
+		String MINUTE = dateStr.substring(10, 12);
+		String SECOND = dateStr.substring(12, 14);// leaving out '.'
+		String MILLISECOND = dateStr.substring(15, 18);// leaving out the
+		// last 3 digits as
+		// microsecond is
+		// not supported,
+		// restricting to
+		// millisecond
+		String sign = dateStr.substring(21, 22);// can be '+' or '-'
+		String utcOffset = dateStr.substring(22, 25);// needs to converted to
+
+		//System.out.println("*****YEAR"+Integer.parseInt(YEAR));
+		try
+		{
+			if(Integer.parseInt(YEAR) >=0 && Integer.parseInt(YEAR) <=9999)
+			{//System.out.println("*****MONTH"+Integer.parseInt(MONTH));
+				if(Integer.parseInt(MONTH) >0 && Integer.parseInt(MONTH) <=12)
+				{//System.out.println("*****DAY_OF_MONTH"+Integer.parseInt(DAY_OF_MONTH));
+					if(Integer.parseInt(DAY_OF_MONTH) >0 && Integer.parseInt(DAY_OF_MONTH) <=31)
+					{//System.out.println("*****HOUR_OF_DAY"+Integer.parseInt(HOUR_OF_DAY));
+						if(Integer.parseInt(HOUR_OF_DAY) >=0 && Integer.parseInt(HOUR_OF_DAY) <24)
+						{//System.out.println("*****MINUTE"+Integer.parseInt(MINUTE));
+							if(Integer.parseInt(MINUTE) >=0 && Integer.parseInt(MINUTE) <60)
+							{//System.out.println("*****SECOND"+Integer.parseInt(SECOND));
+								if(Integer.parseInt(SECOND) >=0 && Integer.parseInt(SECOND) <60)
+								{//System.out.println("*****MILLISECOND"+Integer.parseInt(MILLISECOND));
+									if(Integer.parseInt(MILLISECOND) >=0 && Integer.parseInt(MILLISECOND) <=999)
+									{//System.out.println("*****+"+sign);
+										if(sign.equalsIgnoreCase("+") || sign.equalsIgnoreCase("-"))
+										{//System.out.println("*****utcOffset"+Integer.parseInt(utcOffset));
+											if(Integer.parseInt(utcOffset) >=0 && Integer.parseInt(MILLISECOND) <=999)
+											{
+												//System.out.println(dateStringGeneric+" is a DATETIME string");
+												logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isDateTimeString");
+												return true;
+
+
+											}
+										}
+									}
+								}
+							}
+						}                    
+					}                
+				}            
+			}
+		}
+		catch(NumberFormatException e)
+		{
+//			System.out.println(" string is not a datetime string "+e.getMessage());
+			return false;
+		}
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isDateTimeString");
+		//System.out.println(dateStringGeneric+" is not a DATETIME string");
+
+		return false;
+	}
+    
+    /**
+     * for xsd:dateTime TimePeriod format Supports all of:
+     * http://www.w3.org/TR/1998/NOTE-datetime-19980827 Plus version without -
+     * and : in date/time (see for example)
+     * http://www.cl.cam.ac.uk/~mgk25/iso-time.html
+     * 
+     * @param isUTC
+     * @param isodate
+     * @throws ExpressionException
+     *//*
+    public DateTime(String isodate) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "DateTime");
+        
+        _dataType = new TypeInfo(TypeConstants.dateTime);
+        
+        // -YYYY-MM-DDThh:mm:ss.sTZD
+        // or
+        // -YYYYMMDDThhmmss.sTZD
+        // or
+        // -YYYYMMDDThhmmss
+        // or combination of both
+        
+        // does not support week specifiers, etc.
+        // null argument check
+        
+        if (isodate == null)
+            return;
+        
+        if (isodate.startsWith("-"))
+        {
+            this.eraAD = false;
+        }
+        
+        StringTokenizer datetime = new StringTokenizer(isodate.trim(), "T",
+                true);
+        
+        String datepart = null;
+        String timeTZpart = null;
+        boolean inTime = false;
+        while (datetime.hasMoreTokens())
+        {
+            String token = datetime.nextToken();
+            if (token.equalsIgnoreCase("T"))
+            {
+                if (inTime)
+                {
+                    logger.severe(
+                    "invalid expression: invalid date.");
+                    throw new SPLException(
+                            "invalid expression: invalid date.");
+                }
+                else
+                {
+                    inTime = true;
+                    continue;
+                }
+            }
+            else if (inTime)
+            {
+                timeTZpart = token;
+            }
+            else
+            {
+                datepart = token;
+            }
+        }
+        
+        try
+        {
+            // datepart
+            
+            if (datepart != null)
+            {
+                
+                String overflow = null;
+                StringTokenizer dateToken = new StringTokenizer(datepart, "-",
+                        false);
+                
+                // Year
+                if (dateToken.hasMoreElements())
+                {
+                    String yearStr = (String) dateToken.nextElement();
+                    if (yearStr.length() > 4)
+                    {
+                        overflow = yearStr.substring(4, yearStr.length());
+                        yearStr = yearStr.substring(0, 4);
+                    }
+                    int yearVal = Integer.parseInt(yearStr);
+                    this.year = yearVal;
+                }
+                else
+                {
+                    
+                    return;
+                }
+                
+                // Month
+                if (overflow != null || dateToken.hasMoreElements())
+                {
+                    String monthStr = "";
+                    if (overflow != null)
+                    {
+                        monthStr = overflow;
+                        overflow = null;
+                    }
+                    else if (dateToken.hasMoreElements())
+                    {
+                        monthStr = (String) dateToken.nextElement();
+                    }
+                    
+                    if (monthStr.length() > 2)
+                    {
+                        overflow = monthStr.substring(2, monthStr.length());
+                        monthStr = monthStr.substring(0, 2);
+                    }
+                    this.month = Integer.parseInt(monthStr) - 1;
+                }
+                else
+                {
+                    return;
+                }
+                
+                // Day
+                if (overflow != null || dateToken.hasMoreElements())
+                {
+                    String dayStr = "";
+                    if (overflow != null)
+                    {
+                        dayStr = overflow;
+                        overflow = null;
+                    }
+                    else if (dateToken.hasMoreElements())
+                    {
+                        dayStr = (String) dateToken.nextElement();
+                    }
+                    
+                    if (dayStr.length() > 2)
+                    {
+                        overflow = dayStr.substring(2, dayStr.length());
+                        dayStr = dayStr.substring(0, 2);
+                    }
+                    this.day = Integer.parseInt(dayStr);
+                }
+                else
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "DateTime");
+                    
+                    return;
+                }
+                
+            }
+            
+            // Timepart
+            
+            if (timeTZpart != null)
+            {
+            }
+            
+            StringTokenizer timezoneToken = new StringTokenizer(timeTZpart,
+                    "Z+-", true);
+            
+            // Get just the time (not timezone)
+            String timepart = "";
+            
+            if (timezoneToken.hasMoreElements())
+            {
+                timepart = timezoneToken.nextToken();
+            }
+            
+            String overflow = null;
+            StringTokenizer timeToken = new StringTokenizer(timepart, ":", true);
+            
+            // hour
+            if (timeToken.hasMoreElements())
+            {
+                String hourStr = (String) timeToken.nextElement();
+                if (hourStr.length() > 2)
+                {
+                    overflow = hourStr.substring(2, hourStr.length());
+                    hourStr = hourStr.substring(0, 2);
+                }
+                this.hour = Integer.parseInt(hourStr);
+            }
+            else
+            {
+                this.hour = 0;
+            }
+            
+            // minute
+            if (overflow != null
+                    || (hasToken(timeToken, ":") && timeToken.hasMoreElements()))
+            {
+                String minuteStr = "";
+                if (overflow != null)
+                {
+                    minuteStr = overflow;
+                    overflow = null;
+                }
+                else if (timeToken.hasMoreElements())
+                {
+                    minuteStr = (String) timeToken.nextElement();
+                }
+                
+                if (minuteStr.length() > 2)
+                {
+                    overflow = minuteStr.substring(2, minuteStr.length());
+                    minuteStr = minuteStr.substring(0, 2);
+                }
+                this.minute = Integer.parseInt(minuteStr);
+            }
+            else
+            {
+                this.minute = 0;
+            }
+            
+            // second complete whole and part
+            String secondStr = "";
+//            String wholeSecond = "";
+            String fractionSecond = "";
+            
+            if (overflow != null
+                    || (hasToken(timeToken, ":") && timeToken.hasMoreElements()))
+            {
+                
+                if (overflow != null)
+                {
+                    secondStr = overflow;
+                    overflow = null;
+                }
+                else if (timeToken.hasMoreElements())
+                {
+                    secondStr = (String) timeToken.nextElement();
+                }
+                
+                // We are at the end -- if there are more tokens at this point
+                // then it is an error
+                if (timeToken.hasMoreElements())
+                {
+                    logger.severe(
+                            "invalid expression: "
+                            + "RFC3060 TimePeriodCondition requires the time part be of the form HH:MM:SS.SSSS, but the given time does not meet this requirement: "
+                            + isodate + ".");
+                    throw new SPLException(
+                            "invalid expression: "
+                                    + "RFC3060 TimePeriodCondition requires the time part be of the form HH:MM:SS.SSSS, but the given time does not meet this requirement: "
+                                    + isodate + ".");
+                }
+                
+                // now we need to tease out the fractional seconds part
+                
+                StringTokenizer secondToken = new StringTokenizer(secondStr,
+                        ".", false);
+                
+                if (secondToken.hasMoreElements())
+                {
+//                    wholeSecond = secondToken.nextToken();
+                }
+                if (secondToken.hasMoreElements())
+                {
+                    fractionSecond = secondToken.nextToken();
+                }
+                if (secondToken.hasMoreElements())
+                {
+                    logger.severe(
+                            "invalid expression: "
+                            + "RFC3060 TimePeriodCondition requires the time part be of the form HH:MM:SS.SSSS, but the given time does not meet this requirement: "
+                            + isodate + ".");
+                   
+                    throw new SPLException(
+                            "invalid expression: "
+                                    + "RFC3060 TimePeriodCondition requires the time part be of the form HH:MM:SS.SSSS, but the given time does not meet this requirement: "
+                                    + isodate + ".");
+                }
+                
+            }
+            
+            // whole second
+            
+            if (secondStr.length() > 2)
+            {
+                overflow = secondStr.substring(2, secondStr.length());
+                secondStr = secondStr.substring(0, 2);
+            }
+            if (secondStr.length() > 0)
+            {
+                
+                this.second = Integer.parseInt(secondStr);
+            }
+            else
+            {
+                this.second = 0;
+            }
+            
+            // fraction second / millisecond
+            
+            if (fractionSecond.length() > 0)
+            {
+                while (fractionSecond.length() < 3)
+                {
+                    fractionSecond += "0";
+                }
+                
+                for (int i = 0; i < fractionSecond.length(); i++)
+                {
+                    if (!Character.isDigit(fractionSecond.charAt(i)))
+                    {
+                        logger.severe(
+                                "invalid expression: "
+                                + "Format of fractional seconds in RFC 3060 time is invalid: "
+                                + isodate);
+                        throw new SPLException(
+                                "invalid expression: "
+                                        + "Format of fractional seconds in RFC 3060 time is invalid: "
+                                        + isodate);
+                    }
+                }
+                fractionSecond = fractionSecond.substring(0, 3);
+                // Cut trailing chars..
+                
+                this.millis = Integer.parseInt(fractionSecond);
+            }
+            else
+            {
+                this.millis = 0;
+            }
+            
+            // get TIMEZONE
+            
+            if (timezoneToken.hasMoreElements())
+            {
+                String oper = timezoneToken.nextToken();
+                if (!oper.equals("Z"))
+                { // UTC case
+                    if (!(oper.equals("+") || oper.equals("-")))
+                    { 
+                        logger.severe(
+                                "invalid expression: "
+                                + "Z, +. - required to specify a TZ in a RFC3060 TimePeriodCondition.");
+           
+        
+                        throw new SPLException(
+                                "invalid expression: "
+                                        + "Z, +. - required to specify a TZ in a RFC3060 TimePeriodCondition.");
+                    }
+                    int factor = (oper.equals("-") ? -1 : 1);
+                    
+                    overflow = null;
+                    
+                    if (!timezoneToken.hasMoreElements())
+                    {
+                        logger.severe(
+                            "invalid expression: "
+                            + "TZ without hour specified in a RFC3060 TimePeriodCondition.");
+        
+                        throw new SPLException(
+                                "invalid expression: "
+                                        + "TZ without hour specified in a RFC3060 TimePeriodCondition.");
+                    }
+                    
+                    String timezonediff = timezoneToken.nextToken();
+                    
+                    StringTokenizer tzdToken = new StringTokenizer(
+                            timezonediff, ":", true);
+                    
+                    // hour
+                    if (tzdToken.hasMoreElements())
+                    {
+                        String hourStr = (String) tzdToken.nextElement();
+                        if (hourStr.length() > 2)
+                        {
+                            overflow = hourStr.substring(2, hourStr.length());
+                            hourStr = hourStr.substring(0, 2);
+                        }
+                        int hourValue = Integer.parseInt(hourStr);
+                        this.timeZoneHourOffset = factor * hourValue;
+                    }
+                    else
+                    {logger.severe(
+                            "invalid expression: "
+                            + "TZ without hour specified in a RFC3060 TimePeriodCondition.");
+      
+                        throw new SPLException(
+                                "invalid expression: "
+                                        + "TZ without hour specified in a RFC3060 TimePeriodCondition.");
+                    }
+                    
+                    // minute
+                    if (overflow != null
+                            || (hasToken(tzdToken, ":") && tzdToken
+                                    .hasMoreElements()))
+                    {
+                        String minuteStr = "";
+                        if (overflow != null)
+                        {
+                            minuteStr = overflow;
+                            overflow = null;
+                        }
+                        else if (tzdToken.hasMoreElements())
+                        {
+                            minuteStr = (String) tzdToken.nextElement();
+                        }
+                        
+                        if (minuteStr.length() > 2)
+                        {
+                            overflow = minuteStr.substring(2, minuteStr
+                                    .length());
+                            minuteStr = minuteStr.substring(0, 2);
+                        }
+                        int minuteValue = Integer.parseInt(minuteStr);
+                        this.timeZoneMinuteOffset = factor * minuteValue;
+                    }
+                    
+                }
+                
+            }
+            
+        }
+        catch (Exception ex)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"invalid expression: "
+                    + "Error converting to a Number.");
+            
+            throw new SPLException("invalid expression: "
+                    + "Error converting to a Number.");
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "DateTime");
+     
+    }
+    
+    private static boolean hasToken(StringTokenizer st, String token)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "hasToken");
+
+        try
+        {
+            if (st.hasMoreElements() && st.nextToken().equals(token))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "hasToken");
+                
+                return true;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "hasToken");
+                
+                return false;
+            }
+        }
+        catch (NoSuchElementException ex)
+        {
+            ex.getMessage();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "hasToken");
+            
+            return false;
+        }
+    }
+    */
+    /**
+     * Returns the day number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getDay()
+    {
+        
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getDay");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getDay");
+        return _day;
+    }
+    
+    /**
+     * Returns the hour number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getHour()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getHour");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getHour");
+     
+        return _hour;
+    }
+    
+    /**
+     * Returns the milliseconds number for this dateTime, or -1 if it is
+     * unspecified
+     * 
+     * @return
+     */
+    public int getMillis()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getMillis");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getMillis");
+     
+        return _millis;
+    }
+    
+    /**
+     * Returns the minute number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getMinute()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getMinute");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getMinute");
+     
+        return _minute;
+    }
+    
+    /**
+     * Returns the month number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getMonth()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getMonth");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getMonth");
+     
+        return _month;
+    }
+    
+    /**
+     * Returns the second number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getSecond()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getSecond");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getSecond");
+     
+        return _second;
+    }
+    
+    
+   
+    
+    /**
+     * Returns the year number for this dateTime, or -1 if it is unspecified
+     * 
+     * @return
+     */
+    public int getYear()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getYear");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getYear");
+     
+        return _year;
+    }
+    
+    /**
+     * Returns true if this is an AD date, or false if this is a BC date.
+     * 
+     * @return
+     */
+    public boolean isEraAD()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isEraAD");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isEraAD");
+     
+        return eraAD;
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+     
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        // TODO Auto-generated method stub
+        return _dataType;
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        // TODO Auto-generated method stub
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        
+        String str=Integer.toString(this._year)+"/"+Integer.toString(this._month)+"/"+Integer.toString(this._day)+" "+Integer.toString(this._hour)+":"+Integer.toString(this._minute)+":"+Integer.toString(this._second)+":"+Integer.toString(this._millis)+" MinuteOffset:"+Integer.toString(this.getTimeZoneMinuteOffset())+" eraAD:"+Boolean.toString(this.eraAD);
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+	public int getTimeZoneMinuteOffset() {
+		// TODO Auto-generated method stub
+		return _timeZoneMinuteOffset;
+	}
+
+	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/DateTimeConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTimeConstant.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTimeConstant.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/DateTimeConstant.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,174 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.Date;
+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.CalendarExpression;
+import org.apache.imperius.spl.parser.expressions.ConstantExpression;
+import org.apache.imperius.spl.parser.expressions.TimeZoneExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class DateTimeConstant extends ConstantExpression implements
+        CalendarExpression
+{
+    
+    /*
+     * value of this constant
+     */
+    Calendar _calendarValue;
+    
+    DateTime _dateTime;
+    
+    boolean preferStandardTime;
+    
+    boolean isLenient;
+    
+   
+    
+  
+    
+    
+    private TypeInfo _dataType=new TypeInfo();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="DateTimeConstant";
+    
+    
+    
+    public boolean isArray()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+     
+        
+        return _dataType.getIsArray();
+    }
+    
+  
+    
+        
+    public DateTimeConstant(String dateStr) throws SPLException 
+    {
+    	    	
+    	_dateTime = new DateTime(dateStr);
+    	_dataType.setType(TypeConstants.dateTime);
+	}
+    
+    public DateTimeConstant(Calendar val) throws SPLException
+    {
+    	_dataType.setType(TypeConstants.dateTime);
+    	_calendarValue = val;
+    }
+
+	/**
+     * Evaluates and returns the value of this expression using the specified
+     * <code>SensorLookup</code> to obtain the values of indeterminates
+     * (quantities whose magnitude cannot be determined at the time of authoring
+     * the expression) occuring in this expression. Since this
+     * <code>Expression</code> has a constant value, the specified
+     * <code>SensorLookup</code>is not used.
+     * <p>
+     * 
+     * @param s
+     *            the specified <code>SensorLookup</code>
+     * @return the value of this expression
+     * @throws com.ibm.autonomic.policy.expression.EvaluationException
+     */
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+            if (_calendarValue == null)
+            {
+            	_calendarValue = ExpressionUtility.computeCalendarValue(this.isLenient,
+                        this.preferStandardTime, this._dateTime); 
+                // Need to construct the constant
+               
+            }
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate" + _calendarValue);
+                
+            return _calendarValue;
+            
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+        
+    }
+    
+    public TypeInfo getType()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getType");
+     
+        return _dataType;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+        String str="";
+        if(this._calendarValue ==null){
+        	try{
+        		this.evaluate();
+        	}
+        	catch(SPLException e){
+        		e.printStackTrace();
+        		logger.severe(e.getMessage());
+        	}
+        }
+        if(this._calendarValue !=null){
+        	
+        
+        Calendar cal=this._calendarValue;
+        Date dt=cal.getTime();
+        //dt.
+        //str=Integer.toString(dt.getYear())+"/"+Integer.toString(dt.getMonth())+"/"+Integer.toString(dt.getDay())+" "+Integer.toString(dt.getHours())+":"+Integer.toString(dt.getMinutes())+":"+Integer.toString(dt.getSeconds())+":"+Integer.toString(0)+" MinuteOffset:"+Integer.toString(dt.getTimezoneOffset())+" eraAD:"+Boolean.toString(true);
+        str=Integer.toString(cal.get(Calendar.DAY_OF_MONTH))+"/"+Integer.toString(cal.get(Calendar.MONTH))+
+        	"/"+Integer.toString(cal.get(Calendar.DAY_OF_WEEK))+" "+Integer.toString(cal.get(Calendar.HOUR_OF_DAY))+":"+
+        		Integer.toString(cal.get(Calendar.MINUTE))+":"+Integer.toString(cal.get(Calendar.SECOND))+":"+Integer.toString(0)+" MinuteOffset:"+
+        			Integer.toString((cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET))/60 * 1000)+" eraAD:"+Boolean.toString(true);
+        }
+        else{
+        	str="DateTimeConstant";
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+
+	
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Division.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Division.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Division.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Division.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,237 @@
+/*
+ * 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.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+/**
+ * 
+ * @author Xiping Change Log: 1. 3/9/07: Neeraj Joshi: Changed constructor to
+ *         take a list to facilitate reflection in the expression factory 2.
+ *         3/9/07: Neeraj Joshi: Changed the algorithm which determines return
+ *         type to use numeric promotion
+ * 
+ */
+public class Division extends DoubleArgumentExpression implements
+	NumericExpression
+{
+    
+    public static final String className = Division.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Division";
+    
+    
+    
+    public Division(List exprList, boolean validateExpression)
+    throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Division");
+        
+        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()+" "+ "Division");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        try
+        {
+            if(logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" LHS/RHS "+_lhsExp.toString()+"/"+_rhsExp.toString());
+            
+            Number lhs = (Number) _lhsExp.evaluate();
+            Number rhs = (Number) _rhsExp.evaluate();
+            
+            if(logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" LHS,RHS::"+lhs+","+rhs);
+            
+            Number result=division(lhs, rhs);
+            if(logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" division result ::"+lhs+"/"+rhs+"="+result);
+            
+            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 static Number division(Number o1, Number o2) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "division");
+        
+        Number[] o = new Number[2];
+        o[0] = o1;
+        o[1] = o2;
+        
+//        int resolvedType = TypeResolver.resolveType(o);
+        if((o1!=null)&&(o2!=null))
+        {
+            if(o2.intValue()!=0)
+            {
+                //if (resolvedType == TypeConstants.doubleType)
+                //{
+                Double result=new Double(o1.doubleValue() / o2.doubleValue());
+                if(logger.isLoggable(Level.FINE))
+                    logger.fine(Thread.currentThread().getName()+" result "+result);
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                
+                return result;
+                /* }
+                else if (resolvedType == TypeConstants.floatType)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                    
+                    Float result=new Float(o1.floatValue() / o2.floatValue());
+                    if(logger.isLoggable(Level.FINE))
+                        logger.fine(Thread.currentThread().getName()+" result "+result);
+                    
+                    return result;
+                }
+                else if (resolvedType == TypeConstants.longType)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                    
+                    Long result=new Long(o1.longValue() / o2.longValue());
+                    if(logger.isLoggable(Level.FINE))
+                        logger.fine(Thread.currentThread().getName()+" result "+result);
+                    
+                    return result;
+                }
+                else if (resolvedType == TypeConstants.intType)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                    
+                    Integer result=new Integer(o1.intValue() / o2.intValue());
+                    if(logger.isLoggable(Level.FINE))
+                        logger.fine(Thread.currentThread().getName()+" result "+result);
+                    
+                    return result;
+                }
+                else if (resolvedType == TypeConstants.shortType)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                    
+                    Short result=new Short((short) (o1.shortValue() / o2.shortValue()));
+                    if(logger.isLoggable(Level.FINE))
+                        logger.fine(Thread.currentThread().getName()+" result "+result);
+                    
+                    return result;
+                }
+                else if (resolvedType == TypeConstants.byteType)
+                {
+                    logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "division");
+                    
+                    Byte result=new Byte((byte) (o1.byteValue() / o2.byteValue()));
+                    if(logger.isLoggable(Level.FINE))
+                        logger.fine(Thread.currentThread().getName()+" result "+result);
+                    
+                    return result;
+                }
+                else
+                {
+                    logger.severe(Thread.currentThread().getName()+" "+"wrong operand type.");
+                    
+                    throw new SPLException("wrong operand type.");
+                }*/
+            }
+            else
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"denominator is zero  LHS="+o1+" RHS="+o2);
+                
+                throw new SPLException("denominator is zero  LHS="+o1+" RHS="+o2);
+            }
+            
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"operand is null  LHS="+o1+" RHS="+o2);
+            
+            throw new SPLException("operand is null  LHS="+o1+" RHS="+o2);
+        }
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        // dataType = TypeConstants.numericType;
+        if (TypeResolver.isNumeric(lType) && TypeResolver.isNumeric(rType) &&
+        		!lType.getIsArray() && !rType.getIsArray())
+        {
+            //dataType = TypeResolver
+            //        .binaryNumericPromotionResolver(lType, rType);
+            _dataType.setType(TypeConstants.doubleType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = this._lhsExp.toString() + " / " + this._rhsExp.toString();
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EndsWith.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EndsWith.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EndsWith.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EndsWith.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.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class EndsWith extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = EndsWith.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="EndsWith";
+    
+    
+    
+    public EndsWith(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "EndsWith");
+
+        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()+" "+ "EndsWith");
+        
+    }
+    
+    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.endsWith(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 (TypeResolver.isString(lType) && TypeResolver.isString(rType) &&
+        		!lType.getIsArray() && !rType.getIsArray())
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = this._lhsExp.toString() + ".endsWith(" + this._rhsExp.toString() + ")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EqCollections.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EqCollections.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EqCollections.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/EqCollections.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,215 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class EqCollections extends DoubleArgumentExpression implements
+        Expression
+{
+    
+    // private BasicCollectionExpression basicCollection=null;
+    public String className = EqCollections.class.toString();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="EqCollections";
+    
+    
+    
+    public EqCollections(List exprList, boolean evaluateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "EqCollections");
+
+       //System.out.println("EqCollections");
+        // this.basicCollection=new BasicCollectionExpression(exprList,new
+        // SPLSymbolTable());
+        
+        if (evaluateExpression)
+        {
+           //System.out.println("evaluateExpression " + evaluateExpression);
+            if (!validate())
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"validation error: wrong data type passed in");
+                throw new SPLException(
+                        "validation error: wrong data type passed in "
+                                + this._dataType);
+            }
+            
+        }
+        this._dataType.setType(TypeConstants.booleanType);
+        _dataType.setIsArray(false);
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "EqCollections");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        //System.out.println("EqCollections:evaluate");
+        Object lhsResult = this._lhsExp.evaluate();
+        Object rhsResult = this._rhsExp.evaluate();
+        if (!(lhsResult instanceof java.util.List))
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"lhsResult is not of type List");
+            throw new SPLException("lhsResult is not of type List");
+        }
+        else
+        {
+            //System.out.println("lhsResult is of type List");
+        }
+        if (!(rhsResult instanceof java.util.List))
+        {
+
+            logger.severe(Thread.currentThread().getName()+" "+"rhsResult is not of type List");
+            throw new SPLException("rhsResult is not of type List");
+        }
+        else
+        {
+            //System.out.println("rhsResult is of type List");
+        }
+        
+        List lhsResultarray = (List) lhsResult;
+        List rhsResultarray = (List) rhsResult;
+        Boolean result = Boolean.FALSE;
+        if (lhsResultarray.size() != rhsResultarray.size())
+        {
+            result = Boolean.FALSE;
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+            
+            return result;
+        }
+        Iterator lhsResultarrayIt = lhsResultarray.iterator();
+        while (lhsResultarrayIt.hasNext())
+        {
+            Object lhsResultarrayElement = lhsResultarrayIt.next();
+            //System.out.println("element from Lhs ResultArray "+ lhsResultarrayElement + "  "+ lhsResultarrayElement.getClass());
+            if (!(rhsResultarray.contains(lhsResultarrayElement)))
+            {
+                //System.out.println("element does not exists in RHS List");
+                result = Boolean.FALSE;
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            {
+                //System.out.println("element exists in RHS List");
+            }
+            
+        }
+        Iterator rhsResultarrayIt = rhsResultarray.iterator();
+        while (rhsResultarrayIt.hasNext())
+        {
+            Object rhsResultarrayElement = rhsResultarrayIt.next();
+            //System.out.println("element from Lhs ResultArray "+ rhsResultarrayElement + "  "+ rhsResultarrayElement.getClass());
+            if (!(lhsResultarray.contains(rhsResultarrayElement)))
+            {
+                //System.out.println("element does not exists in LHS List");
+                result = Boolean.FALSE;
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return result;
+            }
+            else
+            {
+                //System.out.println("element exists in RHS List");
+            }
+            
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+        
+        return Boolean.TRUE;
+        
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        //System.out.println("EqCollections : validate ");
+        Expression lhsExpression = (Expression) this._lhsExp;
+        Expression rhsExpression = (Expression) this._rhsExp;
+        if ((lhsExpression == null) || (rhsExpression == null))
+        {
+            //System.out.println("EqCollections : One or more expressions are null ");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        if (lhsExpression.getType().getType() != rhsExpression.getType().getType() )
+        {
+            //System.out.println("EqCollections : lhs Type !=rhs Type "+ lhsExpression.getType() + ":" + rhsExpression.getType());
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        if (lhsExpression.isArray())
+        {
+            //System.out.println("lhsExpression.getType() ==TypeConstants.basicCollectionType");
+            if (rhsExpression.isArray())
+            {
+                //System.out.println("rhsExpression.getType() ==TypeConstants.basicCollectionType");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return true;
+                
+            }
+            else
+            {
+                //System.out.println("rhsExpression.getType() !=TypeConstants.basicCollectionType");
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+                
+                return false;
+            }
+        }
+        else
+        {
+            //System.out.println("lhsExpression.getType() !=TypeConstants.basicCollectionType");
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return false;
+        }
+        
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = "EqCollections( "+ this._lhsExp.toString() + "," + this._rhsExp.toString() +")";
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Equal.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Equal.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Equal.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/parser/expressions/impl/Equal.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,151 @@
+/*
+ * 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.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class Equal extends DoubleArgumentExpression implements
+        BooleanExpression
+{
+    
+    public static final String className = Equal.class.getName();
+    
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="Equal";
+    
+    
+    
+    public Equal(List exprList, boolean validateExpression)
+            throws SPLException
+    {
+        super(exprList);
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Equal");
+
+       //System.out.println("Equal: super(exprList) done");
+        if (validateExpression)
+        {
+           //System.out.println("Equal::validate()  lhsExpType:RhsExpType=result    "
+           //                 + lhsExp.getType()
+           //                 + ":"
+           //                 + rhsExp.getType()
+           //                 + "="
+           //                 + validate());
+            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()+" "+ "Equal");
+        
+    }
+    
+    public Object evaluate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+        try
+        {
+        	//System.out.println("_lhsExp "+_lhsExp );
+        	//System.out.println("_rhsExp "+_rhsExp);
+        	
+            Object lhsValue = _lhsExp.evaluate();
+            Object rhsValue = _rhsExp.evaluate();
+            //System.out.println("_lhsExp "+lhsValue+" "+_lhsExp.getClass());
+        	//System.out.println("_rhsExp "+rhsValue+" "+_rhsExp.getClass());
+        	
+            if (ExpressionUtility.compare(lhsValue, rhsValue) == 0)
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.TRUE;
+            }
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+                
+                return Boolean.FALSE;
+            }
+        }
+        catch (Exception e)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+            
+            throw new SPLException("evaluation error: " + e.toString());
+        }
+    }
+    
+    public boolean validate() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        TypeInfo lType = _lhsExp.getType();
+        TypeInfo rType = _rhsExp.getType();
+        
+        //System.out.println("Equal::validate() lhsExpType:RhsExpType
+        // "+lType+":"+rType);
+        if (!lType.getIsArray() && !rType.getIsArray() &&
+        		TypeResolver.isTypeAssignableForEquality(lType, rType))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+        if ((TypeResolver.isCalendar(lType))
+                && (TypeResolver.isCalendar(rType)))
+        {
+            _dataType.setType(TypeConstants.booleanType);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+            
+            return true;
+        }
+
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+     
+        return false;
+    }
+    
+    public String toString()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+        String str = this._lhsExp.toString() + "==" + this._rhsExp.toString();
+        	
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+       
+        return str;
+    }
+    
+}

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



Mime
View raw message