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 [15/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/ContainsOnlyDigits.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyDigits.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyDigits.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyDigits.java Fri Jan 11 10:56:30 2008
@@ -1,132 +1,132 @@
-/*
- * 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.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 ContainsOnlyDigits extends SingleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = ContainsOnlyDigits.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="ContainsOnlyDigits";
-
-
-
- public ContainsOnlyDigits(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyDigits");
-
- 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()+" "+ "ContainsOnlyDigits");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- String s0 = (String) _exp.evaluate();
-
- if (s0.length() == 0)
- {
- return Boolean.TRUE;
- }
-
- for (int i = 0; i < s0.length(); i++)
- {
- if (!Character.isDigit(s0.charAt(i)))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.FALSE;
- }
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (TypeResolver.isString(eType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "ContainsOnlyDigits( "+ 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.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 ContainsOnlyDigits extends SingleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = ContainsOnlyDigits.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="ContainsOnlyDigits";
+
+
+
+ public ContainsOnlyDigits(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyDigits");
+
+ 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()+" "+ "ContainsOnlyDigits");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ String s0 = (String) _exp.evaluate();
+
+ if (s0.length() == 0)
+ {
+ return Boolean.TRUE;
+ }
+
+ for (int i = 0; i < s0.length(); i++)
+ {
+ if (!Character.isDigit(s0.charAt(i)))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.FALSE;
+ }
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (TypeResolver.isString(eType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "ContainsOnlyDigits( "+ 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/ContainsOnlyDigits.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java Fri Jan 11 10:56:30 2008
@@ -1,133 +1,133 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <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.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class ContainsOnlyLetters extends SingleArgumentExpression implements
- BooleanExpression
-{
-
- public static final String className = ContainsOnlyLetters.class.getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="ContainsOnlyLetters";
-
-
-
- public ContainsOnlyLetters(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLetters");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLetters");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- String s0 = (String) _exp.evaluate();
-
- if (s0.length() == 0)
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
-
- for (int i = 0; i < s0.length(); i++)
- {
- if (!Character.isLetter(s0.charAt(i)))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.FALSE;
- }
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (TypeResolver.isString(eType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "ContainsOnlyLetters("+ this._exp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-
-}
+/*
+ * 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.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ContainsOnlyLetters extends SingleArgumentExpression implements
+ BooleanExpression
+{
+
+ public static final String className = ContainsOnlyLetters.class.getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="ContainsOnlyLetters";
+
+
+
+ public ContainsOnlyLetters(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLetters");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLetters");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ String s0 = (String) _exp.evaluate();
+
+ if (s0.length() == 0)
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+
+ for (int i = 0; i < s0.length(); i++)
+ {
+ if (!Character.isLetter(s0.charAt(i)))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.FALSE;
+ }
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (TypeResolver.isString(eType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "ContainsOnlyLetters("+ this._exp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLetters.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java Fri Jan 11 10:56:30 2008
@@ -1,133 +1,133 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-//
-
-/**
- * @author Prashant Baliga <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.SingleArgumentExpression;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class ContainsOnlyLettersOrDigits extends SingleArgumentExpression
- implements BooleanExpression
-{
-
- public static final String className = ContainsOnlyLettersOrDigits.class
- .getName();
-
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="ContainsOnlyLettersOrDigits";
-
-
-
- public ContainsOnlyLettersOrDigits(List exprList, boolean validateExpression)
- throws SPLException
- {
- super(exprList);
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLettersOrDigits");
-
- if (validateExpression)
- {
- if (!validate())
- {
- logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
- + " has wrong data type passed in.");
-
- throw new SPLException("validation error: " + className
- + " has wrong data type passed in.");
- }
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLettersOrDigits");
-
- }
-
- public Object evaluate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- try
- {
- String s0 = (String) _exp.evaluate();
-
- if (s0.length() == 0)
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
-
- for (int i = 0; i < s0.length(); i++)
- {
- if (!Character.isLetterOrDigit(s0.charAt(i)))
- {
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.FALSE;
- }
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
-
- return Boolean.TRUE;
- }
- catch (Exception e)
- {
- logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
-
- throw new SPLException("evaluation error: " + e.toString());
- }
- }
-
- public boolean validate() throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- TypeInfo eType = _exp.getType();
-
- if (TypeResolver.isString(eType))
- {
- _dataType.setType(TypeConstants.booleanType);
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return true;
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
-
- return false;
- }
-
- public String toString()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- String str = "ContainsOnlyLettersOrDigits( "+ this._exp.toString() + ")";
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
-
- return str;
- }
-}
+/*
+ * 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.SingleArgumentExpression;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class ContainsOnlyLettersOrDigits extends SingleArgumentExpression
+ implements BooleanExpression
+{
+
+ public static final String className = ContainsOnlyLettersOrDigits.class
+ .getName();
+
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="ContainsOnlyLettersOrDigits";
+
+
+
+ public ContainsOnlyLettersOrDigits(List exprList, boolean validateExpression)
+ throws SPLException
+ {
+ super(exprList);
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLettersOrDigits");
+
+ if (validateExpression)
+ {
+ if (!validate())
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"validation error: " + className
+ + " has wrong data type passed in.");
+
+ throw new SPLException("validation error: " + className
+ + " has wrong data type passed in.");
+ }
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "ContainsOnlyLettersOrDigits");
+
+ }
+
+ public Object evaluate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ try
+ {
+ String s0 = (String) _exp.evaluate();
+
+ if (s0.length() == 0)
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+
+ for (int i = 0; i < s0.length(); i++)
+ {
+ if (!Character.isLetterOrDigit(s0.charAt(i)))
+ {
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.FALSE;
+ }
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
+
+ return Boolean.TRUE;
+ }
+ catch (Exception e)
+ {
+ logger.severe(Thread.currentThread().getName()+" "+"evaluation error: " + e.toString());
+
+ throw new SPLException("evaluation error: " + e.toString());
+ }
+ }
+
+ public boolean validate() throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ TypeInfo eType = _exp.getType();
+
+ if (TypeResolver.isString(eType))
+ {
+ _dataType.setType(TypeConstants.booleanType);
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return true;
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+ return false;
+ }
+
+ public String toString()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ String str = "ContainsOnlyLettersOrDigits( "+ this._exp.toString() + ")";
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "toString");
+
+ return str;
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/ContainsOnlyLettersOrDigits.java
------------------------------------------------------------------------------
svn:eol-style = native