tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1050660 - in /tomcat/trunk/java/org/apache/el/lang: ELArithmetic.java ELSupport.java ExpressionBuilder.java FunctionMapperImpl.java VariableMapperImpl.java
Date Sat, 18 Dec 2010 16:23:09 GMT
Author: markt
Date: Sat Dec 18 16:23:09 2010
New Revision: 1050660

URL: http://svn.apache.org/viewvc?rev=1050660&view=rev
Log:
Fix most of the Java, Findbugs and unused code warnings in this package

Modified:
    tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java
    tomcat/trunk/java/org/apache/el/lang/ELSupport.java
    tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java
    tomcat/trunk/java/org/apache/el/lang/FunctionMapperImpl.java
    tomcat/trunk/java/org/apache/el/lang/VariableMapperImpl.java

Modified: tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java?rev=1050660&r1=1050659&r2=1050660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java Sat Dec 18 16:23:09 2010
@@ -198,39 +198,39 @@ public abstract class ELArithmetic {
 
         @Override
         protected Number add(Number num0, Number num1) {
-            return new Long(num0.longValue() + num1.longValue());
+            return Long.valueOf(num0.longValue() + num1.longValue());
         }
 
         @Override
         protected Number coerce(Number num) {
             if (num instanceof Long)
                 return num;
-            return new Long(num.longValue());
+            return Long.valueOf(num.longValue());
         }
 
         @Override
         protected Number coerce(String str) {
-            return new Long(str);
+            return Long.valueOf(str);
         }
 
         @Override
         protected Number divide(Number num0, Number num1) {
-            return new Long(num0.longValue() / num1.longValue());
+            return Long.valueOf(num0.longValue() / num1.longValue());
         }
 
         @Override
         protected Number mod(Number num0, Number num1) {
-            return new Long(num0.longValue() % num1.longValue());
+            return Long.valueOf(num0.longValue() % num1.longValue());
         }
 
         @Override
         protected Number subtract(Number num0, Number num1) {
-            return new Long(num0.longValue() - num1.longValue());
+            return Long.valueOf(num0.longValue() - num1.longValue());
         }
 
         @Override
         protected Number multiply(Number num0, Number num1) {
-            return new Long(num0.longValue() * num1.longValue());
+            return Long.valueOf(num0.longValue() * num1.longValue());
         }
 
         @Override
@@ -247,11 +247,11 @@ public abstract class ELArithmetic {
 
     public static final LongDelegate LONG = new LongDelegate();
 
-    private static final Long ZERO = new Long(0);
+    private static final Long ZERO = Long.valueOf(0);
 
     public static final Number add(final Object obj0, final Object obj1) {
         if (obj0 == null && obj1 == null) {
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         final ELArithmetic delegate;
@@ -272,7 +272,7 @@ public abstract class ELArithmetic {
 
     public static final Number mod(final Object obj0, final Object obj1) {
         if (obj0 == null && obj1 == null) {
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         final ELArithmetic delegate;
@@ -293,7 +293,7 @@ public abstract class ELArithmetic {
 
     public static final Number subtract(final Object obj0, final Object obj1) {
         if (obj0 == null && obj1 == null) {
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         final ELArithmetic delegate;
@@ -333,7 +333,7 @@ public abstract class ELArithmetic {
 
     public static final Number multiply(final Object obj0, final Object obj1) {
         if (obj0 == null && obj1 == null) {
-            return new Long(0);
+            return Long.valueOf(0);
         }
 
         final ELArithmetic delegate;
@@ -393,7 +393,7 @@ public abstract class ELArithmetic {
         }
 
         if (obj instanceof Character) {
-            return coerce(new Short((short) ((Character) obj).charValue()));
+            return coerce(Short.valueOf((short) ((Character) obj).charValue()));
         }
 
         throw new IllegalArgumentException(MessageFactory.get("error.convert",

Modified: tomcat/trunk/java/org/apache/el/lang/ELSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELSupport.java?rev=1050660&r1=1050659&r2=1050660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Sat Dec 18 16:23:09 2010
@@ -23,7 +23,6 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 
 import javax.el.ELException;
-import javax.el.PropertyNotFoundException;
 
 import org.apache.el.util.MessageFactory;
 
@@ -36,18 +35,7 @@ import org.apache.el.util.MessageFactory
  */
 public class ELSupport {
 
-    private static final Long ZERO = new Long(0L);
-
-    public static final void throwUnhandled(Object base, Object property)
-            throws ELException {
-        if (base == null) {
-            throw new PropertyNotFoundException(MessageFactory.get(
-                    "error.resolver.unhandled.null", property));
-        } else {
-            throw new PropertyNotFoundException(MessageFactory.get(
-                    "error.resolver.unhandled", base.getClass(), property));
-        }
-    }
+    private static final Long ZERO = Long.valueOf(0L);
 
     /**
      * Compare two objects, after coercing to the same type if appropriate.
@@ -222,13 +210,13 @@ public class ELSupport {
     public static final Character coerceToCharacter(final Object obj)
             throws ELException {
         if (obj == null || "".equals(obj)) {
-            return new Character((char) 0);
+            return Character.valueOf((char) 0);
         }
         if (obj instanceof String) {
-            return new Character(((String) obj).charAt(0));
+            return Character.valueOf(((String) obj).charAt(0));
         }
         if (ELArithmetic.isNumber(obj)) {
-            return new Character((char) ((Number) obj).shortValue());
+            return Character.valueOf((char) ((Number) obj).shortValue());
         }
         Class<?> objType = obj.getClass();
         if (obj instanceof Character) {
@@ -239,31 +227,16 @@ public class ELSupport {
                 obj, objType, Character.class));
     }
 
-    public static final Number coerceToNumber(final Object obj) {
-        if (obj == null) {
-            return ZERO;
-        } else if (obj instanceof Number) {
-            return (Number) obj;
-        } else {
-            String str = coerceToString(obj);
-            if (isStringFloat(str)) {
-                return toFloat(str);
-            } else {
-                return toNumber(str);
-            }
-        }
-    }
-
     protected static final Number coerceToNumber(final Number number,
             final Class<?> type) throws ELException {
         if (Long.TYPE == type || Long.class.equals(type)) {
-            return new Long(number.longValue());
+            return Long.valueOf(number.longValue());
         }
         if (Double.TYPE == type || Double.class.equals(type)) {
             return new Double(number.doubleValue());
         }
         if (Integer.TYPE == type || Integer.class.equals(type)) {
-            return new Integer(number.intValue());
+            return Integer.valueOf(number.intValue());
         }
         if (BigInteger.class.equals(type)) {
             if (number instanceof BigDecimal) {
@@ -284,10 +257,10 @@ public class ELSupport {
             return new BigDecimal(number.doubleValue());
         }
         if (Byte.TYPE == type || Byte.class.equals(type)) {
-            return new Byte(number.byteValue());
+            return Byte.valueOf(number.byteValue());
         }
         if (Short.TYPE == type || Short.class.equals(type)) {
-            return new Short(number.shortValue());
+            return Short.valueOf(number.shortValue());
         }
         if (Float.TYPE == type || Float.class.equals(type)) {
             return new Float(number.floatValue());
@@ -313,7 +286,7 @@ public class ELSupport {
         }
 
         if (obj instanceof Character) {
-            return coerceToNumber(new Short((short) ((Character) obj)
+            return coerceToNumber(Short.valueOf((short) ((Character) obj)
                     .charValue()), type);
         }
 
@@ -447,20 +420,6 @@ public class ELSupport {
                 obj, obj.getClass(), type));
     }
 
-    /**
-     * Check if an array contains any {@code null} entries.
-     * @param obj array to be checked
-     * @return true if the array contains a {@code null}
-     */
-    public static final boolean containsNulls(final Object[] obj) {
-        for (int i = 0; i < obj.length; i++) {
-            if (obj[0] == null) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     public static final boolean isBigDecimalOp(final Object obj0,
             final Object obj1) {
         return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal);
@@ -478,12 +437,6 @@ public class ELSupport {
                 || obj1 instanceof Float);
     }
 
-    public static final boolean isDoubleStringOp(final Object obj0,
-            final Object obj1) {
-        return (isDoubleOp(obj0, obj1)
-                || (obj0 instanceof String && isStringFloat((String) obj0)) || (obj1
instanceof String && isStringFloat((String) obj1)));
-    }
-
     public static final boolean isLongOp(final Object obj0, final Object obj1) {
         return (obj0 instanceof Long
                 || obj1 instanceof Long
@@ -514,30 +467,6 @@ public class ELSupport {
         return false;
     }
 
-    public static final Number toFloat(final String value) {
-        try {
-            if (Double.parseDouble(value) > Double.MAX_VALUE) {
-                return new BigDecimal(value);
-            } else {
-                return new Double(value);
-            }
-        } catch (NumberFormatException e0) {
-            return new BigDecimal(value);
-        }
-    }
-
-    public static final Number toNumber(final String value) {
-        try {
-            return new Integer(Integer.parseInt(value));
-        } catch (NumberFormatException e0) {
-            try {
-                return new Long(Long.parseLong(value));
-            } catch (NumberFormatException e1) {
-                return new BigInteger(value);
-            }
-        }
-    }
-
     /**
      * 
      */

Modified: tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java?rev=1050660&r1=1050659&r2=1050660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ExpressionBuilder.java Sat Dec 18 16:23:09 2010
@@ -183,6 +183,7 @@ public final class ExpressionBuilder imp
      *
      * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
      */
+    @Override
     public void visit(Node node) throws ELException {
         if (node instanceof AstFunction) {
 

Modified: tomcat/trunk/java/org/apache/el/lang/FunctionMapperImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/FunctionMapperImpl.java?rev=1050660&r1=1050659&r2=1050660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/FunctionMapperImpl.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/FunctionMapperImpl.java Sat Dec 18 16:23:09 2010
@@ -71,6 +71,7 @@ public class FunctionMapperImpl extends 
      * 
      * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
      */
+    @Override
     public void writeExternal(ObjectOutput out) throws IOException {
         out.writeObject(this.functions);
     }
@@ -80,6 +81,8 @@ public class FunctionMapperImpl extends 
      * 
      * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
      */
+    @SuppressWarnings("unchecked")
+    @Override
     public void readExternal(ObjectInput in) throws IOException,
             ClassNotFoundException {
         this.functions = (Map<String, Function>) in.readObject();
@@ -118,6 +121,7 @@ public class FunctionMapperImpl extends 
          * 
          * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
          */
+        @Override
         public void writeExternal(ObjectOutput out) throws IOException {
             out.writeUTF((this.prefix != null) ? this.prefix : "");
             out.writeUTF(this.localName);
@@ -140,6 +144,7 @@ public class FunctionMapperImpl extends 
          * 
          * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
          */
+        @Override
         public void readExternal(ObjectInput in) throws IOException,
                 ClassNotFoundException {
 
@@ -164,14 +169,6 @@ public class FunctionMapperImpl extends 
             return this.m;
         }
 
-        public boolean matches(String prefix, String localName) {
-            if (this.prefix != null) {
-                if (prefix == null) return false;
-                if (!this.prefix.equals(prefix)) return false;
-            }
-            return this.localName.equals(localName);
-        }
-
         /* (non-Javadoc)
          * @see java.lang.Object#equals(java.lang.Object)
          */

Modified: tomcat/trunk/java/org/apache/el/lang/VariableMapperImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/VariableMapperImpl.java?rev=1050660&r1=1050659&r2=1050660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/VariableMapperImpl.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/VariableMapperImpl.java Sat Dec 18 16:23:09 2010
@@ -48,10 +48,13 @@ public class VariableMapperImpl extends 
         return this.vars.put(variable, expression);
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         this.vars = (Map<String, ValueExpression>) in.readObject();
     }
 
+    @Override
     public void writeExternal(ObjectOutput out) throws IOException {
         out.writeObject(this.vars);
     }



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


Mime
View raw message