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 [21/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/LessOrEqual.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java Fri Jan 11 10:56:30 2008
@@ -1,138 +1,138 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.BooleanExpression;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.util.ExpressionUtility;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LessOrEqual extends DoubleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = LessOrEqual.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LessOrEqual";
-
-
-
- public LessOrEqual(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LessOrEqual");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LessOrEqual");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- Object lhsValue = _lhsExp.evaluate();
- Object rhsValue = _rhsExp.evaluate();
-
- if (ExpressionUtility.compare(lhsValue, rhsValue) <= 0)
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
- else
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.FALSE;
- }
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo lType = _lhsExp.getType();
- TypeInfo rType = _rhsExp.getType();
-
- //System.out.println("lType:rType " + lType + " " + rType);
- if(!lType.getIsArray() && !rType.getIsArray())
- {
- if (TypeResolver.isTypeAssignableForRelation(lType, rType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
- if ((TypeResolver.isCalendar(lType))
- && (TypeResolver.isCalendar(rType)))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = this._lhsExp.toString() + "<=" + this._rhsExp.toString();
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.ExpressionUtility;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LessOrEqual extends DoubleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = LessOrEqual.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LessOrEqual";
+
+
+
+ public LessOrEqual(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LessOrEqual");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LessOrEqual");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ Object lhsValue = _lhsExp.evaluate();
+ Object rhsValue = _rhsExp.evaluate();
+
+ if (ExpressionUtility.compare(lhsValue, rhsValue) <= 0)
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+ else
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.FALSE;
+ }
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo lType = _lhsExp.getType();
+ TypeInfo rType = _rhsExp.getType();
+
+ //System.out.println("lType:rType " + lType + " " + rType);
+ if(!lType.getIsArray() && !rType.getIsArray())
+ {
+ if (TypeResolver.isTypeAssignableForRelation(lType, rType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+ if ((TypeResolver.isCalendar(lType))
+ && (TypeResolver.isCalendar(rType)))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = this._lhsExp.toString() + "<=" + this._rhsExp.toString();
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LessOrEqual.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Ln.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Ln.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Ln.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Ln.java Fri Jan 11 10:56:30 2008
@@ -1,121 +1,121 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- * @modified Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class Ln extends SingleArgumentExpression implements NumericExpression
-{
-
- public static final String className = Ln.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="Ln";
-
-
-
- public Ln(List exprList, boolean validateExpression) throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return log((Number) _exp.evaluate());
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public static Number log(Number o)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
-
- return new Double(Math.log(o.doubleValue()));
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
- {
- _dataType.setType(TypeConstants.doubleType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "Ln("+this._exp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Ln extends SingleArgumentExpression implements NumericExpression
+{
+
+ public static final String className = Ln.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="Ln";
+
+
+
+ public Ln(List exprList, boolean validateExpression) throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Ln");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return log((Number) _exp.evaluate());
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public static Number log(Number o)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+ return new Double(Math.log(o.doubleValue()));
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+ {
+ _dataType.setType(TypeConstants.doubleType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "Ln("+this._exp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Ln.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Log10.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Log10.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Log10.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Log10.java Fri Jan 11 10:56:30 2008
@@ -1,124 +1,124 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Xiping Wang
- * @modified Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class Log10 extends SingleArgumentExpression implements
- NumericExpression
-{
-
- public static final String className = Log10.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="Log10";
-
-
-
- public Log10(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Log10");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Log10");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return log((Number) _exp.evaluate());
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public static Number log(Number o)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
-
- return new Double(Math.log(o.doubleValue()) / Math.log(10));
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
- {
- _dataType.setType(TypeConstants.doubleType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "Log10(" + this._exp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Xiping Wang
+ * @modified Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.NumericExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class Log10 extends SingleArgumentExpression implements
+ NumericExpression
+{
+
+ public static final String className = Log10.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="Log10";
+
+
+
+ public Log10(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "Log10");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "Log10");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return log((Number) _exp.evaluate());
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public static Number log(Number o)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "log");
+
+ return new Double(Math.log(o.doubleValue()) / Math.log(10));
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (!eType.getIsArray() && TypeResolver.isNumeric(eType))
+ {
+ _dataType.setType(TypeConstants.doubleType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "Log10(" + this._exp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/Log10.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java Fri Jan 11 10:56:30 2008
@@ -1,118 +1,118 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.BooleanExpression;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LogicalAnd extends DoubleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = LogicalAnd.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LogicalAnd";
-
-
-
- public LogicalAnd(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalAnd");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalAnd");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
- boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Boolean(left && right);
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo lType = _lhsExp.getType();
- TypeInfo rType = _rhsExp.getType();
-
- if (!lType.getIsArray() && !rType.getIsArray() &&
- TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = this._lhsExp.toString() + "&&" + this._rhsExp.toString();
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalAnd extends DoubleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = LogicalAnd.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LogicalAnd";
+
+
+
+ public LogicalAnd(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalAnd");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalAnd");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+ boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Boolean(left && right);
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo lType = _lhsExp.getType();
+ TypeInfo rType = _rhsExp.getType();
+
+ if (!lType.getIsArray() && !rType.getIsArray() &&
+ TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = this._lhsExp.toString() + "&&" + this._rhsExp.toString();
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java Fri Jan 11 10:56:30 2008
@@ -1,127 +1,127 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.BooleanExpression;
-import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LogicalNot extends SingleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = LogicalNot.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LogicalNot";
-
-
-
- public LogicalNot(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalNot");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalNot");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- if (((Boolean) _exp.evaluate()).booleanValue()){
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
- return Boolean.FALSE;
-
- }
-
- else
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (!eType.getIsArray() && TypeResolver.isBoolean(eType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "LogicalNot("+this._exp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalNot extends SingleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = LogicalNot.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LogicalNot";
+
+
+
+ public LogicalNot(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalNot");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalNot");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ if (((Boolean) _exp.evaluate()).booleanValue()){
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+ return Boolean.FALSE;
+
+ }
+
+ else
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (!eType.getIsArray() && TypeResolver.isBoolean(eType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "LogicalNot("+this._exp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalNot.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.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.BooleanExpression;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LogicalOr extends DoubleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = LogicalOr.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LogicalOr";
-
-
-
- public LogicalOr(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- //System.out.println("Logical OR::LHS type: RHS type ::"+ lhsExp.getType() + ":" + rhsExp.getType());
- boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
- boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
- //System.out.println("Logical OR::after Evaluation LHS: RHS ::"+ left + ":" + right);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Boolean(left || right);
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo lType = _lhsExp.getType();
- TypeInfo rType = _rhsExp.getType();
- //System.out.println("Logical OR:validate:TypeResolver.isBoolean(lType)"+ TypeResolver.isBoolean(lType));
- //System.out.println("Logical OR:validate:TypeResolver.isBoolean(rType)"+ TypeResolver.isBoolean(rType));
-
- if (!lType.getIsArray() && !rType.getIsArray() &&
- TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = this._lhsExp.toString() + " || " + this._rhsExp.toString();
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <pr...@in.ibm.com>
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalOr extends DoubleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = LogicalOr.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LogicalOr";
+
+
+
+ public LogicalOr(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalOr");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ //System.out.println("Logical OR::LHS type: RHS type ::"+ lhsExp.getType() + ":" + rhsExp.getType());
+ boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+ boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+ //System.out.println("Logical OR::after Evaluation LHS: RHS ::"+ left + ":" + right);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Boolean(left || right);
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo lType = _lhsExp.getType();
+ TypeInfo rType = _rhsExp.getType();
+ //System.out.println("Logical OR:validate:TypeResolver.isBoolean(lType)"+ TypeResolver.isBoolean(lType));
+ //System.out.println("Logical OR:validate:TypeResolver.isBoolean(rType)"+ TypeResolver.isBoolean(rType));
+
+ if (!lType.getIsArray() && !rType.getIsArray() &&
+ TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = this._lhsExp.toString() + " || " + this._rhsExp.toString();
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.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 Neeraj Joshi
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.BooleanExpression;
-import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LogicalXor extends DoubleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = LogicalXor.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LogicalXor";
-
-
-
- public LogicalXor(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalXor");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalXor");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
- boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
- boolean result = false;
- if ((left && !right) || (!left && right))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- result = true;
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Boolean(result);
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo lType = _lhsExp.getType();
- TypeInfo rType = _rhsExp.getType();
-
- if (!lType.getIsArray() && !rType.getIsArray() &&
- TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "LogicalXor("+this._lhsExp.toString() + "," + this._rhsExp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-}
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi
+ *
+ */
+package org.apache.imperius.spl.parser.expressions.impl;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.expressions.BooleanExpression;
+import org.apache.imperius.spl.parser.expressions.DoubleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class LogicalXor extends DoubleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = LogicalXor.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LogicalXor";
+
+
+
+ public LogicalXor(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LogicalXor");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LogicalXor");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
+ boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+ boolean result = false;
+ if ((left && !right) || (!left && right))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ result = true;
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Boolean(result);
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo lType = _lhsExp.getType();
+ TypeInfo rType = _rhsExp.getType();
+
+ if (!lType.getIsArray() && !rType.getIsArray() &&
+ TypeResolver.isBoolean(lType) && TypeResolver.isBoolean(rType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "LogicalXor("+this._lhsExp.toString() + "," + this._rhsExp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalXor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LongConstant.java Fri Jan 11 10:56:30 2008
@@ -1,103 +1,103 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <pr...@in.ibm.com>
- *
- */
-package org.apache.imperius.spl.parser.expressions.impl;
-
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.TypeConstants;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.expressions.ConstantExpression;
-import org.apache.imperius.spl.parser.expressions.NumericExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class LongConstant extends ConstantExpression implements
- NumericExpression
-{
-
- private long _longValue;
-
- private TypeInfo _dataType=new TypeInfo();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="LongConstant";
-
-
-
- public boolean isArray()
- {
-
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
-
- return _dataType.getIsArray();
- }
-
- public LongConstant(long val)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
-
- this._longValue = val;
- _dataType.setType(TypeConstants.longType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return new Long(_longValue);
- }
- 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 = Long.toString(this._longValue);
- 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.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 LongConstant extends ConstantExpression implements
+ NumericExpression
+{
+
+ private long _longValue;
+
+ private TypeInfo _dataType=new TypeInfo();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="LongConstant";
+
+
+
+ public boolean isArray()
+ {
+
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "isArray");
+
+ return _dataType.getIsArray();
+ }
+
+ public LongConstant(long val)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
+
+ this._longValue = val;
+ _dataType.setType(TypeConstants.longType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "LongConstant");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return new Long(_longValue);
+ }
+ 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 = Long.toString(this._longValue);
+ 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/LongConstant.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/MatchesRegExp.java Fri Jan 11 10:56:30 2008
@@ -1,129 +1,129 @@
-/*
- * 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 java.util.regex.Pattern;
-
-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 MatchesRegExp extends DoubleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = MatchesRegExp.class.getName();
-
- private Pattern _regex = null;
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="MatchesRegExp";
-
-
-
- public MatchesRegExp(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MatchesRegExp");
-
- 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()+" "+ "MatchesRegExp");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- String string = (String) _lhsExp.evaluate();
- Pattern pattern = null;
- if (_regex == null)
- { // need to precompile the regex
- pattern = Pattern.compile((String) _rhsExp.evaluate());
- }
- else
- { // regex precompiled during construction
- pattern = _regex;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.valueOf(pattern.matcher(string).matches());
- }
- 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 lType = _lhsExp.getType();
- TypeInfo rType = _rhsExp.getType();
-
- if (!lType.getIsArray() && !rType.getIsArray() &&
- TypeResolver.isString(lType) && TypeResolver.isString(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 = "MatchesRegExp("+this._lhsExp.toString()+","+ this._rhsExp.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 java.util.regex.Pattern;
+
+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 MatchesRegExp extends DoubleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = MatchesRegExp.class.getName();
+
+ private Pattern _regex = null;
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="MatchesRegExp";
+
+
+
+ public MatchesRegExp(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "MatchesRegExp");
+
+ 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()+" "+ "MatchesRegExp");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ String string = (String) _lhsExp.evaluate();
+ Pattern pattern = null;
+ if (_regex == null)
+ { // need to precompile the regex
+ pattern = Pattern.compile((String) _rhsExp.evaluate());
+ }
+ else
+ { // regex precompiled during construction
+ pattern = _regex;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.valueOf(pattern.matcher(string).matches());
+ }
+ 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 lType = _lhsExp.getType();
+ TypeInfo rType = _rhsExp.getType();
+
+ if (!lType.getIsArray() && !rType.getIsArray() &&
+ TypeResolver.isString(lType) && TypeResolver.isString(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 = "MatchesRegExp("+this._lhsExp.toString()+","+ this._rhsExp.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/MatchesRegExp.java
------------------------------------------------------------------------------
svn:eol-style = native