Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java Sat Jan 28 19:21:08 2017 @@ -100,7 +100,7 @@ public class ASTDirective extends Simple { Token t; - /** method is synchronized to avoid concurrent directive initialization **/ + /* method is synchronized to avoid concurrent directive initialization **/ if (!isInitialized) { @@ -130,17 +130,10 @@ public class ASTDirective extends Simple try { - directive = (Directive) parser.getDirective( directiveName ) + directive = parser.getDirective( directiveName ) .getClass().newInstance(); } - catch (InstantiationException e) - { - throw new VelocityException( - "Couldn't initialize directive of class " + - parser.getDirective(directiveName).getClass().getName(), - e); - } - catch (IllegalAccessException e) + catch (InstantiationException | IllegalAccessException e) { throw new VelocityException( "Couldn't initialize directive of class " + @@ -186,22 +179,22 @@ public class ASTDirective extends Simple } else { - /** - * Create a new RuntimeMacro + /* + Create a new RuntimeMacro */ directive = new RuntimeMacro(); directive.setLocation(getLine(), getColumn(), getTemplate()); - /** - * Initialize it + /* + Initialize it */ try { ((RuntimeMacro)directive).init( rsvc, directiveName, context, this ); } - /** - * correct the line/column number if an exception is caught + /* + correct the line/column number if an exception is caught */ catch (TemplateInitException die) {
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java Sat Jan 28 19:21:08 2017 @@ -85,7 +85,7 @@ public class ASTElseIfStatement extends * where this node was originally asked to evaluate * itself. * @param context - * @return True if all childs are true. + * @return True if all children are true. * @throws MethodInvocationException */ public boolean evaluate ( InternalContextAdapter context) Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java Sat Jan 28 19:21:08 2017 @@ -93,7 +93,7 @@ public class ASTFloatingPointLiteral ext } catch ( NumberFormatException E1 ) { - // if there's still an Exception it will propogate out + // if there's still an Exception it will propqgate out value = new BigDecimal( str ); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java Sat Jan 28 19:21:08 2017 @@ -37,7 +37,7 @@ import java.lang.reflect.InvocationTarge * * Method support for identifiers : $foo * - * mainly used by ASTRefrence + * mainly used by ASTReference * * Introspection is now moved to 'just in time' or at render / execution * time. There are many reasons why this has to be done, but the @@ -133,7 +133,7 @@ public class ASTIdentifier extends Simpl /* * if we have the cache data and the class of the object we are * invoked with is the same as that in the cache, then we must - * be allright. The last 'variable' is the method name, and + * be all right. The last 'variable' is the method name, and * that is fixed in the template :) */ Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java Sat Jan 28 19:21:08 2017 @@ -95,7 +95,7 @@ public class ASTIndex extends SimpleNode public static Object adjMinusIndexArg(Object argument, Object o, InternalContextAdapter context, SimpleNode node) { - if (argument instanceof Integer && ((Integer)argument).intValue() < 0) + if (argument instanceof Integer && (Integer) argument < 0) { // The index value is a negative number, $foo[-1], so we want to actually // Index [size - value], so try and call the size method. @@ -106,7 +106,7 @@ public class ASTIndex extends SimpleNode // The object doesn't have a size method, so there is no notion of "at the end" throw new VelocityException( "A 'size()' method required for negative value " - + ((Integer)argument).intValue() + " does not exist for class '" + + (Integer) argument + " does not exist for class '" + o.getClass().getName() + "' at " + StringUtils.formatFileString(node)); } @@ -124,7 +124,7 @@ public class ASTIndex extends SimpleNode int sizeint = 0; try { - sizeint = ((Integer)size).intValue(); + sizeint = (Integer) size; } catch (ClassCastException e) { @@ -134,7 +134,7 @@ public class ASTIndex extends SimpleNode + "' when Integer was expected at " + StringUtils.formatFileString(node)); } - argument = Integer.valueOf(sizeint + ((Integer)argument).intValue()); + argument = sizeint + ((Integer) argument).intValue(); } // Nothing to do, return the original argument Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java Sat Jan 28 19:21:08 2017 @@ -90,7 +90,7 @@ public class ASTIntegerLiteral extends S } catch ( NumberFormatException E2 ) { - // if there's still an Exception it will propogate out + // if there's still an Exception it will propagate out value = new BigInteger( str ); } } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java Sat Jan 28 19:21:08 2017 @@ -137,7 +137,7 @@ public class ASTIntegerRange extends Sim for (int i = 0; i < nbrElements; i++) { - elements.add(Integer.valueOf(value)); + elements.add(value); value += delta; } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java Sat Jan 28 19:21:08 2017 @@ -30,7 +30,7 @@ import java.util.Map; /** * AST Node for creating a map / dictionary. * - * This class was originally generated from Parset.jjt. + * This class was originally generated from Parser.jjt. * * @version $Id$ * @since 1.5 Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Sat Jan 28 19:21:08 2017 @@ -368,9 +368,8 @@ public class ASTMethod extends SimpleNod * note we skip the null test for methodName and params * due to the earlier test in the constructor */ - for (int i = 0; i < params.length; ++i) + for (Class param : params) { - final Class param = params[i]; if (param != null) { result = result * 37 + param.hashCode(); Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java Sat Jan 28 19:21:08 2017 @@ -61,10 +61,7 @@ public class ASTNotNode extends SimpleNo public boolean evaluate( InternalContextAdapter context) throws MethodInvocationException { - if (jjtGetChild(0).evaluate(context)) - return false; - else - return true; + return !jjtGetChild(0).evaluate(context); } /** Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java Sat Jan 28 19:21:08 2017 @@ -106,9 +106,6 @@ public class ASTOrNode extends ASTLogica * same for right */ - if ( right != null && right.evaluate( context ) ) - return true; - - return false; + return right != null && right.evaluate(context); } } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java Sat Jan 28 19:21:08 2017 @@ -392,7 +392,7 @@ public class ASTReference extends Simple { /** * If we are in strict mode and the variable is escaped, then don't bother to - * retreive the value since we won't use it. And if the var is not defined + * retrieve the value since we won't use it. And if the var is not defined * it will throw an exception. Set value to TRUE to fall through below with * simply printing $foo, and not \$foo */ @@ -824,8 +824,8 @@ public class ASTReference extends Simple } /* - * lets do all the work here. I would argue that if this occurrs, - * it's not a reference at all, so preceeding \ characters in front + * lets do all the work here. I would argue that if this occurs, + * it's not a reference at all, so preceding \ characters in front * of the $ are just schmoo. So we just do the escape processing * trick (even | odd) and move on. This kind of breaks the rule * pattern of $ and # but '!' really tosses a wrench into things. @@ -888,7 +888,7 @@ public class ASTReference extends Simple * we need to see if this reference is escaped. if so * we will clean off the leading \'s and let the * regular behavior determine if we should output this - * as \$foo or $foo later on in render(). Lazyness.. + * as \$foo or $foo later on in render(). Laziness.. */ escaped = false; @@ -917,7 +917,7 @@ public class ASTReference extends Simple } /* - * Look for preceeding stuff like '#' and '$' + * Look for preceding stuff like '#' and '$' * and snip it off, except for the * last $ */ @@ -995,7 +995,7 @@ public class ASTReference extends Simple { /* * this is a 'RUNT', which can happen in certain circumstances where - * the parser is fooled into believeing that an IDENTIFIER is a real + * the parser is fooled into believing that an IDENTIFIER is a real * reference. Another 'dreaded' MORE hack :). */ referenceType = RUNT; Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java Sat Jan 28 19:21:08 2017 @@ -207,7 +207,7 @@ public class ASTSetDirective extends Sim * puts the value of the RHS into the context under the key of the LHS * @param context * @param writer - * @return True if rendering was sucessful. + * @return True if rendering was sucessfull. * @throws IOException * @throws MethodInvocationException */ @@ -254,7 +254,7 @@ public class ASTSetDirective extends Sim /** - * returns the ASTReference that is the LHS of the set statememt + * returns the ASTReference that is the LHS of the set statement * * @return left hand side of #set statement */ Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java Sat Jan 28 19:21:08 2017 @@ -174,7 +174,7 @@ public class ASTStringLiteral extends Si /** * Adjust all the line and column numbers that comprise a node so that they * are corrected for the string literals position within the template file. - * This is neccessary if an exception is thrown while processing the node so + * This is necessary if an exception is thrown while processing the node so * that the line and column position reported reflects the error position * within the template and not just relative to the error position within * the string literal. @@ -182,7 +182,7 @@ public class ASTStringLiteral extends Si public void adjTokenLineNums(Node node) { Token tok = node.getFirstToken(); - // Test against null is probably not neccessary, but just being safe + // Test against null is probably not necessary, but just being safe while(tok != null && tok != node.getLastToken()) { // If tok is on the first line, then the actual column is @@ -209,8 +209,8 @@ public class ASTStringLiteral extends Si */ private String replaceQuotes(String s, char literalQuoteChar) { - if( (literalQuoteChar == '"' && s.indexOf("\"") == -1) || - (literalQuoteChar == '\'' && s.indexOf("'") == -1) ) + if( (literalQuoteChar == '"' && !s.contains("\"")) || + (literalQuoteChar == '\'' && !s.contains("'")) ) { return s; } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java Sat Jan 28 19:21:08 2017 @@ -86,7 +86,7 @@ public class MapGetExecutor { try { - instance = Map.class.getMethod("get", new Class[]{Object.class}); + instance = Map.class.getMethod("get", Object.class); } catch (final NoSuchMethodException mapGetMethodMissingError) { Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java Sat Jan 28 19:21:08 2017 @@ -47,25 +47,25 @@ public class MapSetExecutor protected void discover (final Class clazz) { Class [] interfaces = clazz.getInterfaces(); - for (int i = 0 ; i < interfaces.length; i++) + for (Class anInterface : interfaces) { - if (interfaces[i].equals(Map.class)) + if (anInterface.equals(Map.class)) { try { if (property != null) { - setMethod(Map.class.getMethod("put", new Class [] { Object.class, Object.class })); + setMethod(Map.class.getMethod("put", Object.class, Object.class)); } } /** * pass through application level runtime exceptions */ - catch( RuntimeException e ) + catch (RuntimeException e) { throw e; } - catch(Exception e) + catch (Exception e) { String msg = "Exception while looking for put('" + property + "') method"; log.error(msg, e); Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java Sat Jan 28 19:21:08 2017 @@ -184,7 +184,7 @@ public abstract class MathUtils } else { - return Byte.valueOf((byte)value); + return (byte) value; } } if (type == Short.class) @@ -195,7 +195,7 @@ public abstract class MathUtils } else { - return Short.valueOf((short)value); + return (short) value; } } if (type == Integer.class) @@ -206,12 +206,12 @@ public abstract class MathUtils } else { - return Integer.valueOf((int)value); + return (int) value; } } if (type == Long.class) { - return Long.valueOf(value); + return value; } return BigInteger.valueOf(value); } @@ -319,9 +319,9 @@ public abstract class MathUtils } return wrapPrimitive( result, op1, op2); case BASE_FLOAT: - return new Float (op1.floatValue()+op2.floatValue()); + return op1.floatValue() + op2.floatValue(); case BASE_DOUBLE: - return new Double (op1.doubleValue()+op2.doubleValue()); + return op1.doubleValue() + op2.doubleValue(); // Default is BigDecimal operation default: @@ -353,9 +353,9 @@ public abstract class MathUtils } return wrapPrimitive( result, op1, op2); case BASE_FLOAT: - return new Float (op1.floatValue()-op2.floatValue()); + return op1.floatValue() - op2.floatValue(); case BASE_DOUBLE: - return new Double (op1.doubleValue()-op2.doubleValue()); + return op1.doubleValue() - op2.doubleValue(); // Default is BigDecimal operation default: @@ -387,9 +387,9 @@ public abstract class MathUtils } return wrapPrimitive( result, op1, op2); case BASE_FLOAT: - return new Float (op1.floatValue()*op2.floatValue()); + return op1.floatValue() * op2.floatValue(); case BASE_DOUBLE: - return new Double (op1.doubleValue()*op2.doubleValue()); + return op1.doubleValue() * op2.doubleValue(); // Default is BigDecimal operation default: @@ -420,9 +420,9 @@ public abstract class MathUtils return wrapPrimitive( l1 / l2, op1, op2); case BASE_FLOAT: - return new Float (op1.floatValue()/op2.floatValue()); + return op1.floatValue() / op2.floatValue(); case BASE_DOUBLE: - return new Double (op1.doubleValue()/op2.doubleValue()); + return op1.doubleValue() / op2.doubleValue(); // Default is BigDecimal operation default: @@ -447,9 +447,9 @@ public abstract class MathUtils case BASE_LONG: return wrapPrimitive( op1.longValue() % op2.longValue(), op1, op2); case BASE_FLOAT: - return new Float (op1.floatValue() % op2.floatValue()); + return op1.floatValue() % op2.floatValue(); case BASE_DOUBLE: - return new Double (op1.doubleValue() % op2.doubleValue()); + return op1.doubleValue() % op2.doubleValue(); // Default is BigDecimal operation default: Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java Sat Jan 28 19:21:08 2017 @@ -43,12 +43,12 @@ public interface Node extends Renderable { /** This method is called after the node has been made the current * node. It indicates that child nodes can now be added to it. */ - public void jjtOpen(); + void jjtOpen(); /** This method is called after all the child nodes have been added. */ - public void jjtClose(); + void jjtClose(); /** * This pair of methods are used to inform the node of its @@ -56,12 +56,12 @@ public interface Node extends Renderable * @param n * */ - public void jjtSetParent(Node n); + void jjtSetParent(Node n); /** * @return The node parent. */ - public Node jjtGetParent(); + Node jjtGetParent(); /** * This method tells the node to add its argument to the node's @@ -69,7 +69,7 @@ public interface Node extends Renderable * @param n * @param i */ - public void jjtAddChild(Node n, int i); + void jjtAddChild(Node n, int i); /** * This method returns a child node. The children are numbered @@ -77,20 +77,20 @@ public interface Node extends Renderable * @param i * @return A child node. */ - public Node jjtGetChild(int i); + Node jjtGetChild(int i); /** * Return the number of children the node has. * @return The number of children of this node. */ - public int jjtGetNumChildren(); + int jjtGetNumChildren(); /** * @param visitor * @param data * @return The Node execution result object. */ - public Object jjtAccept(ParserVisitor visitor, Object data); + Object jjtAccept(ParserVisitor visitor, Object data); /* * ======================================================================== @@ -107,20 +107,20 @@ public interface Node extends Renderable * @param data * @return The node execution result. */ - public Object childrenAccept(ParserVisitor visitor, Object data); + Object childrenAccept(ParserVisitor visitor, Object data); /** * @return The first token. */ - public Token getFirstToken(); + Token getFirstToken(); /** * @return The last token. */ - public Token getLastToken(); + Token getLastToken(); /** * @return The NodeType. */ - public int getType(); + int getType(); /** * @param context @@ -128,14 +128,14 @@ public interface Node extends Renderable * @return The init result. * @throws TemplateInitException */ - public Object init( InternalContextAdapter context, Object data) throws TemplateInitException; + Object init(InternalContextAdapter context, Object data) throws TemplateInitException; /** * @param context * @return The evaluation result. * @throws MethodInvocationException */ - public boolean evaluate( InternalContextAdapter context) + boolean evaluate(InternalContextAdapter context) throws MethodInvocationException; /** @@ -143,7 +143,7 @@ public interface Node extends Renderable * @return The node value. * @throws MethodInvocationException */ - public Object value( InternalContextAdapter context) + Object value(InternalContextAdapter context) throws MethodInvocationException; /** @@ -155,7 +155,7 @@ public interface Node extends Renderable * @throws ParseErrorException * @throws ResourceNotFoundException */ - public boolean render( InternalContextAdapter context, Writer writer) + boolean render(InternalContextAdapter context, Writer writer) throws IOException,MethodInvocationException, ParseErrorException, ResourceNotFoundException; /** @@ -164,61 +164,61 @@ public interface Node extends Renderable * @return The execution result. * @throws MethodInvocationException */ - public Object execute(Object o, InternalContextAdapter context) + Object execute(Object o, InternalContextAdapter context) throws MethodInvocationException; /** * @param info */ - public void setInfo(int info); + void setInfo(int info); /** * @return The current node info. */ - public int getInfo(); + int getInfo(); /** * @return A literal. */ - public String literal(); + String literal(); /** * Mark the node as invalid. */ - public void setInvalid(); + void setInvalid(); /** * @return True if the node is invalid. */ - public boolean isInvalid(); + boolean isInvalid(); /** * @return The current line position. */ - public int getLine(); + int getLine(); /** * @return The current column position. */ - public int getColumn(); + int getColumn(); /** * @return the file name of the template */ - public String getTemplateName(); + String getTemplateName(); /** * @return cached image (String) of the first Token for this Node returned by the Parser */ - public String getFirstTokenImage(); + String getFirstTokenImage(); /** * @return cached image (String) of the last Token for this Node returned by the Parser */ - public String getLastTokenImage(); + String getLastTokenImage(); /** * @return the template this node belongs to */ - public Template getTemplate(); + Template getTemplate(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java Sat Jan 28 19:21:08 2017 @@ -34,7 +34,7 @@ public interface ParserVisitor * @param data * @return The object rendered by this node. */ - public Object visit(SimpleNode node, Object data); + Object visit(SimpleNode node, Object data); /** * @param node @@ -42,76 +42,76 @@ public interface ParserVisitor * @return The object rendered by this node. */ - public Object visit(ASTprocess node, Object data); + Object visit(ASTprocess node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTText node, Object data); + Object visit(ASTText node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTEscapedDirective node, Object data); + Object visit(ASTEscapedDirective node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTEscape node, Object data); + Object visit(ASTEscape node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTComment node, Object data); + Object visit(ASTComment node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTTextblock node, Object data); + Object visit(ASTTextblock node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTFloatingPointLiteral node, Object data); + Object visit(ASTFloatingPointLiteral node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTIntegerLiteral node, Object data); + Object visit(ASTIntegerLiteral node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTStringLiteral node, Object data); + Object visit(ASTStringLiteral node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTIdentifier node, Object data); + Object visit(ASTIdentifier node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTWord node, Object data); + Object visit(ASTWord node, Object data); /** * @param node @@ -119,216 +119,216 @@ public interface ParserVisitor * @return The object rendered by this node. */ - public Object visit(ASTDirectiveAssign node, Object data); + Object visit(ASTDirectiveAssign node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTDirective node, Object data); + Object visit(ASTDirective node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTBlock node, Object data); + Object visit(ASTBlock node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTMap node, Object data); + Object visit(ASTMap node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTObjectArray node, Object data); + Object visit(ASTObjectArray node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTIntegerRange node, Object data); + Object visit(ASTIntegerRange node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTMethod node, Object data); + Object visit(ASTMethod node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTIndex node, Object data); + Object visit(ASTIndex node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTReference node, Object data); + Object visit(ASTReference node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTTrue node, Object data); + Object visit(ASTTrue node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTFalse node, Object data); + Object visit(ASTFalse node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTIfStatement node, Object data); + Object visit(ASTIfStatement node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTElseStatement node, Object data); + Object visit(ASTElseStatement node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTElseIfStatement node, Object data); + Object visit(ASTElseIfStatement node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTSetDirective node, Object data); + Object visit(ASTSetDirective node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTExpression node, Object data); + Object visit(ASTExpression node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTAssignment node, Object data); + Object visit(ASTAssignment node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTOrNode node, Object data); + Object visit(ASTOrNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTAndNode node, Object data); + Object visit(ASTAndNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTEQNode node, Object data); + Object visit(ASTEQNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTNENode node, Object data); + Object visit(ASTNENode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTLTNode node, Object data); + Object visit(ASTLTNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTGTNode node, Object data); + Object visit(ASTGTNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTLENode node, Object data); + Object visit(ASTLENode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTGENode node, Object data); + Object visit(ASTGENode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTAddNode node, Object data); + Object visit(ASTAddNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTSubtractNode node, Object data); + Object visit(ASTSubtractNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTMulNode node, Object data); + Object visit(ASTMulNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTDivNode node, Object data); + Object visit(ASTDivNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTModNode node, Object data); + Object visit(ASTModNode node, Object data); /** * @param node * @param data * @return The object rendered by this node. */ - public Object visit(ASTNotNode node, Object data); + Object visit(ASTNotNode node, Object data); /** * @param node Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java Sat Jan 28 19:21:08 2017 @@ -232,9 +232,9 @@ public class SimpleNode implements Node { if (children != null) { - for (int i = 0; i < children.length; ++i) + for (Node aChildren : children) { - children[i].jjtAccept(visitor, data); + aChildren.jjtAccept(visitor, data); } } return data; Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java Sat Jan 28 19:21:08 2017 @@ -38,7 +38,7 @@ public interface ResourceCache * * @param rs RuntimeServices to use for logging, etc */ - public void initialize( RuntimeServices rs ); + void initialize(RuntimeServices rs); /** * retrieves a Resource from the @@ -47,7 +47,7 @@ public interface ResourceCache * @param resourceKey key for Resource to be retrieved * @return Resource specified or null if not found */ - public Resource get( Object resourceKey ); + Resource get(Object resourceKey); /** * stores a Resource in the cache @@ -56,7 +56,7 @@ public interface ResourceCache * @param resource Resource to be stored * @return existing Resource stored under this key, or null if none */ - public Resource put( Object resourceKey, Resource resource ); + Resource put(Object resourceKey, Resource resource); /** * removes a Resource from the cache @@ -64,18 +64,18 @@ public interface ResourceCache * @param resourceKey resource to be removed * @return stored under key */ - public Resource remove( Object resourceKey ); + Resource remove(Object resourceKey); /** * Removes all of the resources from this cache. * The cache will be empty after this call returns. * @since 2.0 */ - public void clear(); + void clear(); /** * returns an Iterator of Keys in the cache. * @return An Iterator of Keys in the cache. */ - public Iterator enumerateKeys(); + Iterator enumerateKeys(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java Sat Jan 28 19:21:08 2017 @@ -88,7 +88,7 @@ public class ResourceCacheImpl implement /** * Cache storage, assumed to be thread-safe. */ - protected Map<Object, Resource> cache = new ConcurrentHashMap<Object, Resource>(512, 0.5f, 30); + protected Map<Object, Resource> cache = new ConcurrentHashMap<>(512, 0.5f, 30); /** * Runtime services, generally initialized by the @@ -123,7 +123,7 @@ public class ResourceCacheImpl implement */ public Resource get( Object key ) { - return (Resource) cache.get( key ); + return cache.get( key ); } /** @@ -131,7 +131,7 @@ public class ResourceCacheImpl implement */ public Resource put( Object key, Resource value ) { - return (Resource) cache.put( key, value ); + return cache.put( key, value ); } /** @@ -139,7 +139,7 @@ public class ResourceCacheImpl implement */ public Resource remove( Object key ) { - return (Resource) cache.remove( key ); + return cache.remove( key ); } /** Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java Sat Jan 28 19:21:08 2017 @@ -37,18 +37,18 @@ public interface ResourceManager /** * A template resources. */ - public static final int RESOURCE_TEMPLATE = 1; + int RESOURCE_TEMPLATE = 1; /** * A static content resource. */ - public static final int RESOURCE_CONTENT = 2; + int RESOURCE_CONTENT = 2; /** * Initialize the ResourceManager. * @param rs */ - public void initialize( RuntimeServices rs ); + void initialize(RuntimeServices rs); /** * Gets the named resource. Returned class type corresponds to specified type @@ -64,7 +64,7 @@ public interface ResourceManager * @throws ParseErrorException if template cannot be parsed due * to syntax (or other) error. */ - public Resource getResource(String resourceName, int resourceType, String encoding ) + Resource getResource(String resourceName, int resourceType, String encoding) throws ResourceNotFoundException, ParseErrorException; /** @@ -76,6 +76,6 @@ public interface ResourceManager * @param resourceName Name of template or content resource * @return class name of loader than can provide it */ - public String getLoaderNameForResource(String resourceName ); + String getLoaderNameForResource(String resourceName); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java Sat Jan 28 19:21:08 2017 @@ -64,7 +64,7 @@ public class ResourceManagerImpl protected ResourceCache globalCache = null; /** The List of templateLoaders that the Runtime will use to locate the InputStream source of a template. */ - protected final List resourceLoaders = new ArrayList(); + protected final List<ResourceLoader> resourceLoaders = new ArrayList<>(); /** * This is a list of the template input stream source initializers, basically properties for a particular template stream @@ -72,7 +72,7 @@ public class ResourceManagerImpl * * <p><loader-id>.resource.loader.<property> = <value></p> */ - private final List sourceInitializerList = new ArrayList(); + private final List<ExtProperties> sourceInitializerList = new ArrayList<>(); /** * Has this Manager been initialized? @@ -91,7 +91,7 @@ public class ResourceManagerImpl /** * Initialize the ResourceManager. * - * @param rsvc The Runtime Services object which is associated with this Resource Manager. + * @param rs The Runtime Services object which is associated with this Resource Manager. */ public synchronized void initialize(final RuntimeServices rs) { @@ -110,13 +110,12 @@ public class ResourceManagerImpl assembleResourceLoaderInitializers(); - for (Iterator it = sourceInitializerList.iterator(); it.hasNext();) + for (ExtProperties configuration : sourceInitializerList) { /** * Resource loader can be loaded either via class name or be passed * in as an instance. */ - ExtProperties configuration = (ExtProperties) it.next(); String loaderClass = StringUtils.trim(configuration.getString("class")); ResourceLoader loaderInstance = (ResourceLoader) configuration.get("instance"); @@ -124,17 +123,15 @@ public class ResourceManagerImpl if (loaderInstance != null) { resourceLoader = loaderInstance; - } - else if (loaderClass != null) + } else if (loaderClass != null) { resourceLoader = ResourceLoaderFactory.getLoader(rsvc, loaderClass); - } - else + } else { String msg = "Unable to find '" + - configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER) + - ".resource.loader.class' specification in configuration." + - " This is a critical value. Please adjust configuration."; + configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER) + + ".resource.loader.class' specification in configuration." + + " This is a critical value. Please adjust configuration."; log.error(msg); throw new VelocityException(msg); } @@ -330,11 +327,6 @@ public class ResourceManagerImpl return getResource(resourceName, resourceType, encoding); } - catch (ParseErrorException pee) - { - log.error("ResourceManager.getResource() exception", pee); - throw pee; - } catch (RuntimeException re) { log.error("ResourceManager.getResource() exception", re); @@ -419,9 +411,8 @@ public class ResourceManagerImpl long howOldItWas = 0; - for (Iterator it = resourceLoaders.iterator(); it.hasNext();) + for (ResourceLoader resourceLoader : resourceLoaders) { - ResourceLoader resourceLoader = (ResourceLoader) it.next(); resource.setResourceLoader(resourceLoader); /* @@ -446,7 +437,7 @@ public class ResourceManagerImpl if (logWhenFound) { log.debug("ResourceManager: found {} with loader {}", - resourceName, resourceLoader.getClassName()); + resourceName, resourceLoader.getClassName()); } howOldItWas = resourceLoader.getLastModified(resource); @@ -594,9 +585,8 @@ public class ResourceManagerImpl */ private ResourceLoader getLoaderForResource(String resourceName) { - for (Iterator i = resourceLoaders.iterator(); i.hasNext(); ) + for (ResourceLoader loader : resourceLoaders) { - ResourceLoader loader = (ResourceLoader)i.next(); if (loader.resourceExists(resourceName)) { return loader; Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Sat Jan 28 19:21:08 2017 @@ -260,23 +260,14 @@ public class DataSourceResourceLoader ex } } - catch (SQLException sqle) + catch (SQLException | NamingException sqle) { String msg = "DataSourceResourceLoader: database problem while getting resource '" + name + "': "; log.error(msg, sqle); throw new ResourceNotFoundException(msg); - } - catch (NamingException ne) - { - String msg = "DataSourceResourceLoader: database problem while getting resource '" - + name + "': "; - - log.error(msg, ne); - throw new ResourceNotFoundException(msg); - } - finally + } finally { closeResultSet(rs); closeStatement(ps); @@ -329,7 +320,7 @@ public class DataSourceResourceLoader ex throw new ResourceNotFoundException(msg); } } - catch (SQLException sqle) + catch (SQLException | NamingException sqle) { String msg = "DataSourceResourceLoader: database problem while " + operation + " of '" + name + "': "; @@ -337,14 +328,6 @@ public class DataSourceResourceLoader ex log.error(msg, sqle); throw new VelocityException(msg, sqle); } - catch (NamingException ne) - { - String msg = "DataSourceResourceLoader: database problem while " - + operation + " of '" + name + "': "; - - log.error(msg, ne); - throw new VelocityException(msg, ne); - } finally { closeResultSet(rs); Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java Sat Jan 28 19:21:08 2017 @@ -55,7 +55,7 @@ public class FileResourceLoader extends /** * The paths to search for templates. */ - private List paths = new ArrayList(); + private List<String> paths = new ArrayList<>(); /** * Used to map the path that a template was found on @@ -124,9 +124,8 @@ public class FileResourceLoader extends } int size = paths.size(); - for (int i = 0; i < size; i++) + for (String path : paths) { - String path = (String) paths.get(i); InputStream rawStream = null; Reader reader = null; @@ -182,9 +181,8 @@ public class FileResourceLoader extends } int size = paths.size(); - for (int i = 0; i < size; i++) + for (String path : paths) { - String path = (String)paths.get(i); try { File file = getFile(path, name); Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java Sat Jan 28 19:21:08 2017 @@ -125,7 +125,7 @@ public class JarResourceLoader extends R log.error(msg); throw new RuntimeException(msg); } - if ( path.indexOf("!/") < 0 ) + if (!path.contains("!/")) { path += "!/"; } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java Sat Jan 28 19:21:08 2017 @@ -281,7 +281,7 @@ public abstract class ResourceLoader * @since 2.0 */ protected Reader buildReader(InputStream rawStream, String encoding) - throws IOException, UnsupportedEncodingException + throws IOException { UnicodeInputStream inputStream = new UnicodeInputStream(rawStream); /* Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java Sat Jan 28 19:21:08 2017 @@ -58,9 +58,9 @@ public class URLResourceLoader extends R roots = configuration.getStringArray("root"); if (log.isDebugEnabled()) { - for (int i=0; i < roots.length; i++) + for (String root : roots) { - log.debug("URLResourceLoader : adding root '{}'", roots[i]); + log.debug("URLResourceLoader : adding root '{}'", root); } } @@ -109,12 +109,12 @@ public class URLResourceLoader extends R Reader reader = null; Exception exception = null; - for(int i=0; i < roots.length; i++) + for (String root : roots) { InputStream rawStream = null; try { - URL u = new URL(roots[i] + name); + URL u = new URL(root + name); URLConnection conn = u.openConnection(); tryToSetTimeout(conn); rawStream = conn.getInputStream(); @@ -122,14 +122,14 @@ public class URLResourceLoader extends R if (reader != null) { - log.debug("URLResourceLoader: Found '{}' at '{}'", name, roots[i]); + log.debug("URLResourceLoader: Found '{}' at '{}'", name, root); // save this root for later re-use - templateRoots.put(name, roots[i]); + templateRoots.put(name, root); break; } } - catch(IOException ioe) + catch (IOException ioe) { if (rawStream != null) { @@ -137,9 +137,11 @@ public class URLResourceLoader extends R { rawStream.close(); } - catch (IOException e) {} + catch (IOException e) + { + } } - log.debug("URLResourceLoader: Exception when looking for '{}' at '{}'", name, roots[i], ioe); + log.debug("URLResourceLoader: Exception when looking for '{}' at '{}'", name, root, ioe); // only save the first one for later throwing if (exception == null) @@ -178,12 +180,8 @@ public class URLResourceLoader extends R { long fileLastModified = getLastModified(resource); // if the file is unreachable or otherwise changed - if (fileLastModified == 0 || - fileLastModified != resource.getLastModified()) - { - return true; - } - return false; + return fileLastModified == 0 || + fileLastModified != resource.getLastModified(); } /** Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java Sat Jan 28 19:21:08 2017 @@ -108,7 +108,7 @@ public class ArrayIterator implements It } /** - * No op--merely added to satify the <code>Iterator</code> interface. + * No op--merely added to satisfy the <code>Iterator</code> interface. */ public void remove() { Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java Sat Jan 28 19:21:08 2017 @@ -162,9 +162,9 @@ public class ClassUtils { * the cache then uses reflections to inspect Object o, for the given method. * @param methodName Name of method * @param params Array of objects that are parameters to the method - * @param paramClasses Array of Classes coresponding to the types in params. + * @param paramClasses Array of Classes corresponding to the types in params. * @param o Object to introspect for the given method. - * @param context Context from which the method cache is aquirred + * @param context Context from which the method cache is acquired * @param node ASTNode, used for error reporting. * @param strictRef If no method is found, throw an exception, never return null in this case * @return VelMethod object if the object is found, null if not matching method is found @@ -245,7 +245,7 @@ public class ClassUtils { { /* * this can come from the doIntrospection(), as the arg values are - * evaluated to find the right method signature. We just want to propogate + * evaluated to find the right method signature. We just want to propagate * it here, not do anything fancy */ Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java Sat Jan 28 19:21:08 2017 @@ -44,6 +44,6 @@ public interface ContextAware * Initialize the EventHandler. * @param context */ - public void setContext( Context context ); + void setContext(Context context); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java Sat Jan 28 19:21:08 2017 @@ -88,13 +88,9 @@ public class DuckType public static boolean asNull(Object value) { - if (value == null || + return value == null || get(value, Types.STRING) == null || - get(value, Types.NUMBER) == null) - { - return true; - } - return false; + get(value, Types.NUMBER) == null; } public static boolean asBoolean(Object value) @@ -110,12 +106,12 @@ public class DuckType } if (value instanceof Boolean) { - return ((Boolean)value).booleanValue(); + return (Boolean) value; } Object got = get(value, Types.BOOLEAN); if (got != NO_METHOD) { - return ((Boolean)got).booleanValue(); + return (Boolean) got; } if (coerceType) { Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java Sat Jan 28 19:21:08 2017 @@ -776,9 +776,9 @@ public class ExtProperties extends Hasht theWrtr.println(currentOutput.toString()); } else if (value instanceof List) { - List values = (List) value; - for (Iterator it = values.iterator(); it.hasNext(); ) { - String currentElement = (String) it.next(); + List<String> values = (List<String>) value; + for (String currentElement : values) + { StringBuilder currentOutput = new StringBuilder(); currentOutput.append(key); currentOutput.append("="); @@ -994,14 +994,16 @@ public class ExtProperties extends Hasht // Each token is of the form 'key=value'. Properties props = new Properties(defaults); - for (int i = 0; i < tokens.length; i++) { - String token = tokens[i]; + for (String token : tokens) + { int equalSign = token.indexOf('='); - if (equalSign > 0) { + if (equalSign > 0) + { String pkey = token.substring(0, equalSign).trim(); String pvalue = token.substring(equalSign + 1).trim(); props.put(pkey, pvalue); - } else { + } else + { throw new IllegalArgumentException('\'' + token + "' does not contain an equals sign"); } } @@ -1159,7 +1161,7 @@ public class ExtProperties extends Hasht public boolean getBoolean(String key) { Boolean b = getBoolean(key, null); if (b != null) { - return b.booleanValue(); + return b; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1175,7 +1177,7 @@ public class ExtProperties extends Hasht * object that is not a Boolean. */ public boolean getBoolean(String key, boolean defaultValue) { - return getBoolean(key, Boolean.valueOf(defaultValue)).booleanValue(); + return getBoolean(key, Boolean.valueOf(defaultValue)); } /** @@ -1227,12 +1229,18 @@ public class ExtProperties extends Hasht public String testBoolean(String value) { String s = value.toLowerCase(Locale.ROOT); - if (s.equals("true") || s.equals("on") || s.equals("yes")) { - return "true"; - } else if (s.equals("false") || s.equals("off") || s.equals("no")) { - return "false"; - } else { - return null; + switch (s) + { + case "true": + case "on": + case "yes": + return "true"; + case "false": + case "off": + case "no": + return "false"; + default: + return null; } } @@ -1251,7 +1259,7 @@ public class ExtProperties extends Hasht public byte getByte(String key) { Byte b = getByte(key, null); if (b != null) { - return b.byteValue(); + return b; } else { throw new NoSuchElementException('\'' + key + " doesn't map to an existing object"); } @@ -1269,7 +1277,7 @@ public class ExtProperties extends Hasht * by the key has not a valid number format. */ public byte getByte(String key, byte defaultValue) { - return getByte(key, Byte.valueOf(defaultValue)).byteValue(); + return getByte(key, Byte.valueOf(defaultValue)); } /** @@ -1321,7 +1329,7 @@ public class ExtProperties extends Hasht public short getShort(String key) { Short s = getShort(key, null); if (s != null) { - return s.shortValue(); + return s; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1339,7 +1347,7 @@ public class ExtProperties extends Hasht * by the key has not a valid number format. */ public short getShort(String key, short defaultValue) { - return getShort(key, Short.valueOf(defaultValue)).shortValue(); + return getShort(key, Short.valueOf(defaultValue)); } /** @@ -1414,7 +1422,7 @@ public class ExtProperties extends Hasht public int getInteger(String key) { Integer i = getInteger(key, null); if (i != null) { - return i.intValue(); + return i; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1437,7 +1445,7 @@ public class ExtProperties extends Hasht if (i == null) { return defaultValue; } - return i.intValue(); + return i; } /** @@ -1489,7 +1497,7 @@ public class ExtProperties extends Hasht public long getLong(String key) { Long l = getLong(key, null); if (l != null) { - return l.longValue(); + return l; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1507,7 +1515,7 @@ public class ExtProperties extends Hasht * by the key has not a valid number format. */ public long getLong(String key, long defaultValue) { - return getLong(key, Long.valueOf(defaultValue)).longValue(); + return getLong(key, Long.valueOf(defaultValue)); } /** @@ -1559,7 +1567,7 @@ public class ExtProperties extends Hasht public float getFloat(String key) { Float f = getFloat(key, null); if (f != null) { - return f.floatValue(); + return f; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1577,7 +1585,7 @@ public class ExtProperties extends Hasht * by the key has not a valid number format. */ public float getFloat(String key, float defaultValue) { - return getFloat(key, new Float(defaultValue)).floatValue(); + return getFloat(key, new Float(defaultValue)); } /** @@ -1629,7 +1637,7 @@ public class ExtProperties extends Hasht public double getDouble(String key) { Double d = getDouble(key, null); if (d != null) { - return d.doubleValue(); + return d; } else { throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object"); } @@ -1647,7 +1655,7 @@ public class ExtProperties extends Hasht * by the key has not a valid number format. */ public double getDouble(String key, double defaultValue) { - return getDouble(key, new Double(defaultValue)).doubleValue(); + return getDouble(key, new Double(defaultValue)); } /** Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java Sat Jan 28 19:21:08 2017 @@ -37,6 +37,6 @@ public interface RuntimeServicesAware * Called automatically when event cartridge is initialized. * @param rs RuntimeServices object assigned during initialization */ - public void setRuntimeServices( RuntimeServices rs ); + void setRuntimeServices(RuntimeServices rs); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java Sat Jan 28 19:21:08 2017 @@ -23,8 +23,6 @@ import org.apache.velocity.runtime.direc import org.apache.velocity.runtime.parser.node.Node; import org.apache.velocity.util.introspection.Info; -import java.util.List; - /** * This class provides some methods for dynamically * invoking methods in objects, and some string @@ -38,43 +36,43 @@ public class StringUtils { /** * Creates a string that formats the template filename with line number - * and column of the given Directive. We use this routine to provide a cosistent format for displaying + * and column of the given Directive. We use this routine to provide a consistent format for displaying * file errors. */ - public static final String formatFileString(Directive directive) + public static String formatFileString(Directive directive) { return formatFileString(directive.getTemplateName(), directive.getLine(), directive.getColumn()); } /** * Creates a string that formats the template filename with line number - * and column of the given Node. We use this routine to provide a cosistent format for displaying + * and column of the given Node. We use this routine to provide a consistent format for displaying * file errors. */ - public static final String formatFileString(Node node) + public static String formatFileString(Node node) { return formatFileString(node.getTemplateName(), node.getLine(), node.getColumn()); } /** * Simply creates a string that formats the template filename with line number - * and column. We use this routine to provide a cosistent format for displaying + * and column. We use this routine to provide a consistent format for displaying * file errors. */ - public static final String formatFileString(Info info) + public static String formatFileString(Info info) { return formatFileString(info.getTemplateName(), info.getLine(), info.getColumn()); } /** * Simply creates a string that formats the template filename with line number - * and column. We use this routine to provide a cosistent format for displaying + * and column. We use this routine to provide a consistent format for displaying * file errors. * @param template File name of template, can be null * @param linenum Line number within the file * @param colnum Column number withing the file at linenum */ - public static final String formatFileString(String template, int linenum, int colnum) + public static String formatFileString(String template, int linenum, int colnum) { StringBuilder buffer = new StringBuilder(); if (template == null || template.equals("")) Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java Sat Jan 28 19:21:08 2017 @@ -33,6 +33,6 @@ public interface TemplateBoolean * Returns a boolean that can be used in a template. * @return A boolean that can be used in a template. */ - public boolean getAsBoolean(); + boolean getAsBoolean(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java Sat Jan 28 19:21:08 2017 @@ -33,6 +33,6 @@ public interface TemplateNumber * Returns a Number that can be used in a template. * @return A Number that can be used in a template. */ - public Number getAsNumber(); + Number getAsNumber(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java Sat Jan 28 19:21:08 2017 @@ -33,6 +33,6 @@ public interface TemplateString * Returns a String that can be used in a template. * @return A String that can be used in a template. */ - public String getAsString(); + String getAsString(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java Sat Jan 28 19:21:08 2017 @@ -33,5 +33,5 @@ public interface ChainableUberspector ex * * @param inner The decorated uberspector. */ - public void wrap(Uberspect inner); + void wrap(Uberspect inner); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java Sat Jan 28 19:21:08 2017 @@ -123,16 +123,16 @@ public class ClassFieldMap populateFieldCacheWith(fieldCache, classToReflect); } Class [] interfaces = classToReflect.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) + for (Class anInterface : interfaces) { - populateFieldCacheWithInterface(fieldCache, interfaces[i]); + populateFieldCacheWithInterface(fieldCache, anInterface); } } // return the already initialized cache return fieldCache; } - /* recurses up interface heirarchy to get all super interfaces (VELOCITY-689) */ + /* recurses up interface hierarchy to get all super interfaces (VELOCITY-689) */ private void populateFieldCacheWithInterface(Map fieldCache, Class iface) { if (Modifier.isPublic(iface.getModifiers())) @@ -140,9 +140,9 @@ public class ClassFieldMap populateFieldCacheWith(fieldCache, iface); } Class[] supers = iface.getInterfaces(); - for (int i=0; i < supers.length; i++) + for (Class aSuper : supers) { - populateFieldCacheWithInterface(fieldCache, supers[i]); + populateFieldCacheWithInterface(fieldCache, aSuper); } } @@ -156,12 +156,12 @@ public class ClassFieldMap try { Field[] fields = classToReflect.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) + for (Field field : fields) { - int modifiers = fields[i].getModifiers(); + int modifiers = field.getModifiers(); if (Modifier.isPublic(modifiers)) { - fieldCache.put(fields[i].getName(), fields[i]); + fieldCache.put(field.getName(), field); } } }