tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r1037284 [2/12] - in /tomcat/taglibs/standard/trunk/jstlel: ./ src/main/java/org/apache/taglibs/standard/lang/jstl/ src/main/java/org/apache/taglibs/standard/lang/jstl/parser/ src/main/java/org/apache/taglibs/standard/lang/support/ src/main...
Date Sat, 20 Nov 2010 18:14:04 GMT
Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BinaryOperatorExpression.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BinaryOperatorExpression.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BinaryOperatorExpression.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BinaryOperatorExpression.java Sat Nov 20 18:14:00 2010
@@ -13,7 +13,7 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
@@ -21,119 +21,126 @@ import java.util.List;
 import java.util.Map;
 
 /**
- *
  * <p>An expression representing a binary operator on a value
- * 
+ *
  * @author Nathan Abramson - Art Technology Group
  * @author Shawn Bayern
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
 public class BinaryOperatorExpression
-  extends Expression
-{
-  //-------------------------------------
-  // Properties
-  //-------------------------------------
-  // property expression
-
-  Expression mExpression;
-  public Expression getExpression ()
-  { return mExpression; }
-  public void setExpression (Expression pExpression)
-  { mExpression = pExpression; }
-
-  //-------------------------------------
-  // property operators
-
-  List mOperators;
-  public List getOperators ()
-  { return mOperators; }
-  public void setOperators (List pOperators)
-  { mOperators = pOperators; }
-
-  //-------------------------------------
-  // property expressions
-
-  List mExpressions;
-  public List getExpressions ()
-  { return mExpressions; }
-  public void setExpressions (List pExpressions)
-  { mExpressions = pExpressions; }
-
-  //-------------------------------------
-  /**
-   *
-   * Constructor
-   **/
-  public BinaryOperatorExpression (Expression pExpression,
-				   List pOperators,
-				   List pExpressions)
-  {
-    mExpression = pExpression;
-    mOperators = pOperators;
-    mExpressions = pExpressions;
-  }
-
-  //-------------------------------------
-  // Expression methods
-  //-------------------------------------
-  /**
-   *
-   * Returns the expression in the expression language syntax
-   **/
-  public String getExpressionString ()
-  {
-    StringBuffer buf = new StringBuffer ();
-    buf.append ("(");
-    buf.append (mExpression.getExpressionString ());
-    for (int i = 0; i < mOperators.size (); i++) {
-      BinaryOperator operator = (BinaryOperator) mOperators.get (i);
-      Expression expression = (Expression) mExpressions.get (i);
-      buf.append (" ");
-      buf.append (operator.getOperatorSymbol ());
-      buf.append (" ");
-      buf.append (expression.getExpressionString ());
-    }
-    buf.append (")");
-
-    return buf.toString ();
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Evaluates to the literal value
-   **/
-  public Object evaluate (Object pContext,
-			  VariableResolver pResolver,
-			  Map functions,
-			  String defaultPrefix,
-			  Logger pLogger)
-    throws ELException
-  {
-    Object value = mExpression.evaluate (pContext, pResolver, functions,
-					 defaultPrefix, pLogger);
-    for (int i = 0; i < mOperators.size (); i++) {
-      BinaryOperator operator = (BinaryOperator) mOperators.get (i);
-
-      // For the And/Or operators, we need to coerce to a boolean
-      // before testing if we shouldEvaluate
-      if (operator.shouldCoerceToBoolean ()) {
-	value = Coercions.coerceToBoolean (value, pLogger);
-      }
-
-      if (operator.shouldEvaluate (value)) {
-	Expression expression = (Expression) mExpressions.get (i);
-	Object nextValue = expression.evaluate (pContext, pResolver,
-						functions, defaultPrefix,
-						pLogger);
+        extends Expression {
+    //-------------------------------------
+    // Properties
+    //-------------------------------------
+    // property expression
+
+    Expression mExpression;
+
+    public Expression getExpression() {
+        return mExpression;
+    }
+
+    public void setExpression(Expression pExpression) {
+        mExpression = pExpression;
+    }
+
+    //-------------------------------------
+    // property operators
+
+    List mOperators;
+
+    public List getOperators() {
+        return mOperators;
+    }
+
+    public void setOperators(List pOperators) {
+        mOperators = pOperators;
+    }
+
+    //-------------------------------------
+    // property expressions
+
+    List mExpressions;
+
+    public List getExpressions() {
+        return mExpressions;
+    }
+
+    public void setExpressions(List pExpressions) {
+        mExpressions = pExpressions;
+    }
+
+    //-------------------------------------
+
+    /**
+     * Constructor
+     */
+    public BinaryOperatorExpression(Expression pExpression,
+                                    List pOperators,
+                                    List pExpressions) {
+        mExpression = pExpression;
+        mOperators = pOperators;
+        mExpressions = pExpressions;
+    }
+
+    //-------------------------------------
+    // Expression methods
+    //-------------------------------------
+
+    /**
+     * Returns the expression in the expression language syntax
+     */
+    public String getExpressionString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("(");
+        buf.append(mExpression.getExpressionString());
+        for (int i = 0; i < mOperators.size(); i++) {
+            BinaryOperator operator = (BinaryOperator) mOperators.get(i);
+            Expression expression = (Expression) mExpressions.get(i);
+            buf.append(" ");
+            buf.append(operator.getOperatorSymbol());
+            buf.append(" ");
+            buf.append(expression.getExpressionString());
+        }
+        buf.append(")");
+
+        return buf.toString();
+    }
+
+    //-------------------------------------
 
-	value = operator.apply (value, nextValue, pContext, pLogger);
-      }
+    /**
+     * Evaluates to the literal value
+     */
+    public Object evaluate(Object pContext,
+                           VariableResolver pResolver,
+                           Map functions,
+                           String defaultPrefix,
+                           Logger pLogger)
+            throws ELException {
+        Object value = mExpression.evaluate(pContext, pResolver, functions,
+                defaultPrefix, pLogger);
+        for (int i = 0; i < mOperators.size(); i++) {
+            BinaryOperator operator = (BinaryOperator) mOperators.get(i);
+
+            // For the And/Or operators, we need to coerce to a boolean
+            // before testing if we shouldEvaluate
+            if (operator.shouldCoerceToBoolean()) {
+                value = Coercions.coerceToBoolean(value, pLogger);
+            }
+
+            if (operator.shouldEvaluate(value)) {
+                Expression expression = (Expression) mExpressions.get(i);
+                Object nextValue = expression.evaluate(pContext, pResolver,
+                        functions, defaultPrefix,
+                        pLogger);
+
+                value = operator.apply(value, nextValue, pContext, pLogger);
+            }
+        }
+        return value;
     }
-    return value;
-  }
 
-  //-------------------------------------
+    //-------------------------------------
 }

Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BooleanLiteral.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BooleanLiteral.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BooleanLiteral.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/BooleanLiteral.java Sat Nov 20 18:14:00 2010
@@ -13,62 +13,57 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
 /**
- *
  * <p>An expression representing a boolean literal value
- * 
+ *
  * @author Nathan Abramson - Art Technology Group
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
 public class BooleanLiteral
-  extends Literal
-{
-  //-------------------------------------
-  // Member variables
-  //-------------------------------------
-
-  public static final BooleanLiteral TRUE = new BooleanLiteral ("true");
-  public static final BooleanLiteral FALSE = new BooleanLiteral ("false");
-
-  //-------------------------------------
-  /**
-   *
-   * Constructor
-   **/
-  public BooleanLiteral (String pToken)
-  {
-    super (getValueFromToken (pToken));
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Parses the given token into the literal value
-   **/
-  static Object getValueFromToken (String pToken)
-  {
-    return
-      ("true".equals (pToken)) ?
-      Boolean.TRUE :
-      Boolean.FALSE;
-  }
-
-  //-------------------------------------
-  // Expression methods
-  //-------------------------------------
-  /**
-   *
-   * Returns the expression in the expression language syntax
-   **/
-  public String getExpressionString ()
-  {
-    return (getValue () == Boolean.TRUE) ? "true" : "false";
-  }
+        extends Literal {
+    //-------------------------------------
+    // Member variables
+    //-------------------------------------
+
+    public static final BooleanLiteral TRUE = new BooleanLiteral("true");
+    public static final BooleanLiteral FALSE = new BooleanLiteral("false");
+
+    //-------------------------------------
+
+    /**
+     * Constructor
+     */
+    public BooleanLiteral(String pToken) {
+        super(getValueFromToken(pToken));
+    }
+
+    //-------------------------------------
+
+    /**
+     * Parses the given token into the literal value
+     */
+    static Object getValueFromToken(String pToken) {
+        return
+                ("true".equals(pToken)) ?
+                        Boolean.TRUE :
+                        Boolean.FALSE;
+    }
+
+    //-------------------------------------
+    // Expression methods
+    //-------------------------------------
+
+    /**
+     * Returns the expression in the expression language syntax
+     */
+    public String getExpressionString() {
+        return (getValue() == Boolean.TRUE) ? "true" : "false";
+    }
 
-  //-------------------------------------
+    //-------------------------------------
 }

Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Coercions.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Coercions.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Coercions.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Coercions.java Sat Nov 20 18:14:00 2010
@@ -13,7 +13,7 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
@@ -21,13 +21,12 @@ import java.beans.PropertyEditor;
 import java.beans.PropertyEditorManager;
 
 /**
- *
  * <p>This class contains the logic for coercing data types before
  * operators are applied to them.
- *
+ * <p/>
  * <p>The following is the list of rules applied for various type
  * conversions.
- *
+ * <p/>
  * <ul><pre>
  * Applying arithmetic operator
  *   Binary operator - A {+,-,*} B
@@ -40,7 +39,7 @@ import java.beans.PropertyEditorManager;
  *       coerce both A and B to Long
  *       apply operator
  *     if operator results in exception (such as divide by 0), error
- * 
+ * <p/>
  *   Binary operator - A {/,div} B
  *     if A and B are null
  *       return 0
@@ -48,7 +47,7 @@ import java.beans.PropertyEditorManager;
  *       coerce both A and B to Double
  *       apply operator
  *     if operator results in exception (such as divide by 0), error
- * 
+ * <p/>
  *   Binary operator - A {%,mod} B
  *     if A and B are null
  *       return 0
@@ -59,7 +58,7 @@ import java.beans.PropertyEditorManager;
  *       coerce both A and B to Long
  *       apply operator
  *     if operator results in exception (such as divide by 0), error
- * 
+ * <p/>
  *   Unary minus operator - -A
  *     if A is null
  *       return 0
@@ -73,7 +72,7 @@ import java.beans.PropertyEditorManager;
  *     if operator results in exception, error
  *     otherwise
  *       error
- *
+ * <p/>
  * Applying "empty" operator - empty A
  *   if A is null
  *     return true
@@ -87,7 +86,7 @@ import java.beans.PropertyEditorManager;
  *     return true
  *   otherwise
  *     return false
- * 
+ * <p/>
  * Applying logical operators
  *   Binary operator - A {and,or} B
  *     coerce both A and B to Boolean, apply operator
@@ -95,7 +94,7 @@ import java.beans.PropertyEditorManager;
  *     A and B and C and D - if B is false, then only A and B is evaluated
  *   Unary not operator - not A
  *     coerce A to Boolean, apply operator
- * 
+ * <p/>
  * Applying relational operator
  *   A {<,>,<=,>=,lt,gt,lte,gte} B
  *     if A==B
@@ -125,7 +124,7 @@ import java.beans.PropertyEditorManager;
  *         use result of B.compareTo(A)
  *     otherwise
  *       error
- * 
+ * <p/>
  * Applying equality operator
  *   A {==,!=} B
  *     if A==B
@@ -147,9 +146,9 @@ import java.beans.PropertyEditorManager;
  *       if an error occurs while calling A.equals(B)
  *         error
  *       apply operator to result of A.equals(B)
- * 
+ * <p/>
  * coercions
- * 
+ * <p/>
  *   coerce A to String
  *     A is String
  *       return A
@@ -159,7 +158,7 @@ import java.beans.PropertyEditorManager;
  *       error
  *     otherwise
  *       return A.toString
- * 
+ * <p/>
  *   coerce A to primitive Number type N
  *     A is null or ""
  *       return 0
@@ -179,7 +178,7 @@ import java.beans.PropertyEditorManager;
  *       return N.valueOf(A)
  *     otherwise
  *       error
- * 
+ * <p/>
  *   coerce A to Character should be
  *     A is null or ""
  *       return (char) 0
@@ -195,7 +194,7 @@ import java.beans.PropertyEditorManager;
  *       return A.charAt (0)
  *     otherwise
  *       error
- * 
+ * <p/>
  *   coerce A to Boolean
  *     A is null or ""
  *       return false
@@ -207,7 +206,7 @@ import java.beans.PropertyEditorManager;
  *       return Boolean.valueOf(A)
  *     otherwise
  *       error
- * 
+ * <p/>
  *   coerce A to any other type T
  *     A is null
  *       return null
@@ -228,798 +227,695 @@ import java.beans.PropertyEditorManager;
  *
  * @author Nathan Abramson - Art Technology Group
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
+
+public class Coercions {
+    //-------------------------------------
 
-public class Coercions
-{
-  //-------------------------------------
-  /**
-   *
-   * Coerces the given value to the specified class.
-   **/
-  public static Object coerce (Object pValue,
-			       Class pClass,
-			       Logger pLogger)
-    throws ELException
-  {
-    if (pClass == String.class) {
-      return coerceToString (pValue, pLogger);
-    }
-    else if (isPrimitiveNumberClass (pClass)) {
-      return coerceToPrimitiveNumber (pValue, pClass, pLogger);
-    }
-    else if (pClass == Character.class ||
-	     pClass == Character.TYPE) {
-      return coerceToCharacter (pValue, pLogger);
-    }
-    else if (pClass == Boolean.class ||
-	     pClass == Boolean.TYPE) {
-      return coerceToBoolean (pValue, pLogger);
-    }
-    else {
-      return coerceToObject (pValue, pClass, pLogger);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given class is Byte, Short, Integer, Long,
-   * Float, Double
-   **/
-  static boolean isPrimitiveNumberClass (Class pClass)
-  {
-    return
-      pClass == Byte.class ||
-      pClass == Byte.TYPE ||
-      pClass == Short.class ||
-      pClass == Short.TYPE ||
-      pClass == Integer.class ||
-      pClass == Integer.TYPE ||
-      pClass == Long.class ||
-      pClass == Long.TYPE ||
-      pClass == Float.class ||
-      pClass == Float.TYPE ||
-      pClass == Double.class ||
-      pClass == Double.TYPE;
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces the specified value to a String
-   **/
-  public static String coerceToString (Object pValue,
-				       Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null) {
-      return "";
-    }
-    else if (pValue instanceof String) {
-      return (String) pValue;
-    }
-    else {
-      try {
-	return pValue.toString ();
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError (Constants.TOSTRING_EXCEPTION,
-			    exc,
-			    pValue.getClass ().getName ());
-	}
-	return "";
-      }
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a value to the given primitive number class
-   **/
-  public static Number coerceToPrimitiveNumber (Object pValue,
-						Class pClass,
-						Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null ||
-	"".equals (pValue)) {
-      return coerceToPrimitiveNumber (0, pClass);
-    }
-    else if (pValue instanceof Character) {
-      char val = ((Character) pValue).charValue ();
-      return coerceToPrimitiveNumber ((short) val, pClass);
-    }
-    else if (pValue instanceof Boolean) {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError (Constants.BOOLEAN_TO_NUMBER,
-			  pValue,
-			  pClass.getName ());
-      }
-      return coerceToPrimitiveNumber (0, pClass);
-    }
-    else if (pValue.getClass () == pClass) {
-      return (Number) pValue;
-    }
-    else if (pValue instanceof Number) {
-      return coerceToPrimitiveNumber ((Number) pValue, pClass);
-    }
-    else if (pValue instanceof String) {
-      try {
-	return coerceToPrimitiveNumber ((String) pValue, pClass);
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError
-	    (Constants.STRING_TO_NUMBER_EXCEPTION,
-	     (String) pValue,
-	     pClass.getName ());
-	}
-	return coerceToPrimitiveNumber (0, pClass);
-      }
-    }
-    else {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.COERCE_TO_NUMBER,
-	   pValue.getClass ().getName (),
-	   pClass.getName ());
-      }
-      return coerceToPrimitiveNumber (0, pClass);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a value to an Integer, returning null if the coercion
-   * isn't possible.
-   **/
-  public static Integer coerceToInteger (Object pValue,
-					 Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null) {
-      return null;
-    }
-    else if (pValue instanceof Character) {
-      return PrimitiveObjects.getInteger 
-	((int) (((Character) pValue).charValue ()));
-    }
-    else if (pValue instanceof Boolean) {
-      if (pLogger.isLoggingWarning ()) {
-	pLogger.logWarning (Constants.BOOLEAN_TO_NUMBER,
-			    pValue,
-			    Integer.class.getName ());
-      }
-      return PrimitiveObjects.getInteger
-	(((Boolean) pValue).booleanValue () ? 1 : 0);
-    }
-    else if (pValue instanceof Integer) {
-      return (Integer) pValue;
-    }
-    else if (pValue instanceof Number) {
-      return PrimitiveObjects.getInteger (((Number) pValue).intValue ());
-    }
-    else if (pValue instanceof String) {
-      try {
-	return Integer.valueOf ((String) pValue);
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingWarning ()) {
-	  pLogger.logWarning
-	    (Constants.STRING_TO_NUMBER_EXCEPTION,
-	     (String) pValue,
-	     Integer.class.getName ());
-	}
-	return null;
-      }
-    }
-    else {
-      if (pLogger.isLoggingWarning ()) {
-	pLogger.logWarning
-	  (Constants.COERCE_TO_NUMBER,
-	   pValue.getClass ().getName (),
-	   Integer.class.getName ());
-      }
-      return null;
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a long to the given primitive number class
-   **/
-  static Number coerceToPrimitiveNumber (long pValue,
-					 Class pClass)
-    throws ELException
-  {
-    if (pClass == Byte.class || pClass == Byte.TYPE) {
-      return PrimitiveObjects.getByte ((byte) pValue);
-    }
-    else if (pClass == Short.class || pClass == Short.TYPE) {
-      return PrimitiveObjects.getShort ((short) pValue);
-    }
-    else if (pClass == Integer.class || pClass == Integer.TYPE) {
-      return PrimitiveObjects.getInteger ((int) pValue);
-    }
-    else if (pClass == Long.class || pClass == Long.TYPE) {
-      return PrimitiveObjects.getLong ((long) pValue);
-    }
-    else if (pClass == Float.class || pClass == Float.TYPE) {
-      return PrimitiveObjects.getFloat ((float) pValue);
-    }
-    else if (pClass == Double.class || pClass == Double.TYPE) {
-      return PrimitiveObjects.getDouble ((double) pValue);
-    }
-    else {
-      return PrimitiveObjects.getInteger (0);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a double to the given primitive number class
-   **/
-  static Number coerceToPrimitiveNumber (double pValue,
-					 Class pClass)
-    throws ELException
-  {
-    if (pClass == Byte.class || pClass == Byte.TYPE) {
-      return PrimitiveObjects.getByte ((byte) pValue);
-    }
-    else if (pClass == Short.class || pClass == Short.TYPE) {
-      return PrimitiveObjects.getShort ((short) pValue);
-    }
-    else if (pClass == Integer.class || pClass == Integer.TYPE) {
-      return PrimitiveObjects.getInteger ((int) pValue);
-    }
-    else if (pClass == Long.class || pClass == Long.TYPE) {
-      return PrimitiveObjects.getLong ((long) pValue);
-    }
-    else if (pClass == Float.class || pClass == Float.TYPE) {
-      return PrimitiveObjects.getFloat ((float) pValue);
-    }
-    else if (pClass == Double.class || pClass == Double.TYPE) {
-      return PrimitiveObjects.getDouble ((double) pValue);
-    }
-    else {
-      return PrimitiveObjects.getInteger (0);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a Number to the given primitive number class
-   **/
-  static Number coerceToPrimitiveNumber (Number pValue,
-					 Class pClass)
-    throws ELException
-  {
-    if (pClass == Byte.class || pClass == Byte.TYPE) {
-      return PrimitiveObjects.getByte (pValue.byteValue ());
-    }
-    else if (pClass == Short.class || pClass == Short.TYPE) {
-      return PrimitiveObjects.getShort (pValue.shortValue ());
-    }
-    else if (pClass == Integer.class || pClass == Integer.TYPE) {
-      return PrimitiveObjects.getInteger (pValue.intValue ());
-    }
-    else if (pClass == Long.class || pClass == Long.TYPE) {
-      return PrimitiveObjects.getLong (pValue.longValue ());
-    }
-    else if (pClass == Float.class || pClass == Float.TYPE) {
-      return PrimitiveObjects.getFloat (pValue.floatValue ());
-    }
-    else if (pClass == Double.class || pClass == Double.TYPE) {
-      return PrimitiveObjects.getDouble (pValue.doubleValue ());
-    }
-    else {
-      return PrimitiveObjects.getInteger (0);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a String to the given primitive number class
-   **/
-  static Number coerceToPrimitiveNumber (String pValue,
-					 Class pClass)
-    throws ELException
-  {
-    if (pClass == Byte.class || pClass == Byte.TYPE) {
-      return Byte.valueOf (pValue);
-    }
-    else if (pClass == Short.class || pClass == Short.TYPE) {
-      return Short.valueOf (pValue);
-    }
-    else if (pClass == Integer.class || pClass == Integer.TYPE) {
-      return Integer.valueOf (pValue);
-    }
-    else if (pClass == Long.class || pClass == Long.TYPE) {
-      return Long.valueOf (pValue);
-    }
-    else if (pClass == Float.class || pClass == Float.TYPE) {
-      return Float.valueOf (pValue);
-    }
-    else if (pClass == Double.class || pClass == Double.TYPE) {
-      return Double.valueOf (pValue);
-    }
-    else {
-      return PrimitiveObjects.getInteger (0);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a value to a Character
-   **/
-  public static Character coerceToCharacter (Object pValue,
-					     Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null ||
-	"".equals (pValue)) {
-      return PrimitiveObjects.getCharacter ((char) 0);
-    }
-    else if (pValue instanceof Character) {
-      return (Character) pValue;
-    }
-    else if (pValue instanceof Boolean) {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError (Constants.BOOLEAN_TO_CHARACTER, pValue);
-      }
-      return PrimitiveObjects.getCharacter ((char) 0);
-    }
-    else if (pValue instanceof Number) {
-      return PrimitiveObjects.getCharacter 
-	((char) ((Number) pValue).shortValue ());
-    }
-    else if (pValue instanceof String) {
-      String str = (String) pValue;
-      return PrimitiveObjects.getCharacter (str.charAt (0));
-    }
-    else {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.COERCE_TO_CHARACTER,
-	   pValue.getClass ().getName ());
-      }
-      return PrimitiveObjects.getCharacter ((char) 0);
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a value to a Boolean
-   **/
-  public static Boolean coerceToBoolean (Object pValue,
-					 Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null ||
-	"".equals (pValue)) {
-      return Boolean.FALSE;
-    }
-    else if (pValue instanceof Boolean) {
-      return (Boolean) pValue;
-    }
-    else if (pValue instanceof String) {
-      String str = (String) pValue;
-      try {
-	return Boolean.valueOf (str);
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError
-	    (Constants.STRING_TO_BOOLEAN,
-	     exc,
-	     (String) pValue);
-	}
-	return Boolean.FALSE;
-      }
-    }
-    else {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.COERCE_TO_BOOLEAN,
-	   pValue.getClass ().getName ());
-      }
-      return Boolean.TRUE;
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Coerces a value to the specified Class that is not covered by any
-   * of the above cases
-   **/
-  public static Object coerceToObject (Object pValue,
-				       Class pClass,
-				       Logger pLogger)
-    throws ELException
-  {
-    if (pValue == null) {
-      return null;
-    }
-    else if (pClass.isAssignableFrom (pValue.getClass ())) {
-      return pValue;
-    }
-    else if (pValue instanceof String) {
-      String str = (String) pValue;
-      PropertyEditor pe = PropertyEditorManager.findEditor (pClass);
-      if (pe == null) {
-	if ("".equals (str)) {
-	  return null;
-	}
-	else {
-	  if (pLogger.isLoggingError ()) {
-	    pLogger.logError
-	      (Constants.NO_PROPERTY_EDITOR,
-	       str,
-	       pClass.getName ());
-	  }
-	  return null;
-	}
-      }
-      try {
-	pe.setAsText (str);
-	return pe.getValue ();
-      }
-      catch (IllegalArgumentException exc) {
-	if ("".equals (str)) {
-	  return null;
-	}
-	else {
-	  if (pLogger.isLoggingError ()) {
-	    pLogger.logError
-	      (Constants.PROPERTY_EDITOR_ERROR,
-	       exc,
-	       pValue,
-	       pClass.getName ());
-	  }
-	  return null;
-	}
-      }
-    }
-    else {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.COERCE_TO_OBJECT,
-	   pValue.getClass ().getName (),
-	   pClass.getName ());
-      }
-      return null;
-    }
-  }
-
-  //-------------------------------------
-  // Applying operators
-  //-------------------------------------
-  /**
-   *
-   * Performs all of the necessary type conversions, then calls on the
-   * appropriate operator.
-   **/
-  public static Object applyArithmeticOperator 
-    (Object pLeft,
-     Object pRight,
-     ArithmeticOperator pOperator,
-     Logger pLogger)
-    throws ELException
-  {
-    if (pLeft == null &&
-	pRight == null) {
-      if (pLogger.isLoggingWarning ()) {
-	pLogger.logWarning
-	  (Constants.ARITH_OP_NULL,
-	   pOperator.getOperatorSymbol ());
-      }
-      return PrimitiveObjects.getInteger (0);
-    }
-
-    else if (isFloatingPointType (pLeft) ||
-	     isFloatingPointType (pRight) ||
-	     isFloatingPointString (pLeft) ||
-	     isFloatingPointString (pRight)) {
-      double left =
-	coerceToPrimitiveNumber (pLeft, Double.class, pLogger).
-	doubleValue ();
-      double right =
-	coerceToPrimitiveNumber (pRight, Double.class, pLogger).
-	doubleValue ();
-      return 
-	PrimitiveObjects.getDouble (pOperator.apply (left, right, pLogger));
-    }
-
-    else {
-      long left =
-	coerceToPrimitiveNumber (pLeft, Long.class, pLogger).
-	longValue ();
-      long right =
-	coerceToPrimitiveNumber (pRight, Long.class, pLogger).
-	longValue ();
-      return
-	PrimitiveObjects.getLong (pOperator.apply (left, right, pLogger));
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Performs all of the necessary type conversions, then calls on the
-   * appropriate operator.
-   **/
-  public static Object applyRelationalOperator 
-    (Object pLeft,
-     Object pRight,
-     RelationalOperator pOperator,
-     Logger pLogger)
-    throws ELException
-  {
-    if (isFloatingPointType (pLeft) ||
-	isFloatingPointType (pRight)) {
-      double left =
-	coerceToPrimitiveNumber (pLeft, Double.class, pLogger).
-	doubleValue ();
-      double right =
-	coerceToPrimitiveNumber (pRight, Double.class, pLogger).
-	doubleValue ();
-      return 
-	PrimitiveObjects.getBoolean (pOperator.apply (left, right, pLogger));
-    }
-
-    else if (isIntegerType (pLeft) ||
-	     isIntegerType (pRight)) {
-      long left =
-	coerceToPrimitiveNumber (pLeft, Long.class, pLogger).
-	longValue ();
-      long right =
-	coerceToPrimitiveNumber (pRight, Long.class, pLogger).
-	longValue ();
-      return
-	PrimitiveObjects.getBoolean (pOperator.apply (left, right, pLogger));
-    }
-
-    else if (pLeft instanceof String ||
-	     pRight instanceof String) {
-      String left = coerceToString (pLeft, pLogger);
-      String right = coerceToString (pRight, pLogger);
-      return
-	PrimitiveObjects.getBoolean (pOperator.apply (left, right, pLogger));
-    }
-
-    else if (pLeft instanceof Comparable) {
-      try {
-	int result = ((Comparable) pLeft).compareTo (pRight);
-	return
-	  PrimitiveObjects.getBoolean 
-	  (pOperator.apply (result, -result, pLogger));
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError
-	    (Constants.COMPARABLE_ERROR,
-	     exc,
-	     pLeft.getClass ().getName (),
-	     (pRight == null) ? "null" : pRight.getClass ().getName (),
-	     pOperator.getOperatorSymbol ());
-	}
-	return Boolean.FALSE;
-      }
-    }
-
-    else if (pRight instanceof Comparable) {
-      try {
-	int result = ((Comparable) pRight).compareTo (pLeft);
-	return
-	  PrimitiveObjects.getBoolean 
-	  (pOperator.apply (-result, result, pLogger));
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError
-	    (Constants.COMPARABLE_ERROR,
-	     exc,
-	     pRight.getClass ().getName (),
-	     (pLeft == null) ? "null" : pLeft.getClass ().getName (),
-	     pOperator.getOperatorSymbol ());
-	}
-	return Boolean.FALSE;
-      }
-    }
-
-    else {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.ARITH_OP_BAD_TYPE,
-	   pOperator.getOperatorSymbol (),
-	   pLeft.getClass ().getName (),
-	   pRight.getClass ().getName ());
-      }
-      return Boolean.FALSE;
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Performs all of the necessary type conversions, then calls on the
-   * appropriate operator.
-   **/
-  public static Object applyEqualityOperator 
-    (Object pLeft,
-     Object pRight,
-     EqualityOperator pOperator,
-     Logger pLogger)
-    throws ELException
-  {
-    if (pLeft == pRight) {
-      return PrimitiveObjects.getBoolean (pOperator.apply (true, pLogger));
-    }
-
-    else if (pLeft == null ||
-	     pRight == null) {
-      return PrimitiveObjects.getBoolean (pOperator.apply (false, pLogger));
-    }
-
-    else if (isFloatingPointType (pLeft) ||
-	     isFloatingPointType (pRight)) {
-      double left =
-	coerceToPrimitiveNumber (pLeft, Double.class, pLogger).
-	doubleValue ();
-      double right =
-	coerceToPrimitiveNumber (pRight, Double.class, pLogger).
-	doubleValue ();
-      return 
-	PrimitiveObjects.getBoolean 
-	(pOperator.apply (left == right, pLogger));
-    }
-
-    else if (isIntegerType (pLeft) ||
-	     isIntegerType (pRight)) {
-      long left =
-	coerceToPrimitiveNumber (pLeft, Long.class, pLogger).
-	longValue ();
-      long right =
-	coerceToPrimitiveNumber (pRight, Long.class, pLogger).
-	longValue ();
-      return
-	PrimitiveObjects.getBoolean 
-	(pOperator.apply (left == right, pLogger));
-    }
-
-    else if (pLeft instanceof Boolean ||
-	     pRight instanceof Boolean) {
-      boolean left = coerceToBoolean (pLeft, pLogger).booleanValue ();
-      boolean right = coerceToBoolean (pRight, pLogger).booleanValue ();
-      return
-	PrimitiveObjects.getBoolean 
-	(pOperator.apply (left == right, pLogger));
-    }
-
-    else if (pLeft instanceof String ||
-	     pRight instanceof String) {
-      String left = coerceToString (pLeft, pLogger);
-      String right = coerceToString (pRight, pLogger);
-      return
-	PrimitiveObjects.getBoolean 
-	(pOperator.apply (left.equals (right), pLogger));
-    }
-
-    else {
-      try {
-      return
-	PrimitiveObjects.getBoolean
-	(pOperator.apply (pLeft.equals (pRight), pLogger));
-      }
-      catch (Exception exc) {
-	if (pLogger.isLoggingError ()) {
-	  pLogger.logError
-	    (Constants.ERROR_IN_EQUALS,
-	     exc,
-	     pLeft.getClass ().getName (),
-	     pRight.getClass ().getName (),
-	     pOperator.getOperatorSymbol ());
-	}
-	return Boolean.FALSE;
-      }
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given Object is of a floating point type
-   **/
-  public static boolean isFloatingPointType (Object pObject)
-  {
-    return 
-      pObject != null &&
-      isFloatingPointType (pObject.getClass ());
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given class is of a floating point type
-   **/
-  public static boolean isFloatingPointType (Class pClass)
-  {
-    return
-      pClass == Float.class ||
-      pClass == Float.TYPE ||
-      pClass == Double.class ||
-      pClass == Double.TYPE;
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given string might contain a floating point
-   * number - i.e., it contains ".", "e", or "E"
-   **/
-  public static boolean isFloatingPointString (Object pObject)
-  {
-    if (pObject instanceof String) {
-      String str = (String) pObject;
-      int len = str.length ();
-      for (int i = 0; i < len; i++) {
-	char ch = str.charAt (i);
-	if (ch == '.' ||
-	    ch == 'e' ||
-	    ch == 'E') {
-	  return true;
-	}
-      }
-      return false;
-    }
-    else {
-      return false;
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given Object is of an integer type
-   **/
-  public static boolean isIntegerType (Object pObject)
-  {
-    return 
-      pObject != null &&
-      isIntegerType (pObject.getClass ());
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Returns true if the given class is of an integer type
-   **/
-  public static boolean isIntegerType (Class pClass)
-  {
-    return
-      pClass == Byte.class ||
-      pClass == Byte.TYPE ||
-      pClass == Short.class ||
-      pClass == Short.TYPE ||
-      pClass == Character.class ||
-      pClass == Character.TYPE ||
-      pClass == Integer.class ||
-      pClass == Integer.TYPE ||
-      pClass == Long.class ||
-      pClass == Long.TYPE;
-  }
+    /**
+     * Coerces the given value to the specified class.
+     */
+    public static Object coerce(Object pValue,
+                                Class pClass,
+                                Logger pLogger)
+            throws ELException {
+        if (pClass == String.class) {
+            return coerceToString(pValue, pLogger);
+        } else if (isPrimitiveNumberClass(pClass)) {
+            return coerceToPrimitiveNumber(pValue, pClass, pLogger);
+        } else if (pClass == Character.class ||
+                pClass == Character.TYPE) {
+            return coerceToCharacter(pValue, pLogger);
+        } else if (pClass == Boolean.class ||
+                pClass == Boolean.TYPE) {
+            return coerceToBoolean(pValue, pLogger);
+        } else {
+            return coerceToObject(pValue, pClass, pLogger);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given class is Byte, Short, Integer, Long,
+     * Float, Double
+     */
+    static boolean isPrimitiveNumberClass(Class pClass) {
+        return
+                pClass == Byte.class ||
+                        pClass == Byte.TYPE ||
+                        pClass == Short.class ||
+                        pClass == Short.TYPE ||
+                        pClass == Integer.class ||
+                        pClass == Integer.TYPE ||
+                        pClass == Long.class ||
+                        pClass == Long.TYPE ||
+                        pClass == Float.class ||
+                        pClass == Float.TYPE ||
+                        pClass == Double.class ||
+                        pClass == Double.TYPE;
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces the specified value to a String
+     */
+    public static String coerceToString(Object pValue,
+                                        Logger pLogger)
+            throws ELException {
+        if (pValue == null) {
+            return "";
+        } else if (pValue instanceof String) {
+            return (String) pValue;
+        } else {
+            try {
+                return pValue.toString();
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError(Constants.TOSTRING_EXCEPTION,
+                            exc,
+                            pValue.getClass().getName());
+                }
+                return "";
+            }
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a value to the given primitive number class
+     */
+    public static Number coerceToPrimitiveNumber(Object pValue,
+                                                 Class pClass,
+                                                 Logger pLogger)
+            throws ELException {
+        if (pValue == null ||
+                "".equals(pValue)) {
+            return coerceToPrimitiveNumber(0, pClass);
+        } else if (pValue instanceof Character) {
+            char val = ((Character) pValue).charValue();
+            return coerceToPrimitiveNumber((short) val, pClass);
+        } else if (pValue instanceof Boolean) {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError(Constants.BOOLEAN_TO_NUMBER,
+                        pValue,
+                        pClass.getName());
+            }
+            return coerceToPrimitiveNumber(0, pClass);
+        } else if (pValue.getClass() == pClass) {
+            return (Number) pValue;
+        } else if (pValue instanceof Number) {
+            return coerceToPrimitiveNumber((Number) pValue, pClass);
+        } else if (pValue instanceof String) {
+            try {
+                return coerceToPrimitiveNumber((String) pValue, pClass);
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError
+                            (Constants.STRING_TO_NUMBER_EXCEPTION,
+                                    (String) pValue,
+                                    pClass.getName());
+                }
+                return coerceToPrimitiveNumber(0, pClass);
+            }
+        } else {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.COERCE_TO_NUMBER,
+                                pValue.getClass().getName(),
+                                pClass.getName());
+            }
+            return coerceToPrimitiveNumber(0, pClass);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a value to an Integer, returning null if the coercion
+     * isn't possible.
+     */
+    public static Integer coerceToInteger(Object pValue,
+                                          Logger pLogger)
+            throws ELException {
+        if (pValue == null) {
+            return null;
+        } else if (pValue instanceof Character) {
+            return PrimitiveObjects.getInteger
+                    ((int) (((Character) pValue).charValue()));
+        } else if (pValue instanceof Boolean) {
+            if (pLogger.isLoggingWarning()) {
+                pLogger.logWarning(Constants.BOOLEAN_TO_NUMBER,
+                        pValue,
+                        Integer.class.getName());
+            }
+            return PrimitiveObjects.getInteger
+                    (((Boolean) pValue).booleanValue() ? 1 : 0);
+        } else if (pValue instanceof Integer) {
+            return (Integer) pValue;
+        } else if (pValue instanceof Number) {
+            return PrimitiveObjects.getInteger(((Number) pValue).intValue());
+        } else if (pValue instanceof String) {
+            try {
+                return Integer.valueOf((String) pValue);
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingWarning()) {
+                    pLogger.logWarning
+                            (Constants.STRING_TO_NUMBER_EXCEPTION,
+                                    (String) pValue,
+                                    Integer.class.getName());
+                }
+                return null;
+            }
+        } else {
+            if (pLogger.isLoggingWarning()) {
+                pLogger.logWarning
+                        (Constants.COERCE_TO_NUMBER,
+                                pValue.getClass().getName(),
+                                Integer.class.getName());
+            }
+            return null;
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a long to the given primitive number class
+     */
+    static Number coerceToPrimitiveNumber(long pValue,
+                                          Class pClass)
+            throws ELException {
+        if (pClass == Byte.class || pClass == Byte.TYPE) {
+            return PrimitiveObjects.getByte((byte) pValue);
+        } else if (pClass == Short.class || pClass == Short.TYPE) {
+            return PrimitiveObjects.getShort((short) pValue);
+        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
+            return PrimitiveObjects.getInteger((int) pValue);
+        } else if (pClass == Long.class || pClass == Long.TYPE) {
+            return PrimitiveObjects.getLong((long) pValue);
+        } else if (pClass == Float.class || pClass == Float.TYPE) {
+            return PrimitiveObjects.getFloat((float) pValue);
+        } else if (pClass == Double.class || pClass == Double.TYPE) {
+            return PrimitiveObjects.getDouble((double) pValue);
+        } else {
+            return PrimitiveObjects.getInteger(0);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a double to the given primitive number class
+     */
+    static Number coerceToPrimitiveNumber(double pValue,
+                                          Class pClass)
+            throws ELException {
+        if (pClass == Byte.class || pClass == Byte.TYPE) {
+            return PrimitiveObjects.getByte((byte) pValue);
+        } else if (pClass == Short.class || pClass == Short.TYPE) {
+            return PrimitiveObjects.getShort((short) pValue);
+        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
+            return PrimitiveObjects.getInteger((int) pValue);
+        } else if (pClass == Long.class || pClass == Long.TYPE) {
+            return PrimitiveObjects.getLong((long) pValue);
+        } else if (pClass == Float.class || pClass == Float.TYPE) {
+            return PrimitiveObjects.getFloat((float) pValue);
+        } else if (pClass == Double.class || pClass == Double.TYPE) {
+            return PrimitiveObjects.getDouble((double) pValue);
+        } else {
+            return PrimitiveObjects.getInteger(0);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a Number to the given primitive number class
+     */
+    static Number coerceToPrimitiveNumber(Number pValue,
+                                          Class pClass)
+            throws ELException {
+        if (pClass == Byte.class || pClass == Byte.TYPE) {
+            return PrimitiveObjects.getByte(pValue.byteValue());
+        } else if (pClass == Short.class || pClass == Short.TYPE) {
+            return PrimitiveObjects.getShort(pValue.shortValue());
+        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
+            return PrimitiveObjects.getInteger(pValue.intValue());
+        } else if (pClass == Long.class || pClass == Long.TYPE) {
+            return PrimitiveObjects.getLong(pValue.longValue());
+        } else if (pClass == Float.class || pClass == Float.TYPE) {
+            return PrimitiveObjects.getFloat(pValue.floatValue());
+        } else if (pClass == Double.class || pClass == Double.TYPE) {
+            return PrimitiveObjects.getDouble(pValue.doubleValue());
+        } else {
+            return PrimitiveObjects.getInteger(0);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a String to the given primitive number class
+     */
+    static Number coerceToPrimitiveNumber(String pValue,
+                                          Class pClass)
+            throws ELException {
+        if (pClass == Byte.class || pClass == Byte.TYPE) {
+            return Byte.valueOf(pValue);
+        } else if (pClass == Short.class || pClass == Short.TYPE) {
+            return Short.valueOf(pValue);
+        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
+            return Integer.valueOf(pValue);
+        } else if (pClass == Long.class || pClass == Long.TYPE) {
+            return Long.valueOf(pValue);
+        } else if (pClass == Float.class || pClass == Float.TYPE) {
+            return Float.valueOf(pValue);
+        } else if (pClass == Double.class || pClass == Double.TYPE) {
+            return Double.valueOf(pValue);
+        } else {
+            return PrimitiveObjects.getInteger(0);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a value to a Character
+     */
+    public static Character coerceToCharacter(Object pValue,
+                                              Logger pLogger)
+            throws ELException {
+        if (pValue == null ||
+                "".equals(pValue)) {
+            return PrimitiveObjects.getCharacter((char) 0);
+        } else if (pValue instanceof Character) {
+            return (Character) pValue;
+        } else if (pValue instanceof Boolean) {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError(Constants.BOOLEAN_TO_CHARACTER, pValue);
+            }
+            return PrimitiveObjects.getCharacter((char) 0);
+        } else if (pValue instanceof Number) {
+            return PrimitiveObjects.getCharacter
+                    ((char) ((Number) pValue).shortValue());
+        } else if (pValue instanceof String) {
+            String str = (String) pValue;
+            return PrimitiveObjects.getCharacter(str.charAt(0));
+        } else {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.COERCE_TO_CHARACTER,
+                                pValue.getClass().getName());
+            }
+            return PrimitiveObjects.getCharacter((char) 0);
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a value to a Boolean
+     */
+    public static Boolean coerceToBoolean(Object pValue,
+                                          Logger pLogger)
+            throws ELException {
+        if (pValue == null ||
+                "".equals(pValue)) {
+            return Boolean.FALSE;
+        } else if (pValue instanceof Boolean) {
+            return (Boolean) pValue;
+        } else if (pValue instanceof String) {
+            String str = (String) pValue;
+            try {
+                return Boolean.valueOf(str);
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError
+                            (Constants.STRING_TO_BOOLEAN,
+                                    exc,
+                                    (String) pValue);
+                }
+                return Boolean.FALSE;
+            }
+        } else {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.COERCE_TO_BOOLEAN,
+                                pValue.getClass().getName());
+            }
+            return Boolean.TRUE;
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Coerces a value to the specified Class that is not covered by any
+     * of the above cases
+     */
+    public static Object coerceToObject(Object pValue,
+                                        Class pClass,
+                                        Logger pLogger)
+            throws ELException {
+        if (pValue == null) {
+            return null;
+        } else if (pClass.isAssignableFrom(pValue.getClass())) {
+            return pValue;
+        } else if (pValue instanceof String) {
+            String str = (String) pValue;
+            PropertyEditor pe = PropertyEditorManager.findEditor(pClass);
+            if (pe == null) {
+                if ("".equals(str)) {
+                    return null;
+                } else {
+                    if (pLogger.isLoggingError()) {
+                        pLogger.logError
+                                (Constants.NO_PROPERTY_EDITOR,
+                                        str,
+                                        pClass.getName());
+                    }
+                    return null;
+                }
+            }
+            try {
+                pe.setAsText(str);
+                return pe.getValue();
+            }
+            catch (IllegalArgumentException exc) {
+                if ("".equals(str)) {
+                    return null;
+                } else {
+                    if (pLogger.isLoggingError()) {
+                        pLogger.logError
+                                (Constants.PROPERTY_EDITOR_ERROR,
+                                        exc,
+                                        pValue,
+                                        pClass.getName());
+                    }
+                    return null;
+                }
+            }
+        } else {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.COERCE_TO_OBJECT,
+                                pValue.getClass().getName(),
+                                pClass.getName());
+            }
+            return null;
+        }
+    }
+
+    //-------------------------------------
+    // Applying operators
+    //-------------------------------------
+
+    /**
+     * Performs all of the necessary type conversions, then calls on the
+     * appropriate operator.
+     */
+    public static Object applyArithmeticOperator
+            (Object pLeft,
+             Object pRight,
+             ArithmeticOperator pOperator,
+             Logger pLogger)
+            throws ELException {
+        if (pLeft == null &&
+                pRight == null) {
+            if (pLogger.isLoggingWarning()) {
+                pLogger.logWarning
+                        (Constants.ARITH_OP_NULL,
+                                pOperator.getOperatorSymbol());
+            }
+            return PrimitiveObjects.getInteger(0);
+        } else if (isFloatingPointType(pLeft) ||
+                isFloatingPointType(pRight) ||
+                isFloatingPointString(pLeft) ||
+                isFloatingPointString(pRight)) {
+            double left =
+                    coerceToPrimitiveNumber(pLeft, Double.class, pLogger).
+                            doubleValue();
+            double right =
+                    coerceToPrimitiveNumber(pRight, Double.class, pLogger).
+                            doubleValue();
+            return
+                    PrimitiveObjects.getDouble(pOperator.apply(left, right, pLogger));
+        } else {
+            long left =
+                    coerceToPrimitiveNumber(pLeft, Long.class, pLogger).
+                            longValue();
+            long right =
+                    coerceToPrimitiveNumber(pRight, Long.class, pLogger).
+                            longValue();
+            return
+                    PrimitiveObjects.getLong(pOperator.apply(left, right, pLogger));
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Performs all of the necessary type conversions, then calls on the
+     * appropriate operator.
+     */
+    public static Object applyRelationalOperator
+            (Object pLeft,
+             Object pRight,
+             RelationalOperator pOperator,
+             Logger pLogger)
+            throws ELException {
+        if (isFloatingPointType(pLeft) ||
+                isFloatingPointType(pRight)) {
+            double left =
+                    coerceToPrimitiveNumber(pLeft, Double.class, pLogger).
+                            doubleValue();
+            double right =
+                    coerceToPrimitiveNumber(pRight, Double.class, pLogger).
+                            doubleValue();
+            return
+                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
+        } else if (isIntegerType(pLeft) ||
+                isIntegerType(pRight)) {
+            long left =
+                    coerceToPrimitiveNumber(pLeft, Long.class, pLogger).
+                            longValue();
+            long right =
+                    coerceToPrimitiveNumber(pRight, Long.class, pLogger).
+                            longValue();
+            return
+                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
+        } else if (pLeft instanceof String ||
+                pRight instanceof String) {
+            String left = coerceToString(pLeft, pLogger);
+            String right = coerceToString(pRight, pLogger);
+            return
+                    PrimitiveObjects.getBoolean(pOperator.apply(left, right, pLogger));
+        } else if (pLeft instanceof Comparable) {
+            try {
+                int result = ((Comparable) pLeft).compareTo(pRight);
+                return
+                        PrimitiveObjects.getBoolean
+                                (pOperator.apply(result, -result, pLogger));
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError
+                            (Constants.COMPARABLE_ERROR,
+                                    exc,
+                                    pLeft.getClass().getName(),
+                                    (pRight == null) ? "null" : pRight.getClass().getName(),
+                                    pOperator.getOperatorSymbol());
+                }
+                return Boolean.FALSE;
+            }
+        } else if (pRight instanceof Comparable) {
+            try {
+                int result = ((Comparable) pRight).compareTo(pLeft);
+                return
+                        PrimitiveObjects.getBoolean
+                                (pOperator.apply(-result, result, pLogger));
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError
+                            (Constants.COMPARABLE_ERROR,
+                                    exc,
+                                    pRight.getClass().getName(),
+                                    (pLeft == null) ? "null" : pLeft.getClass().getName(),
+                                    pOperator.getOperatorSymbol());
+                }
+                return Boolean.FALSE;
+            }
+        } else {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.ARITH_OP_BAD_TYPE,
+                                pOperator.getOperatorSymbol(),
+                                pLeft.getClass().getName(),
+                                pRight.getClass().getName());
+            }
+            return Boolean.FALSE;
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Performs all of the necessary type conversions, then calls on the
+     * appropriate operator.
+     */
+    public static Object applyEqualityOperator
+            (Object pLeft,
+             Object pRight,
+             EqualityOperator pOperator,
+             Logger pLogger)
+            throws ELException {
+        if (pLeft == pRight) {
+            return PrimitiveObjects.getBoolean(pOperator.apply(true, pLogger));
+        } else if (pLeft == null ||
+                pRight == null) {
+            return PrimitiveObjects.getBoolean(pOperator.apply(false, pLogger));
+        } else if (isFloatingPointType(pLeft) ||
+                isFloatingPointType(pRight)) {
+            double left =
+                    coerceToPrimitiveNumber(pLeft, Double.class, pLogger).
+                            doubleValue();
+            double right =
+                    coerceToPrimitiveNumber(pRight, Double.class, pLogger).
+                            doubleValue();
+            return
+                    PrimitiveObjects.getBoolean
+                            (pOperator.apply(left == right, pLogger));
+        } else if (isIntegerType(pLeft) ||
+                isIntegerType(pRight)) {
+            long left =
+                    coerceToPrimitiveNumber(pLeft, Long.class, pLogger).
+                            longValue();
+            long right =
+                    coerceToPrimitiveNumber(pRight, Long.class, pLogger).
+                            longValue();
+            return
+                    PrimitiveObjects.getBoolean
+                            (pOperator.apply(left == right, pLogger));
+        } else if (pLeft instanceof Boolean ||
+                pRight instanceof Boolean) {
+            boolean left = coerceToBoolean(pLeft, pLogger).booleanValue();
+            boolean right = coerceToBoolean(pRight, pLogger).booleanValue();
+            return
+                    PrimitiveObjects.getBoolean
+                            (pOperator.apply(left == right, pLogger));
+        } else if (pLeft instanceof String ||
+                pRight instanceof String) {
+            String left = coerceToString(pLeft, pLogger);
+            String right = coerceToString(pRight, pLogger);
+            return
+                    PrimitiveObjects.getBoolean
+                            (pOperator.apply(left.equals(right), pLogger));
+        } else {
+            try {
+                return
+                        PrimitiveObjects.getBoolean
+                                (pOperator.apply(pLeft.equals(pRight), pLogger));
+            }
+            catch (Exception exc) {
+                if (pLogger.isLoggingError()) {
+                    pLogger.logError
+                            (Constants.ERROR_IN_EQUALS,
+                                    exc,
+                                    pLeft.getClass().getName(),
+                                    pRight.getClass().getName(),
+                                    pOperator.getOperatorSymbol());
+                }
+                return Boolean.FALSE;
+            }
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given Object is of a floating point type
+     */
+    public static boolean isFloatingPointType(Object pObject) {
+        return
+                pObject != null &&
+                        isFloatingPointType(pObject.getClass());
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given class is of a floating point type
+     */
+    public static boolean isFloatingPointType(Class pClass) {
+        return
+                pClass == Float.class ||
+                        pClass == Float.TYPE ||
+                        pClass == Double.class ||
+                        pClass == Double.TYPE;
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given string might contain a floating point
+     * number - i.e., it contains ".", "e", or "E"
+     */
+    public static boolean isFloatingPointString(Object pObject) {
+        if (pObject instanceof String) {
+            String str = (String) pObject;
+            int len = str.length();
+            for (int i = 0; i < len; i++) {
+                char ch = str.charAt(i);
+                if (ch == '.' ||
+                        ch == 'e' ||
+                        ch == 'E') {
+                    return true;
+                }
+            }
+            return false;
+        } else {
+            return false;
+        }
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given Object is of an integer type
+     */
+    public static boolean isIntegerType(Object pObject) {
+        return
+                pObject != null &&
+                        isIntegerType(pObject.getClass());
+    }
+
+    //-------------------------------------
+
+    /**
+     * Returns true if the given class is of an integer type
+     */
+    public static boolean isIntegerType(Class pClass) {
+        return
+                pClass == Byte.class ||
+                        pClass == Byte.TYPE ||
+                        pClass == Short.class ||
+                        pClass == Short.TYPE ||
+                        pClass == Character.class ||
+                        pClass == Character.TYPE ||
+                        pClass == Integer.class ||
+                        pClass == Integer.TYPE ||
+                        pClass == Long.class ||
+                        pClass == Long.TYPE;
+    }
 
-  //-------------------------------------
+    //-------------------------------------
 
 }

Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/ComplexValue.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/ComplexValue.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/ComplexValue.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/ComplexValue.java Sat Nov 20 18:14:00 2010
@@ -13,7 +13,7 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
@@ -21,96 +21,99 @@ import java.util.List;
 import java.util.Map;
 
 /**
- *
  * <p>Represents a dynamic value, which consists of a prefix and an
  * optional set of ValueSuffix elements.  A prefix is something like
  * an identifier, and a suffix is something like a "property of" or
  * "indexed element of" operator.
- * 
+ *
  * @author Nathan Abramson - Art Technology Group
  * @author Shawn Bayern
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
 public class ComplexValue
-  extends Expression
-{
-  //-------------------------------------
-  // Properties
-  //-------------------------------------
-  // property prefix
-
-  Expression mPrefix;
-  public Expression getPrefix ()
-  { return mPrefix; }
-  public void setPrefix (Expression pPrefix)
-  { mPrefix = pPrefix; }
-
-  //-------------------------------------
-  // property suffixes
-
-  List mSuffixes;
-  public List getSuffixes ()
-  { return mSuffixes; }
-  public void setSuffixes (List pSuffixes)
-  { mSuffixes = pSuffixes; }
-
-  //-------------------------------------
-  /**
-   *
-   * Constructor
-   **/
-  public ComplexValue (Expression pPrefix,
-		       List pSuffixes)
-  {
-    mPrefix = pPrefix;
-    mSuffixes = pSuffixes;
-  }
-
-  //-------------------------------------
-  // Expression methods
-  //-------------------------------------
-  /**
-   *
-   * Returns the expression in the expression language syntax
-   **/
-  public String getExpressionString ()
-  {
-    StringBuffer buf = new StringBuffer ();
-    buf.append (mPrefix.getExpressionString ());
-
-    for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) {
-      ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i);
-      buf.append (suffix.getExpressionString ());
-    }
-
-    return buf.toString ();
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Evaluates by evaluating the prefix, then applying the suffixes
-   **/
-  public Object evaluate (Object pContext,
-			  VariableResolver pResolver,
-			  Map functions,
-			  String defaultPrefix,
-			  Logger pLogger)
-    throws ELException
-  {
-    Object ret = mPrefix.evaluate (pContext, pResolver, functions,
-				   defaultPrefix, pLogger);
-
-    // Apply the suffixes
-    for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) {
-      ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i);
-      ret = suffix.evaluate (ret, pContext, pResolver, functions,
-			     defaultPrefix, pLogger);
+        extends Expression {
+    //-------------------------------------
+    // Properties
+    //-------------------------------------
+    // property prefix
+
+    Expression mPrefix;
+
+    public Expression getPrefix() {
+        return mPrefix;
+    }
+
+    public void setPrefix(Expression pPrefix) {
+        mPrefix = pPrefix;
     }
 
-    return ret;
-  }
+    //-------------------------------------
+    // property suffixes
+
+    List mSuffixes;
+
+    public List getSuffixes() {
+        return mSuffixes;
+    }
+
+    public void setSuffixes(List pSuffixes) {
+        mSuffixes = pSuffixes;
+    }
+
+    //-------------------------------------
+
+    /**
+     * Constructor
+     */
+    public ComplexValue(Expression pPrefix,
+                        List pSuffixes) {
+        mPrefix = pPrefix;
+        mSuffixes = pSuffixes;
+    }
+
+    //-------------------------------------
+    // Expression methods
+    //-------------------------------------
+
+    /**
+     * Returns the expression in the expression language syntax
+     */
+    public String getExpressionString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append(mPrefix.getExpressionString());
+
+        for (int i = 0; mSuffixes != null && i < mSuffixes.size(); i++) {
+            ValueSuffix suffix = (ValueSuffix) mSuffixes.get(i);
+            buf.append(suffix.getExpressionString());
+        }
+
+        return buf.toString();
+    }
+
+    //-------------------------------------
+
+    /**
+     * Evaluates by evaluating the prefix, then applying the suffixes
+     */
+    public Object evaluate(Object pContext,
+                           VariableResolver pResolver,
+                           Map functions,
+                           String defaultPrefix,
+                           Logger pLogger)
+            throws ELException {
+        Object ret = mPrefix.evaluate(pContext, pResolver, functions,
+                defaultPrefix, pLogger);
+
+        // Apply the suffixes
+        for (int i = 0; mSuffixes != null && i < mSuffixes.size(); i++) {
+            ValueSuffix suffix = (ValueSuffix) mSuffixes.get(i);
+            ret = suffix.evaluate(ret, pContext, pResolver, functions,
+                    defaultPrefix, pLogger);
+        }
+
+        return ret;
+    }
 
-  //-------------------------------------
+    //-------------------------------------
 }

Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Constants.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Constants.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/Constants.java Sat Nov 20 18:14:00 2010
@@ -13,7 +13,7 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
@@ -21,184 +21,180 @@ import java.util.MissingResourceExceptio
 import java.util.ResourceBundle;
 
 /**
- *
  * <p>This contains all of the non-public constants, including
  * messsage strings read from the resource file.
  *
  * @author Nathan Abramson - Art Technology Group
  * @author Shawn Bayern
- *
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
-public class Constants
-{
-  //-------------------------------------
-  // Resources
+public class Constants {
+    //-------------------------------------
+    // Resources
 
-  static ResourceBundle sResources =
-  ResourceBundle.getBundle ("org.apache.taglibs.standard.lang.jstl.Resources");
+    static ResourceBundle sResources =
+            ResourceBundle.getBundle("org.apache.taglibs.standard.lang.jstl.Resources");
 
-  //-------------------------------------
-  // Messages from the resource bundle
-  //-------------------------------------
+    //-------------------------------------
+    // Messages from the resource bundle
+    //-------------------------------------
 
-  public static final String EXCEPTION_GETTING_BEANINFO =
-    getStringResource ("EXCEPTION_GETTING_BEANINFO");
+    public static final String EXCEPTION_GETTING_BEANINFO =
+            getStringResource("EXCEPTION_GETTING_BEANINFO");
 
-  public static final String NULL_EXPRESSION_STRING =
-    getStringResource ("NULL_EXPRESSION_STRING");
+    public static final String NULL_EXPRESSION_STRING =
+            getStringResource("NULL_EXPRESSION_STRING");
 
-  public static final String PARSE_EXCEPTION =
-    getStringResource ("PARSE_EXCEPTION");
+    public static final String PARSE_EXCEPTION =
+            getStringResource("PARSE_EXCEPTION");
 
-  public static final String CANT_GET_PROPERTY_OF_NULL =
-    getStringResource ("CANT_GET_PROPERTY_OF_NULL");
+    public static final String CANT_GET_PROPERTY_OF_NULL =
+            getStringResource("CANT_GET_PROPERTY_OF_NULL");
 
-  public static final String NO_SUCH_PROPERTY =
-    getStringResource ("NO_SUCH_PROPERTY");
+    public static final String NO_SUCH_PROPERTY =
+            getStringResource("NO_SUCH_PROPERTY");
 
-  public static final String NO_GETTER_METHOD =
-    getStringResource ("NO_GETTER_METHOD");
+    public static final String NO_GETTER_METHOD =
+            getStringResource("NO_GETTER_METHOD");
 
-  public static final String ERROR_GETTING_PROPERTY =
-    getStringResource ("ERROR_GETTING_PROPERTY");
+    public static final String ERROR_GETTING_PROPERTY =
+            getStringResource("ERROR_GETTING_PROPERTY");
 
-  public static final String CANT_GET_INDEXED_VALUE_OF_NULL =
-    getStringResource ("CANT_GET_INDEXED_VALUE_OF_NULL");
+    public static final String CANT_GET_INDEXED_VALUE_OF_NULL =
+            getStringResource("CANT_GET_INDEXED_VALUE_OF_NULL");
 
-  public static final String CANT_GET_NULL_INDEX =
-    getStringResource ("CANT_GET_NULL_INDEX");
+    public static final String CANT_GET_NULL_INDEX =
+            getStringResource("CANT_GET_NULL_INDEX");
 
-  public static final String NULL_INDEX =
-    getStringResource ("NULL_INDEX");
+    public static final String NULL_INDEX =
+            getStringResource("NULL_INDEX");
 
-  public static final String BAD_INDEX_VALUE =
-    getStringResource ("BAD_INDEX_VALUE");
+    public static final String BAD_INDEX_VALUE =
+            getStringResource("BAD_INDEX_VALUE");
 
-  public static final String EXCEPTION_ACCESSING_LIST =
-    getStringResource ("EXCEPTION_ACCESSING_LIST");
+    public static final String EXCEPTION_ACCESSING_LIST =
+            getStringResource("EXCEPTION_ACCESSING_LIST");
 
-  public static final String EXCEPTION_ACCESSING_ARRAY =
-    getStringResource ("EXCEPTION_ACCESSING_ARRAY");
+    public static final String EXCEPTION_ACCESSING_ARRAY =
+            getStringResource("EXCEPTION_ACCESSING_ARRAY");
 
-  public static final String CANT_FIND_INDEX =
-    getStringResource ("CANT_FIND_INDEX");
+    public static final String CANT_FIND_INDEX =
+            getStringResource("CANT_FIND_INDEX");
 
-  public static final String TOSTRING_EXCEPTION =
-    getStringResource ("TOSTRING_EXCEPTION");
+    public static final String TOSTRING_EXCEPTION =
+            getStringResource("TOSTRING_EXCEPTION");
 
-  public static final String BOOLEAN_TO_NUMBER =
-    getStringResource ("BOOLEAN_TO_NUMBER");
+    public static final String BOOLEAN_TO_NUMBER =
+            getStringResource("BOOLEAN_TO_NUMBER");
 
-  public static final String STRING_TO_NUMBER_EXCEPTION =
-    getStringResource ("STRING_TO_NUMBER_EXCEPTION");
+    public static final String STRING_TO_NUMBER_EXCEPTION =
+            getStringResource("STRING_TO_NUMBER_EXCEPTION");
 
-  public static final String COERCE_TO_NUMBER =
-    getStringResource ("COERCE_TO_NUMBER");
+    public static final String COERCE_TO_NUMBER =
+            getStringResource("COERCE_TO_NUMBER");
 
-  public static final String BOOLEAN_TO_CHARACTER =
-    getStringResource ("BOOLEAN_TO_CHARACTER");
+    public static final String BOOLEAN_TO_CHARACTER =
+            getStringResource("BOOLEAN_TO_CHARACTER");
 
-  public static final String EMPTY_STRING_TO_CHARACTER =
-    getStringResource ("EMPTY_STRING_TO_CHARACTER");
+    public static final String EMPTY_STRING_TO_CHARACTER =
+            getStringResource("EMPTY_STRING_TO_CHARACTER");
 
-  public static final String COERCE_TO_CHARACTER =
-    getStringResource ("COERCE_TO_CHARACTER");
+    public static final String COERCE_TO_CHARACTER =
+            getStringResource("COERCE_TO_CHARACTER");
 
-  public static final String NULL_TO_BOOLEAN =
-    getStringResource ("NULL_TO_BOOLEAN");
+    public static final String NULL_TO_BOOLEAN =
+            getStringResource("NULL_TO_BOOLEAN");
 
-  public static final String STRING_TO_BOOLEAN =
-    getStringResource ("STRING_TO_BOOLEAN");
+    public static final String STRING_TO_BOOLEAN =
+            getStringResource("STRING_TO_BOOLEAN");
 
-  public static final String COERCE_TO_BOOLEAN =
-    getStringResource ("COERCE_TO_BOOLEAN");
+    public static final String COERCE_TO_BOOLEAN =
+            getStringResource("COERCE_TO_BOOLEAN");
 
-  public static final String COERCE_TO_OBJECT =
-    getStringResource ("COERCE_TO_OBJECT");
+    public static final String COERCE_TO_OBJECT =
+            getStringResource("COERCE_TO_OBJECT");
 
-  public static final String NO_PROPERTY_EDITOR =
-    getStringResource ("NO_PROPERTY_EDITOR");
+    public static final String NO_PROPERTY_EDITOR =
+            getStringResource("NO_PROPERTY_EDITOR");
 
-  public static final String PROPERTY_EDITOR_ERROR =
-    getStringResource ("PROPERTY_EDITOR_ERROR");
+    public static final String PROPERTY_EDITOR_ERROR =
+            getStringResource("PROPERTY_EDITOR_ERROR");
 
-  public static final String ARITH_OP_NULL =
-    getStringResource ("ARITH_OP_NULL");
+    public static final String ARITH_OP_NULL =
+            getStringResource("ARITH_OP_NULL");
 
-  public static final String ARITH_OP_BAD_TYPE =
-    getStringResource ("ARITH_OP_BAD_TYPE");
+    public static final String ARITH_OP_BAD_TYPE =
+            getStringResource("ARITH_OP_BAD_TYPE");
 
-  public static final String ARITH_ERROR =
-    getStringResource ("ARITH_ERROR");
+    public static final String ARITH_ERROR =
+            getStringResource("ARITH_ERROR");
 
-  public static final String ERROR_IN_EQUALS =
-    getStringResource ("ERROR_IN_EQUALS");
+    public static final String ERROR_IN_EQUALS =
+            getStringResource("ERROR_IN_EQUALS");
 
-  public static final String UNARY_OP_BAD_TYPE =
-    getStringResource ("UNARY_OP_BAD_TYPE");
+    public static final String UNARY_OP_BAD_TYPE =
+            getStringResource("UNARY_OP_BAD_TYPE");
 
-  public static final String NAMED_VALUE_NOT_FOUND =
-    getStringResource ("NAMED_VALUE_NOT_FOUND");
+    public static final String NAMED_VALUE_NOT_FOUND =
+            getStringResource("NAMED_VALUE_NOT_FOUND");
 
-  public static final String CANT_GET_INDEXED_PROPERTY =
-    getStringResource ("CANT_GET_INDEXED_PROPERTY");
+    public static final String CANT_GET_INDEXED_PROPERTY =
+            getStringResource("CANT_GET_INDEXED_PROPERTY");
 
-  public static final String COMPARABLE_ERROR =
-    getStringResource ("COMPARABLE_ERROR");
+    public static final String COMPARABLE_ERROR =
+            getStringResource("COMPARABLE_ERROR");
 
-  public static final String BAD_IMPLICIT_OBJECT =
-    getStringResource ("BAD_IMPLICIT_OBJECT");
+    public static final String BAD_IMPLICIT_OBJECT =
+            getStringResource("BAD_IMPLICIT_OBJECT");
 
-  public static final String ATTRIBUTE_EVALUATION_EXCEPTION =
-    getStringResource ("ATTRIBUTE_EVALUATION_EXCEPTION");
+    public static final String ATTRIBUTE_EVALUATION_EXCEPTION =
+            getStringResource("ATTRIBUTE_EVALUATION_EXCEPTION");
 
-  public static final String ATTRIBUTE_PARSE_EXCEPTION =
-    getStringResource ("ATTRIBUTE_PARSE_EXCEPTION");
+    public static final String ATTRIBUTE_PARSE_EXCEPTION =
+            getStringResource("ATTRIBUTE_PARSE_EXCEPTION");
 
-  public static final String UNKNOWN_FUNCTION =
-    getStringResource ("UNKNOWN_FUNCTION");
+    public static final String UNKNOWN_FUNCTION =
+            getStringResource("UNKNOWN_FUNCTION");
 
-  public static final String INAPPROPRIATE_FUNCTION_ARG_COUNT =
-    getStringResource ("INAPPROPRIATE_FUNCTION_ARG_COUNT");
+    public static final String INAPPROPRIATE_FUNCTION_ARG_COUNT =
+            getStringResource("INAPPROPRIATE_FUNCTION_ARG_COUNT");
 
-  public static final String FUNCTION_INVOCATION_ERROR =
-    getStringResource ("FUNCTION_INVOCATION_ERROR");
+    public static final String FUNCTION_INVOCATION_ERROR =
+            getStringResource("FUNCTION_INVOCATION_ERROR");
 
 
-  //-------------------------------------
-  // Getting resources
-  //-------------------------------------
-  /**
-   *
-   * 
-   **/
-  public static String getStringResource (String pResourceName)
-    throws MissingResourceException
-  {
-    try {
-      String ret = sResources.getString (pResourceName);
-      if (ret == null) {
-	String str = "ERROR: Unable to load resource " + pResourceName;
-	System.err.println (str);
-	throw new MissingResourceException 
-	  (str, 
-	   "org.apache.taglibs.standard.lang.jstl.Constants",
-	   pResourceName);
-      }
-      else {
-	return ret;
-      }
-    }
-    catch (MissingResourceException exc) {
-      System.err.println ("ERROR: Unable to load resource " +
-			  pResourceName +
-			  ": " +
-			  exc);
-      throw exc;
+    //-------------------------------------
+    // Getting resources
+    //-------------------------------------
+
+    /**
+     *
+     *
+     **/
+    public static String getStringResource(String pResourceName)
+            throws MissingResourceException {
+        try {
+            String ret = sResources.getString(pResourceName);
+            if (ret == null) {
+                String str = "ERROR: Unable to load resource " + pResourceName;
+                System.err.println(str);
+                throw new MissingResourceException
+                        (str,
+                                "org.apache.taglibs.standard.lang.jstl.Constants",
+                                pResourceName);
+            } else {
+                return ret;
+            }
+        }
+        catch (MissingResourceException exc) {
+            System.err.println("ERROR: Unable to load resource " +
+                    pResourceName +
+                    ": " +
+                    exc);
+            throw exc;
+        }
     }
-  }
 
-  //-------------------------------------
+    //-------------------------------------
 }

Modified: tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/DivideOperator.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/DivideOperator.java?rev=1037284&r1=1037283&r2=1037284&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/DivideOperator.java (original)
+++ tomcat/taglibs/standard/trunk/jstlel/src/main/java/org/apache/taglibs/standard/lang/jstl/DivideOperator.java Sat Nov 20 18:14:00 2010
@@ -13,91 +13,86 @@
  * 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.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl;
 
 /**
- *
  * <p>The implementation of the divide operator
- * 
+ *
  * @author Nathan Abramson - Art Technology Group
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
 public class DivideOperator
-  extends BinaryOperator
-{
-  //-------------------------------------
-  // Singleton
-  //-------------------------------------
-
-  public static final DivideOperator SINGLETON =
-    new DivideOperator ();
-
-  //-------------------------------------
-  /**
-   *
-   * Constructor
-   **/
-  public DivideOperator ()
-  {
-  }
-
-  //-------------------------------------
-  // Expression methods
-  //-------------------------------------
-  /**
-   *
-   * Returns the symbol representing the operator
-   **/
-  public String getOperatorSymbol ()
-  {
-    return "/";
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Applies the operator to the given value
-   **/
-  public Object apply (Object pLeft,
-		       Object pRight,
-		       Object pContext,
-		       Logger pLogger)
-    throws ELException
-  {
-    if (pLeft == null &&
-	pRight == null) {
-      if (pLogger.isLoggingWarning ()) {
-	pLogger.logWarning
-	  (Constants.ARITH_OP_NULL,
-	   getOperatorSymbol ());
-      }
-      return PrimitiveObjects.getInteger (0);
+        extends BinaryOperator {
+    //-------------------------------------
+    // Singleton
+    //-------------------------------------
+
+    public static final DivideOperator SINGLETON =
+            new DivideOperator();
+
+    //-------------------------------------
+
+    /**
+     * Constructor
+     */
+    public DivideOperator() {
     }
 
-    double left =
-      Coercions.coerceToPrimitiveNumber (pLeft, Double.class, pLogger).
-      doubleValue ();
-    double right =
-      Coercions.coerceToPrimitiveNumber (pRight, Double.class, pLogger).
-      doubleValue ();
-
-    try {
-      return PrimitiveObjects.getDouble (left / right);
+    //-------------------------------------
+    // Expression methods
+    //-------------------------------------
+
+    /**
+     * Returns the symbol representing the operator
+     */
+    public String getOperatorSymbol() {
+        return "/";
     }
-    catch (Exception exc) {
-      if (pLogger.isLoggingError ()) {
-	pLogger.logError
-	  (Constants.ARITH_ERROR,
-	   getOperatorSymbol (),
-	   "" + left,
-	   "" + right);
-      }
-      return PrimitiveObjects.getInteger (0);
+
+    //-------------------------------------
+
+    /**
+     * Applies the operator to the given value
+     */
+    public Object apply(Object pLeft,
+                        Object pRight,
+                        Object pContext,
+                        Logger pLogger)
+            throws ELException {
+        if (pLeft == null &&
+                pRight == null) {
+            if (pLogger.isLoggingWarning()) {
+                pLogger.logWarning
+                        (Constants.ARITH_OP_NULL,
+                                getOperatorSymbol());
+            }
+            return PrimitiveObjects.getInteger(0);
+        }
+
+        double left =
+                Coercions.coerceToPrimitiveNumber(pLeft, Double.class, pLogger).
+                        doubleValue();
+        double right =
+                Coercions.coerceToPrimitiveNumber(pRight, Double.class, pLogger).
+                        doubleValue();
+
+        try {
+            return PrimitiveObjects.getDouble(left / right);
+        }
+        catch (Exception exc) {
+            if (pLogger.isLoggingError()) {
+                pLogger.logError
+                        (Constants.ARITH_ERROR,
+                                getOperatorSymbol(),
+                                "" + left,
+                                "" + right);
+            }
+            return PrimitiveObjects.getInteger(0);
+        }
     }
-  }
 
-  //-------------------------------------
+    //-------------------------------------
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message