Author: rahul Date: Sat Jul 18 04:11:49 2009 New Revision: 795308 URL: http://svn.apache.org/viewvc?rev=795308&view=rev Log: Reduce checkstyle and raw type warnings. Patch by Henri Biestro <hbiestro at gmail dot com>. JEXL-20
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlEngine.java commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/Introspector.java commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlEngine.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlEngine.java?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlEngine.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/JexlEngine.java Sat Jul 18 04:11:49 2009 @@ -32,7 +32,6 @@ import org.apache.commons.jexl.parser.ParseException; import org.apache.commons.jexl.parser.Parser; -import org.apache.commons.jexl.parser.Node; import org.apache.commons.jexl.parser.SimpleNode; import org.apache.commons.jexl.parser.TokenMgrError; import org.apache.commons.jexl.parser.ASTJexlScript; @@ -500,8 +499,8 @@ int start = 0; int end = str.length(); if (end > 0) { - for(start = 0; start < end && str.charAt(start) == ' '; ++start); // trim front spaces - for(;end > 0 && str.charAt(end - 1) == ' '; --end); // trim ending spaces + for(start = 0; start < end && str.charAt(start) == ' '; ++start) {} // trim front spaces + for(;end > 0 && str.charAt(end - 1) == ' '; --end) {} // trim ending spaces return str.subSequence(start, end).toString(); } return ""; Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt Sat Jul 18 04:11:49 2009 @@ -41,8 +41,6 @@ import java.io.Reader; import java.io.ByteArrayInputStream; -import org.apache.commons.jexl.util.introspection.Uberspect; - public class Parser extends StringParser { Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/ClassMap.java Sat Jul 18 04:11:49 2009 @@ -18,10 +18,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; @@ -46,7 +43,7 @@ /** * Class passed into the constructor used to as the basis for the Method map. */ - private final Class clazz; + private final Class<?> clazz; /** logger. */ private final Log rlog; /** cache of methods. */ @@ -58,7 +55,7 @@ * @param aClass the class to deconstruct. * @param log the logger. */ - public ClassMap(Class aClass, Log log) { + public ClassMap(Class<?> aClass, Log log) { clazz = aClass; this.rlog = log; methodCache = new MethodCache(); @@ -69,7 +66,7 @@ /** * @return the class object whose methods are cached by this map. */ - Class getCachedClass() { + Class<?> getCachedClass() { return clazz; } @@ -106,11 +103,11 @@ // hit the public elements sooner or later because we reflect all the public elements anyway. // // Ah, the miracles of Java for(;;) ... - for (Class classToReflect = getCachedClass(); classToReflect != null; classToReflect = classToReflect.getSuperclass()) { + for (Class<?> classToReflect = getCachedClass(); classToReflect != null; classToReflect = classToReflect.getSuperclass()) { if (Modifier.isPublic(classToReflect.getModifiers())) { populateMethodCacheWith(methodCache, classToReflect); } - Class[] interfaces = classToReflect.getInterfaces(); + Class<?>[] interfaces = classToReflect.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { populateMethodCacheWithInterface(methodCache, interfaces[i]); } @@ -118,17 +115,17 @@ } /* recurses up interface hierarchy to get all super interfaces */ - private void populateMethodCacheWithInterface(MethodCache methodCache, Class iface) { + private void populateMethodCacheWithInterface(MethodCache methodCache, Class<?> iface) { if (Modifier.isPublic(iface.getModifiers())) { populateMethodCacheWith(methodCache, iface); } - Class[] supers = iface.getInterfaces(); + Class<?>[] supers = iface.getInterfaces(); for (int i = 0; i < supers.length; i++) { populateMethodCacheWithInterface(methodCache, supers[i]); } } - private void populateMethodCacheWith(MethodCache methodCache, Class classToReflect) { + private void populateMethodCacheWith(MethodCache methodCache, Class<?> classToReflect) { try { Method[] methods = classToReflect.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { @@ -178,9 +175,9 @@ return null; } private static final Method CACHE_MISS = CacheMiss(); - private static final Map<Class, Class> convertPrimitives; + private static final Map<Class<?>, Class<?>> convertPrimitives; static { - convertPrimitives = new HashMap<Class, Class>(13); + convertPrimitives = new HashMap<Class<?>, Class<?>>(13); convertPrimitives.put(Boolean.TYPE, Boolean.class); convertPrimitives.put(Byte.TYPE, Byte.class); convertPrimitives.put(Character.TYPE, Character.class); @@ -199,10 +196,10 @@ * correctly. * </p> */ - static final Class primitiveClass(Class parm) { + static final Class<?> primitiveClass(Class<?> parm) { // it is marginally faster to get from the map than call isPrimitive... //if (!parm.isPrimitive()) return parm; - Class prim = convertPrimitives.get(parm); + Class<?> prim = convertPrimitives.get(parm); return prim == null ? parm : prim; } /** @@ -294,13 +291,13 @@ */ static class MethodKey { /** The hash code */ - final int hash; + final int hashCode; /** The method name. */ final String method; /** The parameters. */ - final Class[] params; + final Class<?>[] params; /** A marker for empty parameter list. */ - static final Class[] NOARGS = new Class[0]; + static final Class<?>[] NOARGS = new Class<?>[0]; /** Builds a MethodKey from a method. * Used to store information in the method map. @@ -318,12 +315,12 @@ int hash = this.method.hashCode(); final int size; if (args != null && (size = args.length) > 0) { - this.params = new Class[size]; + this.params = new Class<?>[size]; for (int p = 0; p < size; ++p) { // ctor(Object) : { Object arg = args[p]; // no need to go thru primitive type conversion since these are objects - Class parm = arg == null ? Object.class : arg.getClass(); + Class<?> parm = arg == null ? Object.class : arg.getClass(); // } hash = (37 * hash) + parm.hashCode(); this.params[p] = parm; @@ -331,22 +328,22 @@ } else { this.params = NOARGS; } - this.hash = hash; + this.hashCode = hash; } /** Builds a MethodKey from a method name and a set of parameters (classes). * Used to store information in the method map. ( @see MethodKey#primitiveClass ) */ - MethodKey(String method, Class[] args) { + MethodKey(String method, Class<?>[] args) { // !! keep this in sync with the other ctor (hash code) !! this.method = method; int hash = this.method.hashCode(); final int size; if (args != null && (size = args.length) > 0) { - this.params = new Class[size]; + this.params = new Class<?>[size]; for (int p = 0; p < size; ++p) { // ctor(Class): { - Class parm = MethodCache.primitiveClass(args[p]); + Class<?> parm = MethodCache.primitiveClass(args[p]); // } hash = (37 * hash) + parm.hashCode(); this.params[p] = parm; @@ -354,25 +351,28 @@ } else { this.params = NOARGS; } - this.hash = hash; + this.hashCode = hash; } @Override public int hashCode() { - return hash; + return hashCode; } @Override public boolean equals(Object arg) { - MethodKey key = (MethodKey) arg; - return method.equals(key.method) && java.util.Arrays.equals(params, key.params); + if (arg instanceof MethodKey) { + MethodKey key = (MethodKey) arg; + return method.equals(key.method) && java.util.Arrays.equals(params, key.params); + } + return false; } @Override /** Compatible with original string key. */ public String toString() { StringBuilder builder = new StringBuilder(method); - for (Class c : params) { + for (Class<?> c : params) { builder.append(c.getName()); } return builder.toString(); Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/Introspector.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/Introspector.java?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/Introspector.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/Introspector.java Sat Jul 18 04:11:49 2009 @@ -88,7 +88,7 @@ * CSOFF: RedundantThrows */ @Override - public Method getMethod(Class c, String name, Object[] params) throws IllegalArgumentException { + public Method getMethod(Class<?> c, String name, Object[] params) throws IllegalArgumentException { /* * just delegate to the base class */ @@ -121,6 +121,7 @@ * Clears the classmap and classname * caches, and logs that we did so. */ + @Override protected void clearCache() { super.clearCache(); rlog.info(CACHEDUMP_MSG); Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/IntrospectorBase.java Sat Jul 18 04:11:49 2009 @@ -61,7 +61,7 @@ * Made WeakHashMap so we wont prevent a class from being GCed. * object. */ - protected final Map<Class, ClassMap> classMethodMaps = new java.util.WeakHashMap<Class, ClassMap>(); + protected final Map<Class<?>, ClassMap> classMethodMaps = new java.util.WeakHashMap<Class<?>, ClassMap>(); /** * Holds the qualified class names for the classes we hold in the @@ -91,7 +91,7 @@ * one match for the requested signature. * CSOFF: RedundantThrows */ - public Method getMethod(Class c, String name, Object[] params) + public Method getMethod(Class<?> c, String name, Object[] params) throws IllegalArgumentException, MethodMap.AmbiguousException { if (c == null) { throw new IllegalArgumentException("Introspector.getMethod(): Class method key was null: " + name); @@ -135,7 +135,7 @@ * @param c class. * @return a {...@link ClassMap} */ - protected ClassMap createClassMap(Class c) { + protected ClassMap createClassMap(Class<?> c) { ClassMap classMap = new ClassMap(c,rlog); classMethodMaps.put(c, classMap); cachedClassNames.add(c.getName()); Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java?rev=795308&r1=795307&r2=795308&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java (original) +++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/util/introspection/UberspectImpl.java Sat Jul 18 04:11:49 2009 @@ -105,7 +105,7 @@ + i.getColumn() + "]" + " in template " + i.getTemplateName() + ". Because it's not resetable," + " if used in more than once, this may lead to" + " unexpected results."); - return new EnumerationIterator((Enumeration<?>) obj); + return new EnumerationIterator<Object>((Enumeration<Object>) obj); } else { // look for an iterator() method to support the JDK5 Iterable // interface or any user tools/DTOs that want to work in