You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-commits@incubator.apache.org by ke...@apache.org on 2008/01/11 18:57:14 UTC
svn commit: r611261 [18/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...
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Floor.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Floor.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Floor.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Floor.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 Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 Floor extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = Floor.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="Floor";
-
-
-
- public Floor(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Floor");
-
- 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()+" "+ "Floor");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return floor((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 floor(Number o)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Number");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Number");
-
- return new Double(Math.floor(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 = "Floor( "+ 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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 Floor extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = Floor.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="Floor";
+
+
+
+ public Floor(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Floor");
+
+ 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()+" "+ "Floor");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return floor((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 floor(Number o)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Number");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Number");
+
+ return new Double(Math.floor(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 = "Floor( "+ 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/Floor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetCurrentTime.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetCurrentTime.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetCurrentTime.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetCurrentTime.java Fri Jan 11 10:56:30 2008
@@ -1,119 +1,119 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.ZeroArgumentExpression;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class GetCurrentTime extends ZeroArgumentExpression implements
-NumericExpression
-{
-
- public static final String className = GetCurrentTime.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetCurrentTime";
- private Calendar oCalendar = null;
-
-
- public GetCurrentTime(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetCurrentTime");
-
- 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()+" "+ "GetCurrentTime");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- try
- {
- oCalendar = Calendar.getInstance();
- oCalendar.setTimeInMillis(System.currentTimeMillis());
- //System.out.println("&&&&&&&&Current time is&&&&&&&& "+calendar.toString());
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return oCalendar;
- }
- 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");
-
- _dataType.setType(TypeConstants.dateTime);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str="";
- if (oCalendar != null){
- str = "GetCurrentTime "+ oCalendar.getTime().getTime();
- }else{
- str = "GetCurrentTime() ";
- }
-
- 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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.ZeroArgumentExpression;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class GetCurrentTime extends ZeroArgumentExpression implements
+NumericExpression
+{
+
+ public static final String className = GetCurrentTime.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetCurrentTime";
+ private Calendar oCalendar = null;
+
+
+ public GetCurrentTime(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetCurrentTime");
+
+ 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()+" "+ "GetCurrentTime");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ try
+ {
+ oCalendar = Calendar.getInstance();
+ oCalendar.setTimeInMillis(System.currentTimeMillis());
+ //System.out.println("&&&&&&&&Current time is&&&&&&&& "+calendar.toString());
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return oCalendar;
+ }
+ 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");
+
+ _dataType.setType(TypeConstants.dateTime);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str="";
+ if (oCalendar != null){
+ str = "GetCurrentTime "+ oCalendar.getTime().getTime();
+ }else{
+ str = "GetCurrentTime() ";
+ }
+
+ 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/GetCurrentTime.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfMonth.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfMonth.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfMonth.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfMonth.java Fri Jan 11 10:56:30 2008
@@ -1,123 +1,123 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetDayOfMonth extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetDayOfMonth.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetDayOfMonth";
-
-
-
- public GetDayOfMonth(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfMonth");
-
- 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()+" "+ "GetDayOfMonth");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
-
- return new Integer(calendar.get(Calendar.DAY_OF_MONTH));
- }
- 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("invalid expression type " + eType + " for getdayofmth");
- }
-
-
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetDayOfMonth("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetDayOfMonth extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetDayOfMonth.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetDayOfMonth";
+
+
+
+ public GetDayOfMonth(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfMonth");
+
+ 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()+" "+ "GetDayOfMonth");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+
+ return new Integer(calendar.get(Calendar.DAY_OF_MONTH));
+ }
+ 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("invalid expression type " + eType + " for getdayofmth");
+ }
+
+
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetDayOfMonth("+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/GetDayOfMonth.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeek.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeek.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeek.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeek.java Fri Jan 11 10:56:30 2008
@@ -1,151 +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 <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetDayOfWeek extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetDayOfWeek.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetDayOfWeek";
-
-
-
- public GetDayOfWeek(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfWeek");
-
- 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()+" "+ "GetDayOfWeek");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
-
- // I actually use a case statement in case the JVM later changes the
- // constant values
- int result = 0;
-
- switch (calendar.get(Calendar.DAY_OF_WEEK))
- {
- case Calendar.SUNDAY:
- result = 1;
- break;
- case Calendar.MONDAY:
- result = 2;
- break;
- case Calendar.TUESDAY:
- result = 3;
- break;
- case Calendar.WEDNESDAY:
- result = 4;
- break;
- case Calendar.THURSDAY:
- result = 5;
- break;
- case Calendar.FRIDAY:
- result = 6;
- break;
- case Calendar.SATURDAY:
- result = 7;
- break;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(result);
-
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
-
- if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for getDayOfWeek");
- }
-
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetDayOfWeek("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetDayOfWeek extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetDayOfWeek.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetDayOfWeek";
+
+
+
+ public GetDayOfWeek(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfWeek");
+
+ 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()+" "+ "GetDayOfWeek");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+
+ // I actually use a case statement in case the JVM later changes the
+ // constant values
+ int result = 0;
+
+ switch (calendar.get(Calendar.DAY_OF_WEEK))
+ {
+ case Calendar.SUNDAY:
+ result = 1;
+ break;
+ case Calendar.MONDAY:
+ result = 2;
+ break;
+ case Calendar.TUESDAY:
+ result = 3;
+ break;
+ case Calendar.WEDNESDAY:
+ result = 4;
+ break;
+ case Calendar.THURSDAY:
+ result = 5;
+ break;
+ case Calendar.FRIDAY:
+ result = 6;
+ break;
+ case Calendar.SATURDAY:
+ result = 7;
+ break;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(result);
+
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+
+ if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for getDayOfWeek");
+ }
+
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetDayOfWeek("+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/GetDayOfWeek.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeekInMonth.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeekInMonth.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeekInMonth.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfWeekInMonth.java Fri Jan 11 10:56:30 2008
@@ -1,123 +1,123 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetDayOfWeekInMonth extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetDayOfWeekInMonth.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetDayOfWeekInMonth";
-
-
-
- public GetDayOfWeekInMonth(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfWeekInMonth");
-
- 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()+" "+ "GetDayOfWeekInMonth");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- Calendar calendar = null;
- try
- {
- calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"invalid expression.");
-
- throw new SPLException("invalid expression.");
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
-
- if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for getDayOfWeekInMonth");
- }
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetDayOfWeekInMonth("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetDayOfWeekInMonth extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetDayOfWeekInMonth.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetDayOfWeekInMonth";
+
+
+
+ public GetDayOfWeekInMonth(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfWeekInMonth");
+
+ 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()+" "+ "GetDayOfWeekInMonth");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ Calendar calendar = null;
+ try
+ {
+ calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"invalid expression.");
+
+ throw new SPLException("invalid expression.");
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+
+ if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for getDayOfWeekInMonth");
+ }
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetDayOfWeekInMonth("+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/GetDayOfWeekInMonth.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfYear.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfYear.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfYear.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetDayOfYear.java Fri Jan 11 10:56:30 2008
@@ -1,123 +1,123 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetDayOfYear extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetDayOfYear.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetDayOfYear";
-
-
-
- public GetDayOfYear(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfYear");
-
- 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()+" "+ "GetDayOfYear");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(calendar.get(Calendar.DAY_OF_YEAR));
- }
- 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for getdayofyear");
- }
-
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetDayOfYear("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetDayOfYear extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetDayOfYear.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetDayOfYear";
+
+
+
+ public GetDayOfYear(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetDayOfYear");
+
+ 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()+" "+ "GetDayOfYear");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(calendar.get(Calendar.DAY_OF_YEAR));
+ }
+ 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for getdayofyear");
+ }
+
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetDayOfYear("+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/GetDayOfYear.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour12.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour12.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour12.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour12.java Fri Jan 11 10:56:30 2008
@@ -1,122 +1,122 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetHour12 extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetHour12.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetHour12";
-
-
-
- public GetHour12(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetHour12");
-
- 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()+" "+ "GetHour12");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(calendar.get(Calendar.HOUR));
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"invalid expression.");
-
- throw new SPLException("invalid expression.");
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
-
- if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for gethour12");
- }
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetHour12("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetHour12 extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetHour12.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetHour12";
+
+
+
+ public GetHour12(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetHour12");
+
+ 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()+" "+ "GetHour12");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(calendar.get(Calendar.HOUR));
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"invalid expression.");
+
+ throw new SPLException("invalid expression.");
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+
+ if (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for gethour12");
+ }
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetHour12("+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/GetHour12.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour24.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour24.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour24.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetHour24.java Fri Jan 11 10:56:30 2008
@@ -1,122 +1,122 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetHour24 extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetHour24.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetHour24";
-
-
-
- public GetHour24(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetHour24");
-
- 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()+" "+ "GetHour24");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(calendar.get(Calendar.HOUR_OF_DAY));
- }
- 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for gethour24");
- }
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetHour24("+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 <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.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 GetHour24 extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetHour24.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetHour24";
+
+
+
+ public GetHour24(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetHour24");
+
+ 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()+" "+ "GetHour24");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(calendar.get(Calendar.HOUR_OF_DAY));
+ }
+ 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for gethour24");
+ }
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetHour24("+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/GetHour24.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetMillisecond.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetMillisecond.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetMillisecond.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/GetMillisecond.java Fri Jan 11 10:56:30 2008
@@ -1,123 +1,123 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.Calendar;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.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 GetMillisecond extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = GetMillisecond.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="GetMillisecond";
-
-
-
- public GetMillisecond(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetMillisecond");
-
- 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()+" "+ "GetMillisecond");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- /*
- * this method returns an integer number corresponding to the day of the
- * month where the first day of the month has value 1. The parser and
- * validator should ensure the argument is of type calendar type.
- */
- try
- {
- Calendar calendar = (Calendar) _exp.evaluate();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Integer(calendar.get(Calendar.MILLISECOND));
- }
- 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
- _dataType.setType(TypeConstants.intType);
- return true;
- }
- else
- {
- throw new SPLException("Invalid input type " + eType + " for getmilliseconds");
- }
-
-
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "GetMillisecond("+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.Calendar;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class GetMillisecond extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = GetMillisecond.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="GetMillisecond";
+
+
+
+ public GetMillisecond(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "GetMillisecond");
+
+ 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()+" "+ "GetMillisecond");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ /*
+ * this method returns an integer number corresponding to the day of the
+ * month where the first day of the month has value 1. The parser and
+ * validator should ensure the argument is of type calendar type.
+ */
+ try
+ {
+ Calendar calendar = (Calendar) _exp.evaluate();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Integer(calendar.get(Calendar.MILLISECOND));
+ }
+ 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 (!eType.getIsArray() && TypeResolver.isCalendar(eType))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+ _dataType.setType(TypeConstants.intType);
+ return true;
+ }
+ else
+ {
+ throw new SPLException("Invalid input type " + eType + " for getmilliseconds");
+ }
+
+
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "GetMillisecond("+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/GetMillisecond.java
------------------------------------------------------------------------------
svn:eol-style = native