aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src/main/java/org
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2017-01-28 19:21:08 +0000
committerClaude Brisson <cbrisson@apache.org>2017-01-28 19:21:08 +0000
commit23e6d0faeb4648ec700481fb3f01214bd81f4f79 (patch)
tree9dcf8c9be8710fa85f2dd31ea18604584445882f /velocity-engine-core/src/main/java/org
parent34e78d04e1edf70a291f2acbf9d891466bc9582a (diff)
downloadapache-velocity-engine-23e6d0faeb4648ec700481fb3f01214bd81f4f79.tar.gz
[engine] full code review (foreach loops and some other problems detected by code analysis tools)
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1780734 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/Template.java16
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/VelocityContext.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/FieldMethodizer.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/IncludeEventHandler.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/context/AbstractContext.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/context/InternalContextBase.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/context/InternalEventContext.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/io/Filter.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/io/VelocityWriter.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/Renderable.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java63
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java88
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroManager.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/DirectiveConstants.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Evaluate.java7
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java10
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java12
-rwxr-xr-xvelocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParseException.java19
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java24
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java7
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java25
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java3
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java5
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java5
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java10
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java28
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java56
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java86
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java4
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java10
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java34
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java23
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java28
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java12
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java62
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java18
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java16
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java28
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java14
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java13
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java2
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java8
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java10
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java9
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java10
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java6
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java6
88 files changed, 468 insertions, 539 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/Template.java b/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
index 8222c277..6280f3e0 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
@@ -202,7 +202,7 @@ public class Template extends Resource
/**
* initializes the document. init() is not longer
* dependant upon context, but we need to let the
- * init() carry the template name down throught for VM
+ * init() carry the template name down through for VM
* namespace features
* @throws TemplateInitException When a problem occurs during the document initialization.
*/
@@ -250,7 +250,7 @@ public class Template extends Resource
* The AST node structure is merged with the
* context to produce the final output.
*
- * @param context Conext with data elements accessed by template
+ * @param context Context with data elements accessed by template
* @param writer output writer for rendered template
* @throws ResourceNotFoundException if template not found
* from any available source.
@@ -269,7 +269,7 @@ public class Template extends Resource
* The AST node structure is merged with the
* context to produce the final output.
*
- * @param context Conext with data elements accessed by template
+ * @param context Context with data elements accessed by template
* @param writer output writer for rendered template
* @param macroLibraries a list of template files containing macros to be used when merging
* @throws ResourceNotFoundException if template not found
@@ -310,14 +310,14 @@ public class Template extends Resource
if (macroLibraries != null)
{
- for (int i = 0; i < macroLibraries.size(); i++)
+ for (String macroLibrary : (List<String>)macroLibraries)
{
/**
* Build the macro library
*/
try
{
- Template t = rsvc.getTemplate((String) macroLibraries.get(i));
+ Template t = rsvc.getTemplate(macroLibrary);
libTemplates.add(t);
}
catch (ResourceNotFoundException re)
@@ -326,7 +326,7 @@ public class Template extends Resource
* the macro lib wasn't found. Note it and throw
*/
log.error("template.merge(): cannot find template {}",
- (String)macroLibraries.get(i));
+ macroLibrary);
throw re;
}
catch (ParseErrorException pe)
@@ -336,14 +336,14 @@ public class Template extends Resource
* note it and throw
*/
rsvc.getLog("parser").error("template.merge(): syntax error in template {}: {}",
- (String)macroLibraries.get(i), pe.getMessage(), pe);
+ macroLibrary, pe.getMessage(), pe);
throw pe;
}
catch (Exception e)
{
throw new RuntimeException("Template.merge(): parse failed in template " +
- (String) macroLibraries.get(i) + ".", e);
+ (String) macroLibrary + ".", e);
}
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/VelocityContext.java b/velocity-engine-core/src/main/java/org/apache/velocity/VelocityContext.java
index 875e2021..4ab5181a 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/VelocityContext.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/VelocityContext.java
@@ -177,7 +177,7 @@ public class VelocityContext extends AbstractContext implements Cloneable
try
{
clone = (VelocityContext) super.clone();
- clone.context = new HashMap<String, Object>(context);
+ clone.context = new HashMap<>(context);
}
catch (CloneNotSupportedException ignored)
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/FieldMethodizer.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/FieldMethodizer.java
index f77088ab..daabeac1 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/FieldMethodizer.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/FieldMethodizer.java
@@ -170,15 +170,15 @@ public class FieldMethodizer
private void inspect(Class clas)
{
Field[] fields = clas.getFields();
- for( int i = 0; i < fields.length; i++)
+ for (Field field : fields)
{
/*
* only if public and static
*/
- int mod = fields[i].getModifiers();
- if ( Modifier.isStatic(mod) && Modifier.isPublic(mod) )
+ int mod = field.getModifiers();
+ if (Modifier.isStatic(mod) && Modifier.isPublic(mod))
{
- fieldHash.put(fields[i].getName(), fields[i]);
+ fieldHash.put(field.getName(), field);
}
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
index 171655b5..b1bd01ae 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
@@ -329,7 +329,7 @@ public class VelocityEngine implements RuntimeConstants
* cannot be used to pre-load the resource cache, as the
* previous implementation did as a side-effect.
* <br><br>
- * The previous implementation exhibited extreme lazyness and
+ * The previous implementation exhibited extreme laziness and
* sloth, and the author has been flogged.
*
* @param resourceName name of the resource to search for
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/IncludeEventHandler.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/IncludeEventHandler.java
index 55f0f736..c88027fe 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/IncludeEventHandler.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/IncludeEventHandler.java
@@ -48,5 +48,5 @@ public interface IncludeEventHandler extends EventHandler
* @return a new resource path for the directive, or null to block the
* include from occurring.
*/
- public String includeEvent(Context context, String includeResourcePath, String currentResourcePath, String directiveName);
+ String includeEvent(Context context, String includeResourcePath, String currentResourcePath, String directiveName);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
index e5b5b362..f02e09b6 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
@@ -50,8 +50,8 @@ public interface InvalidReferenceEventHandler extends EventHandler
* @param info contains template, line, column details
* @return substitute return value for missing reference, or null if no substitute
*/
- public Object invalidGetMethod(Context context, String reference,
- Object object, String property, Info info);
+ Object invalidGetMethod(Context context, String reference,
+ Object object, String property, Info info);
/**
* Called when object is null or there is no setter for the given
@@ -68,8 +68,8 @@ public interface InvalidReferenceEventHandler extends EventHandler
* @return if true then stop calling invalidSetMethod along the
* chain.
*/
- public boolean invalidSetMethod(Context context, String leftreference,
- String rightreference, Info info);
+ boolean invalidSetMethod(Context context, String leftreference,
+ String rightreference, Info info);
/**
* Called when object is null or the given method does not exist.
@@ -83,6 +83,6 @@ public interface InvalidReferenceEventHandler extends EventHandler
* @param info contains template, line, column details
* @return substitute return value for missing reference, or null if no substitute
*/
- public Object invalidMethod(Context context, String reference,
- Object object, String method, Info info);
+ Object invalidMethod(Context context, String reference,
+ Object object, String method, Info info);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
index b691817c..b30d90f4 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/MethodExceptionEventHandler.java
@@ -48,5 +48,5 @@ public interface MethodExceptionEventHandler extends EventHandler
* @return an object to insert in the page
* @throws RuntimeException an exception to be thrown instead inserting an object
*/
- public Object methodException(Context context, Class claz, String method, Exception e, Info info);
+ Object methodException(Context context, Class claz, String method, Exception e, Info info);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java
index 30906282..a9e1d660 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/ReferenceInsertionEventHandler.java
@@ -48,6 +48,6 @@ public interface ReferenceInsertionEventHandler extends EventHandler
* @return Object on which <code>toString()</code> should be called for
* output.
*/
- public Object referenceInsert( Context context, String reference, Object value );
+ Object referenceInsert(Context context, String reference, Object value);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java
index f3ce719f..d1d7c824 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/PrintExceptions.java
@@ -35,7 +35,7 @@ import java.io.StringWriter;
* <P>By default this event handler renders an error message containing the class and method which generated
* the exception, the exception name and its message.
*
- * To render the reference and the location in the tempkate, set the property <code>eventhandler.methodexception.templateinfo</code>
+ * To render the reference and the location in the template, set the property <code>eventhandler.methodexception.templateinfo</code>
* to <code>true</code>.
*
* To render the stack trace, set the property <code>eventhandler.methodexception.stacktrace</code>
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/context/AbstractContext.java b/velocity-engine-core/src/main/java/org/apache/velocity/context/AbstractContext.java
index 1bb976f6..4e62c4e3 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/context/AbstractContext.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/context/AbstractContext.java
@@ -163,9 +163,9 @@ public abstract class AbstractContext extends InternalContextBase
/*
* We always use string interning here:
- * 1) speed is générally less critical when populating the context than during parsing or rendering
+ * 1) speed is generally less critical when populating the context than during parsing or rendering
* 2) a context key is very likely to be used several times, or even a lot of times, in the template (but does it save memory if runtime.string.interning is false?)
- * 3) last but not least: we don't have access to RuntimeServices from here, the reenginering would be painful...
+ * 3) last but not least: we don't have access to RuntimeServices from here, the reengineering would be painful...
*/
return internalPut(key.intern(), value);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalContextBase.java b/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalContextBase.java
index b2376368..c516dd91 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalContextBase.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalContextBase.java
@@ -57,12 +57,12 @@ class InternalContextBase implements InternalHousekeepingContext, InternalEventC
/**
* Template name stack. The stack top contains the current template name.
*/
- private Stack<String> templateNameStack = new Stack<String>();
+ private Stack<String> templateNameStack = new Stack<>();
/**
* Velocimacro name stack. The stack top contains the current macro name.
*/
- private Stack<String> macroNameStack = new Stack<String>();
+ private Stack<String> macroNameStack = new Stack<>();
/**
* EventCartridge we are to carry. Set by application
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalEventContext.java b/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalEventContext.java
index 9133a538..61602468 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalEventContext.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/context/InternalEventContext.java
@@ -35,10 +35,10 @@ public interface InternalEventContext
* @param ec
* @return The old EventCartridge.
*/
- public EventCartridge attachEventCartridge( EventCartridge ec);
+ EventCartridge attachEventCartridge(EventCartridge ec);
/**
* @return The current EventCartridge.
*/
- public EventCartridge getEventCartridge();
+ EventCartridge getEventCartridge();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/io/Filter.java b/velocity-engine-core/src/main/java/org/apache/velocity/io/Filter.java
index 2ff2e8bd..021e43e7 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/io/Filter.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/io/Filter.java
@@ -28,5 +28,5 @@ import java.io.IOException;
public interface Filter
{
- public void writeReference(String ref) throws IOException;
+ void writeReference(String ref) throws IOException;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java b/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java
index 65748f7d..ce9bbb06 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/io/UnicodeInputStream.java
@@ -194,7 +194,7 @@ public class UnicodeInputStream
return (encoding != null) ? encoding.getEncoding() : null;
}
- private final UnicodeBOM match(final UnicodeBOM matchEncoding, final UnicodeBOM noMatchEncoding)
+ private UnicodeBOM match(final UnicodeBOM matchEncoding, final UnicodeBOM noMatchEncoding)
throws IOException
{
byte [] bom = matchEncoding.getBytes();
@@ -218,7 +218,7 @@ public class UnicodeInputStream
return matchEncoding;
}
- private final boolean readByte()
+ private boolean readByte()
throws IOException
{
int res = inputStream.read();
@@ -236,7 +236,7 @@ public class UnicodeInputStream
return true;
}
- private final void pushback(final UnicodeBOM matchBOM)
+ private void pushback(final UnicodeBOM matchBOM)
throws IOException
{
int count = pos; // By default, all bytes are pushed back.
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/io/VelocityWriter.java b/velocity-engine-core/src/main/java/org/apache/velocity/io/VelocityWriter.java
index c09681b0..40817ca4 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/io/VelocityWriter.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/io/VelocityWriter.java
@@ -120,7 +120,7 @@ public final class VelocityWriter extends Writer implements Filter
* flushing the stream itself. This method is non-private only so that it
* may be invoked by PrintStream.
*/
- private final void flushBuffer() throws IOException
+ private void flushBuffer() throws IOException
{
if (bufferSize == 0)
return;
@@ -138,7 +138,7 @@ public final class VelocityWriter extends Writer implements Filter
nextChar = 0;
}
- private final void bufferOverflow() throws IOException
+ private void bufferOverflow() throws IOException
{
throw new IOException("overflow");
}
@@ -204,7 +204,7 @@ public final class VelocityWriter extends Writer implements Filter
* <code>java.lang.Math</code> if we've run out of file
* descriptors and we're trying to print a stack trace.
*/
- private final int min(int a, int b)
+ private int min(int a, int b)
{
return (a < b ? a : b);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/Renderable.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/Renderable.java
index 18ddff98..157ba6a0 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/Renderable.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/Renderable.java
@@ -38,7 +38,7 @@ import java.io.Writer;
public interface Renderable {
- public boolean render( InternalContextAdapter context, Writer writer)
+ boolean render(InternalContextAdapter context, Writer writer)
throws IOException, MethodInvocationException, ParseErrorException, ResourceNotFoundException;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
index a98847f5..2d1b5d91 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
@@ -289,7 +289,7 @@ public interface RuntimeConstants
/**
* Space gobbling modes
*/
- public enum SpaceGobbling
+ enum SpaceGobbling
{
NONE, BC, LINES, STRUCTURED
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
index 574ace7c..1e9fb2ec 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
@@ -361,14 +361,13 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
private void initializeIntrospection()
{
String[] uberspectors = configuration.getStringArray(RuntimeConstants.UBERSPECT_CLASSNAME);
- for (int i=0; i <uberspectors.length;i++)
+ for (String rm : uberspectors)
{
- String rm = uberspectors[i];
Object o = null;
try
{
- o = ClassUtils.getNewInstance( rm );
+ o = ClassUtils.getNewInstance(rm);
}
catch (ClassNotFoundException cnfe)
{
@@ -379,11 +378,11 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
}
catch (InstantiationException ie)
{
- throw new VelocityException("Could not instantiate class '" + rm + "'", ie);
+ throw new VelocityException("Could not instantiate class '" + rm + "'", ie);
}
catch (IllegalAccessException ae)
{
- throw new VelocityException("Cannot access class '" + rm + "'", ae);
+ throw new VelocityException("Cannot access class '" + rm + "'", ae);
}
if (!(o instanceof Uberspect))
@@ -396,27 +395,25 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
throw new VelocityException(err);
}
- Uberspect u = (Uberspect)o;
+ Uberspect u = (Uberspect) o;
if (u instanceof RuntimeServicesAware)
{
- ((RuntimeServicesAware)u).setRuntimeServices(this);
+ ((RuntimeServicesAware) u).setRuntimeServices(this);
}
if (uberSpect == null)
{
uberSpect = u;
- }
- else
+ } else
{
if (u instanceof ChainableUberspector)
{
- ((ChainableUberspector)u).wrap(uberSpect);
+ ((ChainableUberspector) u).wrap(uberSpect);
uberSpect = u;
- }
- else
+ } else
{
- uberSpect = new LinkingUberspector(uberSpect,u);
+ uberSpect = new LinkingUberspector(uberSpect, u);
}
}
}
@@ -797,9 +794,9 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
String[] referenceinsertion = configuration.getStringArray(RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION);
if ( referenceinsertion != null )
{
- for ( int i=0; i < referenceinsertion.length; i++ )
+ for (String aReferenceinsertion : referenceinsertion)
{
- EventHandler ev = initializeSpecificEventHandler(referenceinsertion[i],RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION,ReferenceInsertionEventHandler.class);
+ EventHandler ev = initializeSpecificEventHandler(aReferenceinsertion, RuntimeConstants.EVENTHANDLER_REFERENCEINSERTION, ReferenceInsertionEventHandler.class);
if (ev != null)
eventCartridge.addReferenceInsertionEventHandler((ReferenceInsertionEventHandler) ev);
}
@@ -808,9 +805,9 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
String[] methodexception = configuration.getStringArray(RuntimeConstants.EVENTHANDLER_METHODEXCEPTION);
if ( methodexception != null )
{
- for ( int i=0; i < methodexception.length; i++ )
+ for (String aMethodexception : methodexception)
{
- EventHandler ev = initializeSpecificEventHandler(methodexception[i],RuntimeConstants.EVENTHANDLER_METHODEXCEPTION,MethodExceptionEventHandler.class);
+ EventHandler ev = initializeSpecificEventHandler(aMethodexception, RuntimeConstants.EVENTHANDLER_METHODEXCEPTION, MethodExceptionEventHandler.class);
if (ev != null)
eventCartridge.addMethodExceptionHandler((MethodExceptionEventHandler) ev);
}
@@ -819,9 +816,9 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
String[] includeHandler = configuration.getStringArray(RuntimeConstants.EVENTHANDLER_INCLUDE);
if ( includeHandler != null )
{
- for ( int i=0; i < includeHandler.length; i++ )
+ for (String anIncludeHandler : includeHandler)
{
- EventHandler ev = initializeSpecificEventHandler(includeHandler[i],RuntimeConstants.EVENTHANDLER_INCLUDE,IncludeEventHandler.class);
+ EventHandler ev = initializeSpecificEventHandler(anIncludeHandler, RuntimeConstants.EVENTHANDLER_INCLUDE, IncludeEventHandler.class);
if (ev != null)
eventCartridge.addIncludeEventHandler((IncludeEventHandler) ev);
}
@@ -830,9 +827,9 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
String[] invalidReferenceSet = configuration.getStringArray(RuntimeConstants.EVENTHANDLER_INVALIDREFERENCES);
if ( invalidReferenceSet != null )
{
- for ( int i=0; i < invalidReferenceSet.length; i++ )
+ for (String anInvalidReferenceSet : invalidReferenceSet)
{
- EventHandler ev = initializeSpecificEventHandler(invalidReferenceSet[i],RuntimeConstants.EVENTHANDLER_INVALIDREFERENCES,InvalidReferenceEventHandler.class);
+ EventHandler ev = initializeSpecificEventHandler(anInvalidReferenceSet, RuntimeConstants.EVENTHANDLER_INVALIDREFERENCES, InvalidReferenceEventHandler.class);
if (ev != null)
{
eventCartridge.addInvalidReferenceEventHandler((InvalidReferenceEventHandler) ev);
@@ -1024,10 +1021,10 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
String[] userdirective = configuration.getStringArray("userdirective");
- for( int i = 0; i < userdirective.length; i++)
+ for (String anUserdirective : userdirective)
{
- loadDirective(userdirective[i]);
- log.debug("Loaded User Directive: {}", userdirective[i]);
+ loadDirective(anUserdirective);
+ log.debug("Loaded User Directive: {}", anUserdirective);
}
}
@@ -1072,8 +1069,7 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
*/
private void updateSharedDirectivesMap()
{
- Map tmp = new HashMap(runtimeDirectives);
- runtimeDirectivesShared = tmp;
+ runtimeDirectivesShared = new HashMap(runtimeDirectives);
}
/**
@@ -1192,8 +1188,7 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
{
requireInitialization();
- Parser parser = new Parser(this);
- return parser;
+ return new Parser(this);
}
/**
@@ -1218,7 +1213,7 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
{
requireInitialization();
- Parser parser = (Parser) parserPool.get();
+ Parser parser = parserPool.get();
boolean keepParser = true;
if (parser == null)
{
@@ -1501,11 +1496,11 @@ public class RuntimeInstance implements RuntimeConstants, RuntimeServices
StringBuilder template = new StringBuilder("#");
template.append(vmName);
template.append("(");
- for( int i = 0; i < params.length; i++)
- {
- template.append(" $");
- template.append(params[i]);
- }
+ for (String param : params)
+ {
+ template.append(" $");
+ template.append(param);
+ }
template.append(" )");
return evaluate(context, writer, logTag, template.toString());
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
index 8e80829c..4a5ae8cc 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
@@ -71,7 +71,7 @@ public interface RuntimeServices
* <li>Velocimacro System</li>
* </ul>
*/
- public void init();
+ void init();
/**
* Allows an external system to set a property in
@@ -80,7 +80,7 @@ public interface RuntimeServices
* @param key property key
* @param value property value
*/
- public void setProperty(String key, Object value);
+ void setProperty(String key, Object value);
/**
* Allow an external system to set an ExtProperties
@@ -89,7 +89,7 @@ public interface RuntimeServices
* @param configuration
* @since 2.0
*/
- public void setConfiguration( ExtProperties configuration);
+ void setConfiguration(ExtProperties configuration);
/**
* Add a property to the configuration. If it already
@@ -110,7 +110,7 @@ public interface RuntimeServices
* @param key
* @param value
*/
- public void addProperty(String key, Object value);
+ void addProperty(String key, Object value);
/**
* Clear the values pertaining to a particular
@@ -118,7 +118,7 @@ public interface RuntimeServices
*
* @param key of property to clear
*/
- public void clearProperty(String key);
+ void clearProperty(String key);
/**
* Allows an external caller to get a property. The calling
@@ -128,7 +128,7 @@ public interface RuntimeServices
* @param key property to return
* @return The value.
*/
- public Object getProperty( String key );
+ Object getProperty(String key);
/**
* Initialize the Velocity Runtime with a Properties
@@ -136,7 +136,7 @@ public interface RuntimeServices
*
* @param p
*/
- public void init(Properties p);
+ void init(Properties p);
/**
* Initialize the Velocity Runtime with the name of
@@ -144,7 +144,7 @@ public interface RuntimeServices
*
* @param configurationFile
*/
- public void init(String configurationFile);
+ void init(String configurationFile);
/**
* Parse the input and return the root of
@@ -163,7 +163,7 @@ public interface RuntimeServices
* @return The AST representing the template.
* @throws ParseException
*/
- public SimpleNode parse( Reader reader, Template template )
+ SimpleNode parse(Reader reader, Template template)
throws ParseException;
/**
@@ -185,8 +185,8 @@ public interface RuntimeServices
* @throws IOException While rendering to the writer, an I/O problem occurred.
* @since Velocity 1.6
*/
- public boolean evaluate(Context context, Writer out,
- String logTag, String instring);
+ boolean evaluate(Context context, Writer out,
+ String logTag, String instring);
/**
* Renders the input reader using the context into the output writer.
@@ -206,8 +206,8 @@ public interface RuntimeServices
* @throws ResourceNotFoundException A referenced resource could not be loaded.
* @since Velocity 1.6
*/
- public boolean evaluate(Context context, Writer writer,
- String logTag, Reader reader);
+ boolean evaluate(Context context, Writer writer,
+ String logTag, Reader reader);
/**
* Invokes a currently registered Velocimacro with the params provided
@@ -225,9 +225,9 @@ public interface RuntimeServices
* @return true if Velocimacro exists and successfully invoked, false otherwise.
* @since 1.6
*/
- public boolean invokeVelocimacro(final String vmName, String logTag,
- String[] params, final Context context,
- final Writer writer);
+ boolean invokeVelocimacro(final String vmName, String logTag,
+ String[] params, final Context context,
+ final Writer writer);
/**
* Returns a <code>Template</code> from the resource manager.
@@ -242,7 +242,7 @@ public interface RuntimeServices
* @throws ParseErrorException if template cannot be parsed due
* to syntax (or other) error.
*/
- public Template getTemplate(String name)
+ Template getTemplate(String name)
throws ResourceNotFoundException, ParseErrorException;
/**
@@ -256,7 +256,7 @@ public interface RuntimeServices
* @throws ParseErrorException if template cannot be parsed due
* to syntax (or other) error.
*/
- public Template getTemplate(String name, String encoding)
+ Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException;
/**
@@ -270,7 +270,7 @@ public interface RuntimeServices
* from any available source.
* @throws ParseErrorException
*/
- public ContentResource getContent(String name)
+ ContentResource getContent(String name)
throws ResourceNotFoundException, ParseErrorException;
/**
@@ -284,7 +284,7 @@ public interface RuntimeServices
* from any available source.
* @throws ParseErrorException
*/
- public ContentResource getContent( String name, String encoding )
+ ContentResource getContent(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException;
/**
@@ -296,7 +296,7 @@ public interface RuntimeServices
* @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);
/**
* String property accessor method with default to hide the
@@ -307,7 +307,7 @@ public interface RuntimeServices
* found in resource manager.
* @return String value of key or default
*/
- public String getString( String key, String defaultValue);
+ String getString(String key, String defaultValue);
/**
* Returns the appropriate VelocimacroProxy object if strVMname
@@ -321,7 +321,7 @@ public interface RuntimeServices
*
* @return VelocimacroProxy
*/
- public Directive getVelocimacro(String vmName, Template renderingTemplate, Template template);
+ Directive getVelocimacro(String vmName, Template renderingTemplate, Template template);
/**
* Adds a new Velocimacro. Usually called by Macro only while parsing.
@@ -335,10 +335,10 @@ public interface RuntimeServices
* @return boolean True if added, false if rejected for some
* reason (either parameters or permission settings)
*/
- public boolean addVelocimacro( String name,
- Node macro,
- List<Macro.MacroArg> macroArgs,
- Template definingTemplate );
+ boolean addVelocimacro(String name,
+ Node macro,
+ List<Macro.MacroArg> macroArgs,
+ Template definingTemplate);
/**
@@ -348,14 +348,14 @@ public interface RuntimeServices
* @param template Template "namespace"
* @return boolean True if VM by that name exists, false if not
*/
- public boolean isVelocimacro(String vmName, Template template);
+ boolean isVelocimacro(String vmName, Template template);
/**
* String property accessor method to hide the configuration implementation
* @param key property key
* @return value of key or null
*/
- public String getString(String key);
+ String getString(String key);
/**
* Int property accessor method to hide the configuration implementation.
@@ -363,7 +363,7 @@ public interface RuntimeServices
* @param key property key
* @return int value
*/
- public int getInt( String key );
+ int getInt(String key);
/**
* Int property accessor method to hide the configuration implementation.
@@ -372,7 +372,7 @@ public interface RuntimeServices
* @param defaultValue default value
* @return int value
*/
- public int getInt( String key, int defaultValue );
+ int getInt(String key, int defaultValue);
/**
* Boolean property accessor method to hide the configuration implementation.
@@ -381,7 +381,7 @@ public interface RuntimeServices
* @param def default default value if property not found
* @return boolean value of key or default value
*/
- public boolean getBoolean( String key, boolean def );
+ boolean getBoolean(String key, boolean def);
/**
* Return the velocity runtime configuration object.
@@ -389,7 +389,7 @@ public interface RuntimeServices
* @return ExtProperties configuration object which houses
* the velocity runtime properties.
*/
- public ExtProperties getConfiguration();
+ ExtProperties getConfiguration();
/**
* Return the specified application attribute.
@@ -397,7 +397,7 @@ public interface RuntimeServices
* @param key The name of the attribute to retrieve.
* @return The value of the attribute.
*/
- public Object getApplicationAttribute( Object key );
+ Object getApplicationAttribute(Object key);
/**
* Set the specified application attribute.
@@ -406,20 +406,20 @@ public interface RuntimeServices
* @param value The attribute value to set.
* @return the displaced attribute value
*/
- public Object setApplicationAttribute( Object key, Object value );
+ Object setApplicationAttribute(Object key, Object value);
/**
* Returns the configured class introspection/reflection
* implementation.
* @return The current Uberspect object.
*/
- public Uberspect getUberspect();
+ Uberspect getUberspect();
/**
* Returns a convenient Log instance that wraps the current LogChute.
* @return A log object.
*/
- public Logger getLog();
+ Logger getLog();
/**
* Get a logger for the specified child namespace.
@@ -428,25 +428,25 @@ public interface RuntimeServices
* @param childNamespace
* @return
*/
- public Logger getLog(String childNamespace);
+ Logger getLog(String childNamespace);
/**
* Returns the event handlers for the application.
* @return The event handlers for the application.
*/
- public EventCartridge getApplicationEventCartridge();
+ EventCartridge getApplicationEventCartridge();
/**
* Returns true if the RuntimeInstance has been successfully initialized.
* @return True if the RuntimeInstance has been successfully initialized.
*/
- public boolean isInitialized();
+ boolean isInitialized();
/**
* Create a new parser instance.
* @return A new parser instance.
*/
- public Parser createNewParser();
+ Parser createNewParser();
/**
* Retrieve a previously instantiated directive.
@@ -454,17 +454,17 @@ public interface RuntimeServices
* @return the directive with that name, if any
* @since 1.6
*/
- public Directive getDirective(String name);
+ Directive getDirective(String name);
/**
* Check whether the engine uses string interning
* @return true if string interning is active
*/
- public boolean useStringInterning();
+ boolean useStringInterning();
/**
* get space gobbling mode
* @return space gobbling mode
*/
- public SpaceGobbling getSpaceGobbling();
+ SpaceGobbling getSpaceGobbling();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
index 2f9c48fc..12635cac 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
@@ -58,7 +58,7 @@ import java.util.Properties;
* -----------------------------------------------------------------------
* RuntimeSingleton.init(String/Properties)
*
- * In this case the default velocity properties are layed down
+ * In this case the default velocity properties are laid down
* first to provide a solid base, then any properties provided
* in the given properties object will override the corresponding
* default property.
@@ -407,7 +407,7 @@ public class RuntimeSingleton implements RuntimeConstants
* @param macro root AST node of the parsed macro
* @param macroArgs Array of macro arguments, containing the
* #macro() arguments and default values. the 0th is the name.
- * @param definingTemplate Templaite containing the definition of the macro.
+ * @param definingTemplate Template containing the definition of the macro.
*/
public static boolean addVelocimacro(String name, Node macro,
List<Macro.MacroArg> macroArgs, Template definingTemplate)
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
index 2d713346..4034f062 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
@@ -89,7 +89,7 @@ public class VelocimacroFactory
/**
* vector of the library names
*/
- private List macroLibVec = null;
+ private List<String> macroLibVec = null;
/**
* map of the library Template objects
@@ -164,20 +164,18 @@ public class VelocimacroFactory
if(libfiles != null)
{
- macroLibVec = new ArrayList();
+ macroLibVec = new ArrayList<>();
if (libfiles instanceof Vector)
{
- macroLibVec.addAll((Vector)libfiles);
+ macroLibVec.addAll((Vector<String>)libfiles);
}
else if (libfiles instanceof String)
{
- macroLibVec.add(libfiles);
+ macroLibVec.add((String)libfiles);
}
- for(int i = 0, is = macroLibVec.size(); i < is; i++)
+ for (String lib : macroLibVec)
{
- String lib = (String) macroLibVec.get(i);
-
/*
* only if it's a non-empty string do we bother
*/
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroManager.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroManager.java
index e4986028..a4b18153 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroManager.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroManager.java
@@ -53,7 +53,7 @@ public class VelocimacroManager
/** reference to global namespace hash */
private final Map globalNamespace;
- /** set of names of library tempates/namespaces */
+ /** set of names of library templates/namespaces */
private final Map libraries = new ConcurrentHashMap(17, 0.5f, 20);
private RuntimeServices rsvc = null;
@@ -258,12 +258,8 @@ public class VelocimacroManager
* currently, we only support the local template namespace idea
*/
- if (inlineLocalMode)
- {
- return true;
- }
+ return inlineLocalMode;
- return false;
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/DirectiveConstants.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/DirectiveConstants.java
index 91834af8..0836e752 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/DirectiveConstants.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/DirectiveConstants.java
@@ -28,8 +28,8 @@ package org.apache.velocity.runtime.directive;
public interface DirectiveConstants
{
/** Block directive indicator */
- public static final int BLOCK = 1;
+ int BLOCK = 1;
/** Line directive indicator */
- public static final int LINE = 2;
+ int LINE = 2;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Evaluate.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Evaluate.java
index 7735e683..dc5037c1 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Evaluate.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Evaluate.java
@@ -165,17 +165,12 @@ public class Evaluate extends Directive
{
nodeTree = rsvc.parse(new StringReader(sourceText), template);
}
- catch (ParseException pex)
+ catch (ParseException | TemplateInitException pex)
{
// use the line/column from the template
Info info = new Info( templateName, node.getLine(), node.getColumn() );
throw new ParseErrorException( pex.getMessage(), info );
}
- catch (TemplateInitException pex)
- {
- Info info = new Info( templateName, node.getLine(), node.getColumn() );
- throw new ParseErrorException( pex.getMessage(), info );
- }
/*
* now we want to init and render. Chain the context
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
index 475d7a89..86f62639 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
@@ -45,7 +45,7 @@ import java.io.Writer;
* <li>For security reasons, the included source material can only come
* from somewhere within the template root tree. If you want to include
* content from elsewhere on your disk, add extra template roots, or use
- * a link from somwhere under template root to that content.</li>
+ * a link from somwehere under template root to that content.</li>
*
* <li>By default, there is no output to the render stream in the event of
* a problem. You can override this behavior with two property values :
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
index d28310f8..b2182966 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
@@ -153,9 +153,9 @@ public class Macro extends Directive
{
if (argtypes.get(argPos) == ParserTreeConstants.JJTDIRECTIVEASSIGN)
{
- // Abosrb next argument type since parser enforces that these are in
+ // Absorb next argument type since parser enforces that these are in
// pairs, and we don't need to check the type of the second
- // arg becuase it is done by the parser.
+ // arg because it is done by the parser.
argPos++;
consecutive = true;
}
@@ -176,7 +176,7 @@ public class Macro extends Directive
/**
* Creates an array containing the literal text from the macro
- * arguement(s) (including the macro's name as the first arg).
+ * argument(s) (including the macro's name as the first arg).
*
* @param node The parse node from which to grok the argument
* list. It's expected to include the block node tree (for the
@@ -267,8 +267,8 @@ public class Macro extends Directive
* has passed in as buf, this method returns it.
* @since 1.5
*/
- public static final StringBuilder macroToString(final StringBuilder buf,
- List<MacroArg> macroArgs)
+ public static StringBuilder macroToString(final StringBuilder buf,
+ List<MacroArg> macroArgs)
{
StringBuilder ret = (buf == null) ? new StringBuilder() : buf;
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
index 0e1ee80b..04dc321f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
@@ -133,19 +133,19 @@ public class MacroParseException
StringBuilder expected = new StringBuilder();
- for (int i = 0; i < expectedTokenSequences.length; i++)
+ for (int[] expectedTokenSequence : expectedTokenSequences)
{
- if (maxSize < expectedTokenSequences[i].length)
+ if (maxSize < expectedTokenSequence.length)
{
- maxSize = expectedTokenSequences[i].length;
+ maxSize = expectedTokenSequence.length;
}
- for (int j = 0; j < expectedTokenSequences[i].length; j++)
+ for (int j = 0; j < expectedTokenSequence.length; j++)
{
- expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ expected.append(tokenImage[expectedTokenSequence[j]]).append(" ");
}
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0)
+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0)
{
expected.append("...");
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
index 16161f17..896fc7a4 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
@@ -51,7 +51,7 @@ import java.util.List;
* 1) The parsed source material can only come from somewhere in
* the TemplateRoot tree for security reasons. There is no way
* around this. If you want to include content from elsewhere on
- * your disk, use a link from somwhere under Template Root to that
+ * your disk, use a link from somewhere under Template Root to that
* content.
*
* 2) There is a limited parse depth. It is set as a property
@@ -193,9 +193,9 @@ public class Parse extends InputBase
if (templateStack.length >= maxDepth)
{
StringBuilder path = new StringBuilder();
- for( int i = 0; i < templateStack.length; ++i)
+ for (String aTemplateStack : templateStack)
{
- path.append( " > " + templateStack[i] );
+ path.append(" > " + aTemplateStack);
}
log.error("Max recursion depth reached ({}) File stack: {}",
templateStack.length, path);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
index f5584bef..cbd2172f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
@@ -230,10 +230,10 @@ public class RuntimeMacro extends Directive
/**
* Velocimacro implementation is not known at the init time. So look for
- * a implementation in the macro libaries and if finds one renders it. The
+ * a implementation in the macro libraries and if finds one renders it. The
* actual rendering is delegated to the VelocimacroProxy object. When
* looking for a macro we first loot at the template with has the
- * macro call then we look at the macro lbraries in the order they appear
+ * macro call then we look at the macro libraries in the order they appear
* in the list. If a macro has many definitions above look up will
* determine the precedence.
*
@@ -330,7 +330,7 @@ public class RuntimeMacro extends Directive
}
return true;
}
- catch (RuntimeException e)
+ catch (RuntimeException | IOException e)
{
/**
* We catch, the exception here so that we can record in
@@ -343,12 +343,6 @@ public class RuntimeMacro extends Directive
macroName, StringUtils.formatFileString(node));
throw e;
}
- catch (IOException e)
- {
- log.error("Exception in macro #{} called at {}",
- macroName, StringUtils.formatFileString(node));
- throw e;
- }
finally
{
postRender(context);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
index b2171059..3026a747 100755
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Scope.java
@@ -280,7 +280,7 @@ public class Scope extends AbstractMap
{
String vtl = getTemplate();
sb.append(" template:");
- if (vtl.indexOf(" ") < 0)
+ if (!vtl.contains(" "))
{
sb.append(vtl);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
index 18cdd3f2..f0985a46 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
@@ -284,7 +284,7 @@ public class VelocimacroProxy extends Directive
}
out.append(stack[i]);
}
- out.append(" at " + StringUtils.formatFileString(this));
+ out.append(" at ").append(StringUtils.formatFileString(this));
log.error(out.toString());
// clean out the macro stack, since we just broke it
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParseException.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParseException.java
index 80a257ab..7af197ba 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParseException.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParseException.java
@@ -123,14 +123,18 @@ public class ParseException extends Exception {
}
String expected = "";
int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.length; i++) {
- if (maxSize < expectedTokenSequences[i].length) {
- maxSize = expectedTokenSequences[i].length;
+ for (int[] expectedTokenSequence : expectedTokenSequences)
+ {
+ if (maxSize < expectedTokenSequence.length)
+ {
+ maxSize = expectedTokenSequence.length;
}
- for (int j = 0; j < expectedTokenSequences[i].length; j++) {
- expected += tokenImage[expectedTokenSequences[i][j]] + " ";
+ for (int j = 0; j < expectedTokenSequence.length; j++)
+ {
+ expected += tokenImage[expectedTokenSequence[j]] + " ";
}
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0)
+ {
expected += "...";
}
expected += eol + " ";
@@ -202,11 +206,10 @@ public class ParseException extends Exception {
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
- continue;
}
}
return retval.toString();
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
index ec76bc53..fe2c7ca6 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
@@ -107,8 +107,8 @@ public class TemplateParseException
}
/**
- * returns the Template name where this exception occured.
- * @return The Template name where this exception occured.
+ * returns the Template name where this exception occurred.
+ * @return The Template name where this exception occurred.
*/
public String getTemplateName()
{
@@ -116,8 +116,8 @@ public class TemplateParseException
}
/**
- * returns the line number where this exception occured.
- * @return The line number where this exception occured.
+ * returns the line number where this exception occurred.
+ * @return The line number where this exception occurred.
*/
public int getLineNumber()
{
@@ -132,8 +132,8 @@ public class TemplateParseException
}
/**
- * returns the column number where this exception occured.
- * @return The column number where this exception occured.
+ * returns the column number where this exception occurred.
+ * @return The column number where this exception occurred.
*/
public int getColumnNumber()
{
@@ -171,19 +171,19 @@ public class TemplateParseException
StringBuilder expected = new StringBuilder();
- for (int i = 0; i < expectedTokenSequences.length; i++)
+ for (int[] expectedTokenSequence : expectedTokenSequences)
{
- if (maxSize < expectedTokenSequences[i].length)
+ if (maxSize < expectedTokenSequence.length)
{
- maxSize = expectedTokenSequences[i].length;
+ maxSize = expectedTokenSequence.length;
}
- for (int j = 0; j < expectedTokenSequences[i].length; j++)
+ for (int j = 0; j < expectedTokenSequence.length; j++)
{
- expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ expected.append(tokenImage[expectedTokenSequence[j]]).append(" ");
}
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0)
+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0)
{
expected.append("...");
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
index 4c381b11..d434aeb5 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/VelocityCharStream.java
@@ -60,7 +60,7 @@ implements CharStream
private int maxNextCharInd = 0;
private int inBuf = 0;
- private final void ExpandBuff(boolean wrapAround)
+ private void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + nextBufExpand];
int newbufline[] = new int[bufsize + nextBufExpand];
@@ -111,7 +111,7 @@ implements CharStream
tokenBegin = 0;
}
- private final void FillBuff() throws java.io.IOException
+ private void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
@@ -158,7 +158,6 @@ implements CharStream
{
maxNextCharInd += i;
}
- return;
}
catch(java.io.IOException e)
{
@@ -184,7 +183,7 @@ implements CharStream
return c;
}
- private final void UpdateLineColumn(char c)
+ private void UpdateLineColumn(char c)
{
column++;
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
index fbf2c1b6..a0ee06a8 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
@@ -159,6 +159,6 @@ public abstract class ASTComparisonNode extends ASTBinaryOperator
*/
public Object value(InternalContextAdapter context) throws MethodInvocationException
{
- return Boolean.valueOf(evaluate(context));
+ return evaluate(context);
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
index 55853795..94490a9a 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
@@ -100,7 +100,7 @@ public class ASTDirective extends SimpleNode
{
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 SimpleNode
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 SimpleNode
}
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)
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java
index 06d67d63..b2c006eb 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTElseIfStatement.java
@@ -85,7 +85,7 @@ public class ASTElseIfStatement extends SimpleNode
* 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)
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java
index 3c7315bc..7ecdac42 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTFloatingPointLiteral.java
@@ -93,7 +93,7 @@ public class ASTFloatingPointLiteral extends SimpleNode
} 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 );
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
index 9bd52633..1a5ecdb6 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java
@@ -37,7 +37,7 @@ import java.lang.reflect.InvocationTargetException;
*
* 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 SimpleNode
/*
* 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 :)
*/
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java
index 3bafd5b7..72d6e20f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java
@@ -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
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java
index 380a5ded..bfef11d9 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerLiteral.java
@@ -90,7 +90,7 @@ public class ASTIntegerLiteral extends SimpleNode
}
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 );
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
index 34a989b9..0cc33e58 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
@@ -137,7 +137,7 @@ public class ASTIntegerRange extends SimpleNode
for (int i = 0; i < nbrElements; i++)
{
- elements.add(Integer.valueOf(value));
+ elements.add(value);
value += delta;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java
index fae69ee2..57a6d3ff 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMap.java
@@ -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
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
index d5869fcc..403cd28a 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
@@ -368,9 +368,8 @@ public class ASTMethod extends SimpleNode
* 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();
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java
index a3c41ab5..f65736e0 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNotNode.java
@@ -61,10 +61,7 @@ public class ASTNotNode extends SimpleNode
public boolean evaluate( InternalContextAdapter context)
throws MethodInvocationException
{
- if (jjtGetChild(0).evaluate(context))
- return false;
- else
- return true;
+ return !jjtGetChild(0).evaluate(context);
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java
index 3b81a7ea..7fdd303f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTOrNode.java
@@ -106,9 +106,6 @@ public class ASTOrNode extends ASTLogicalOperator
* same for right
*/
- if ( right != null && right.evaluate( context ) )
- return true;
-
- return false;
+ return right != null && right.evaluate(context);
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
index d56c452f..8278de61 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
@@ -392,7 +392,7 @@ public class ASTReference extends SimpleNode
{
/**
* 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 SimpleNode
}
/*
- * 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 SimpleNode
* 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 SimpleNode
}
/*
- * 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 SimpleNode
{
/*
* 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;
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
index b45cb8d2..f9f93b20 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
@@ -207,7 +207,7 @@ public class ASTSetDirective extends SimpleNode
* 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 SimpleNode
/**
- * 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
*/
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
index 51179ee0..44bce6eb 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
@@ -174,7 +174,7 @@ public class ASTStringLiteral extends SimpleNode
/**
* 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 SimpleNode
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 SimpleNode
*/
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;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
index b4020590..3ce0d097 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
@@ -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)
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
index 880ad572..9de39929 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
@@ -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);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java
index 28142c45..927d6434 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java
@@ -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:
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
index f3c881ad..f311cb71 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/Node.java
@@ -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();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java
index acff7a89..a5d80ae3 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ParserVisitor.java
@@ -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
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
index 686371ae..27821e33 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
@@ -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;
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java
index c55acd4e..98570971 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCache.java
@@ -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();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
index efab63fa..9849eb94 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
@@ -88,7 +88,7 @@ public class ResourceCacheImpl implements ResourceCache
/**
* 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 implements ResourceCache
*/
public Resource get( Object key )
{
- return (Resource) cache.get( key );
+ return cache.get( key );
}
/**
@@ -131,7 +131,7 @@ public class ResourceCacheImpl implements ResourceCache
*/
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 implements ResourceCache
*/
public Resource remove( Object key )
{
- return (Resource) cache.remove( key );
+ return cache.remove( key );
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java
index 99b69784..a5b64395 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManager.java
@@ -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);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
index 5f629530..f4cff570 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
@@ -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>&lt;loader-id&gt;.resource.loader.&lt;property&gt; = &lt;value&gt;</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;
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
index c2e76f35..58bcf2f4 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
@@ -260,23 +260,14 @@ public class DataSourceResourceLoader extends ResourceLoader
}
}
- 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 extends ResourceLoader
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 extends ResourceLoader
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);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
index 4392d3c1..df41a023 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
@@ -55,7 +55,7 @@ public class FileResourceLoader extends ResourceLoader
/**
* 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 ResourceLoader
}
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 ResourceLoader
}
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);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
index 95439463..7b34c912 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
@@ -125,7 +125,7 @@ public class JarResourceLoader extends ResourceLoader
log.error(msg);
throw new RuntimeException(msg);
}
- if ( path.indexOf("!/") < 0 )
+ if (!path.contains("!/"))
{
path += "!/";
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
index 3397dcd6..354514bb 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
@@ -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);
/*
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
index 750accde..25c7688b 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
@@ -58,9 +58,9 @@ public class URLResourceLoader extends ResourceLoader
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 ResourceLoader
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 ResourceLoader
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 ResourceLoader
{
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 ResourceLoader
{
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();
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java
index ab3cb5b0..6bbbcd7b 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ArrayIterator.java
@@ -108,7 +108,7 @@ public class ArrayIterator implements Iterator
}
/**
- * 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()
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
index 574c1fed..66e2ae72 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java
@@ -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
*/
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java
index a2facb3f..7e7c3cda 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ContextAware.java
@@ -44,6 +44,6 @@ public interface ContextAware
* Initialize the EventHandler.
* @param context
*/
- public void setContext( Context context );
+ void setContext(Context context);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java
index 048c2d6f..eb426d6e 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/DuckType.java
@@ -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)
{
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
index 46280057..4c5f3716 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
@@ -776,9 +776,9 @@ public class ExtProperties extends Hashtable<String,Object> {
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 Hashtable<String,Object> {
// 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
if (i == null) {
return defaultValue;
}
- return i.intValue();
+ return i;
}
/**
@@ -1489,7 +1497,7 @@ public class ExtProperties extends Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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 Hashtable<String,Object> {
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 Hashtable<String,Object> {
* 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));
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java
index cff5aa70..739439fe 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/RuntimeServicesAware.java
@@ -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);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
index b842d616..2316e854 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
@@ -23,8 +23,6 @@ import org.apache.velocity.runtime.directive.Directive;
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(""))
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java
index 7da890b3..037d923f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateBoolean.java
@@ -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();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java
index 43829424..2997e2b9 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateNumber.java
@@ -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();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java
index 781b05d2..14adc9e4 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/TemplateString.java
@@ -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();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java
index 135f9a6e..7811ad3f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ChainableUberspector.java
@@ -33,5 +33,5 @@ public interface ChainableUberspector extends Uberspect
*
* @param inner The decorated uberspector.
*/
- public void wrap(Uberspect inner);
+ void wrap(Uberspect inner);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java
index 6bc7481f..0081cfe0 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java
@@ -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);
}
}
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java
index 16a3baae..fe7416bc 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java
@@ -145,9 +145,9 @@ public class ClassMap
populateMethodCacheWith(methodCache, classToReflect);
}
Class [] interfaces = classToReflect.getInterfaces();
- for (int i = 0; i < interfaces.length; i++)
+ for (Class anInterface : interfaces)
{
- populateMethodCacheWithInterface(methodCache, interfaces[i]);
+ populateMethodCacheWithInterface(methodCache, anInterface);
}
}
// return the already initialized cache
@@ -162,9 +162,9 @@ public class ClassMap
populateMethodCacheWith(methodCache, iface);
}
Class[] supers = iface.getInterfaces();
- for (int i=0; i < supers.length; i++)
+ for (Class aSuper : supers)
{
- populateMethodCacheWithInterface(methodCache, supers[i]);
+ populateMethodCacheWithInterface(methodCache, aSuper);
}
}
@@ -178,12 +178,12 @@ public class ClassMap
try
{
Method[] methods = classToReflect.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++)
+ for (Method method : methods)
{
- int modifiers = methods[i].getModifiers();
+ int modifiers = method.getModifiers();
if (Modifier.isPublic(modifiers))
{
- methodCache.put(methods[i]);
+ methodCache.put(method);
}
}
}
@@ -327,7 +327,7 @@ public class ClassMap
StringBuilder methodKey = new StringBuilder((args+1)*16).append(method.getName());
- for (int j = 0; j < args; j++)
+ for (Class parameterType : parameterTypes)
{
/*
* If the argument type is primitive then we want
@@ -339,13 +339,12 @@ public class ClassMap
* primitives (boolean, byte, char, double, float, int, long, short)
* known to Java. So it should never return null for the key passed in.
*/
- if (parameterTypes[j].isPrimitive())
+ if (parameterType.isPrimitive())
{
- methodKey.append((String) convertPrimitives.get(parameterTypes[j]));
- }
- else
+ methodKey.append((String) convertPrimitives.get(parameterType));
+ } else
{
- methodKey.append(parameterTypes[j].getName());
+ methodKey.append(parameterType.getName());
}
}
@@ -362,9 +361,8 @@ public class ClassMap
StringBuilder methodKey = new StringBuilder((args+1)*16).append(method);
- for (int j = 0; j < args; j++)
+ for (Object arg : params)
{
- Object arg = params[j];
if (arg == null)
{
methodKey.append(NULL_ARG);
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java
index 3ce2d222..f52eec1b 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java
@@ -23,7 +23,7 @@ package org.apache.velocity.util.introspection;
* A conversion handler adds admissible conversions between Java types whenever Velocity introspection has to map
* VTL methods and property accessors to Java methods.
* Both methods must be consistent: <code>getNeededConverter</code> must not return <code>null</code> whenever
- * <code>isExplicitelyConvertible</code> returned true with the same arguments.
+ * <code>isExplicitlyConvertible</code> returned true with the same arguments.
*
* @author <a href="mailto:claude.brisson@gmail.com">Claude Brisson</a>
* @version $Id: ConversionHandler.java $
@@ -39,7 +39,7 @@ public interface ConversionHandler
* @return null if no conversion is needed, or the appropriate Converter object
* @since 2.0
*/
- public boolean isExplicitlyConvertible(Class formal, Class actual, boolean possibleVarArg);
+ boolean isExplicitlyConvertible(Class formal, Class actual, boolean possibleVarArg);
/**
* Returns the appropriate Converter object needed for an explicit conversion
@@ -50,7 +50,7 @@ public interface ConversionHandler
* @return null if no conversion is needed, or the appropriate Converter object
* @since 2.0
*/
- public Converter getNeededConverter(final Class formal, final Class actual);
+ Converter getNeededConverter(final Class formal, final Class actual);
/**
* Add the given converter to the handler. Implementation should be thread-safe.
@@ -60,5 +60,5 @@ public interface ConversionHandler
* @param converter converter
* @since 2.0
*/
- public void addConverter(Class formal, Class actual, Converter converter);
+ void addConverter(Class formal, Class actual, Converter converter);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java
index 51666813..248c879f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java
@@ -71,7 +71,7 @@ public class ConversionHandlerImpl implements ConversionHandler
static
{
- standardConverterMap = new HashMap<Pair<? extends Class, ? extends Class>, Converter>();
+ standardConverterMap = new HashMap<>();
cacheMiss = new Converter<Object>()
{
@@ -122,7 +122,7 @@ public class ConversionHandlerImpl implements ConversionHandler
@Override
public Boolean convert(Object o)
{
- return o == null ? null : ((Character) o).charValue() != 0;
+ return o == null ? null : (Character) o != 0;
}
};
standardConverterMap.put(new Pair<>(Boolean.class, Character.class), charToBoolean);
@@ -418,7 +418,7 @@ public class ConversionHandlerImpl implements ConversionHandler
@Override
public Byte convert(Object o)
{
- return o == null ? null : ((Boolean)o).booleanValue() ? (byte)1 : (byte)0;
+ return o == null ? null : (Boolean) o ? (byte)1 : (byte)0;
}
};
standardConverterMap.put(new Pair<>(Byte.class, Boolean.class), booleanToByte);
@@ -432,7 +432,7 @@ public class ConversionHandlerImpl implements ConversionHandler
@Override
public Short convert(Object o)
{
- return o == null ? null : ((Boolean)o).booleanValue() ? (short)1 : (short)0;
+ return o == null ? null : (Boolean) o ? (short)1 : (short)0;
}
};
standardConverterMap.put(new Pair<>(Short.class, Boolean.class), booleanToShort);
@@ -446,7 +446,7 @@ public class ConversionHandlerImpl implements ConversionHandler
@Override
public Integer convert(Object o)
{
- return o == null ? null : ((Boolean)o).booleanValue() ? (Integer)1 : (Integer)0;
+ return o == null ? null : (Boolean) o ? (Integer)1 : (Integer)0;
}
};
standardConverterMap.put(new Pair<>(Integer.class, Boolean.class), booleanToInteger);
@@ -460,7 +460,7 @@ public class ConversionHandlerImpl implements ConversionHandler
@Override
public Long convert(Object o)
{
- return o == null ? null : ((Boolean)o).booleanValue() ? 1L : 0L;
+ return o == null ? null : (Boolean) o ? 1L : 0L;
}
};
standardConverterMap.put(new Pair<>(Long.class, Boolean.class), booleanToLong);
@@ -484,7 +484,7 @@ public class ConversionHandlerImpl implements ConversionHandler
*/
public ConversionHandlerImpl()
{
- converterCacheMap = new ConcurrentHashMap<Pair<? extends Class, ? extends Class>, Converter>();
+ converterCacheMap = new ConcurrentHashMap<>();
}
/**
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java
index 9b28a042..57a193c8 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java
@@ -44,7 +44,7 @@ public class IntrospectionUtils
static
{
- boxingMap = new HashMap<Class, Class>();
+ boxingMap = new HashMap<>();
boxingMap.put(Boolean.TYPE, Boolean.class);
boxingMap.put(Character.TYPE, Character.class);
boxingMap.put(Byte.TYPE, Byte.class);
@@ -54,8 +54,8 @@ public class IntrospectionUtils
boxingMap.put(Float.TYPE, Float.class);
boxingMap.put(Double.TYPE, Double.class);
- unboxingMap = new HashMap<Class, Class>();
- for (Map.Entry<Class,Class> entry : (Set<Map.Entry<Class,Class>>)boxingMap.entrySet())
+ unboxingMap = new HashMap<>();
+ for (Map.Entry<Class,Class> entry : boxingMap.entrySet())
{
unboxingMap.put(entry.getValue(), entry.getKey());
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
index ddd013f8..772a989d 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java
@@ -155,7 +155,7 @@ public class MethodMap
return getBestMatch(methodList, classes);
}
- private Method getBestMatch(List methods, Class[] args)
+ private Method getBestMatch(List<Method> methods, Class[] args)
{
List equivalentMatches = null;
Method bestMatch = null;
@@ -166,9 +166,8 @@ public class MethodMap
{
unboxedArgs[i] = IntrospectionUtils.getUnboxedClass(args[i]);
}
- for (Iterator i = methods.iterator(); i.hasNext(); )
+ for (Method method : methods)
{
- Method method = (Method)i.next();
if (isApplicable(method, args))
{
if (bestMatch == null)
@@ -176,8 +175,7 @@ public class MethodMap
bestMatch = method;
bestMatchTypes = method.getParameterTypes();
bestMatchComp = compare(bestMatchTypes, unboxedArgs);
- }
- else
+ } else
{
Class[] methodTypes = method.getParameterTypes();
switch (compare(methodTypes, bestMatchTypes))
@@ -195,14 +193,13 @@ public class MethodMap
bestMatch = method;
bestMatchTypes = methodTypes;
bestMatchComp = compare(bestMatchTypes, unboxedArgs);
- }
- else
+ } else
{
/* have to beat all other ambiguous ones... */
int ambiguities = equivalentMatches.size();
for (int a = 0; a < ambiguities; a++)
{
- Method other = (Method)equivalentMatches.get(a);
+ Method other = (Method) equivalentMatches.get(a);
switch (compare(methodTypes, other.getParameterTypes()))
{
case MORE_SPECIFIC:
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java
index 6f467871..47789bdc 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java
@@ -37,6 +37,6 @@ public interface SecureIntrospectorControl
*
* @return true if method may be called on object
*/
- public boolean checkObjectExecutePermission(Class clazz, String method);
+ boolean checkObjectExecutePermission(Class clazz, String method);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java
index 89b34c6f..38ac7ce8 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java
@@ -134,17 +134,17 @@ public class SecureIntrospectorImpl extends Introspector implements SecureIntros
int dotPos = className.lastIndexOf('.');
String packageName = (dotPos == -1) ? "" : className.substring(0, dotPos);
- for (int i = 0, size = badPackages.length; i < size; i++)
+ for (String badPackage : badPackages)
{
- if (packageName.equals(badPackages[i]))
+ if (packageName.equals(badPackage))
{
return false;
}
}
- for (int i = 0, size = badClasses.length; i < size; i++)
+ for (String badClass : badClasses)
{
- if (className.equals(badClasses[i]))
+ if (className.equals(badClass))
{
return false;
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java
index 77f9f54b..a57b20ae 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java
@@ -33,7 +33,7 @@ public interface Uberspect
/**
* Initializer - will be called before use
*/
- public void init();
+ void init();
/**
* To support iteratives - #foreach()
@@ -41,7 +41,7 @@ public interface Uberspect
* @param info
* @return An Iterator.
*/
- public Iterator getIterator(Object obj, Info info);
+ Iterator getIterator(Object obj, Info info);
/**
* Returns a general method, corresponding to $foo.bar( $woogie )
@@ -51,7 +51,7 @@ public interface Uberspect
* @param info
* @return A Velocity Method.
*/
- public VelMethod getMethod(Object obj, String method, Object[] args, Info info);
+ VelMethod getMethod(Object obj, String method, Object[] args, Info info);
/**
* Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie)
@@ -60,7 +60,7 @@ public interface Uberspect
* @param info
* @return A Velocity Getter.
*/
- public VelPropertyGet getPropertyGet(Object obj, String identifier, Info info);
+ VelPropertyGet getPropertyGet(Object obj, String identifier, Info info);
/**
* Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir")
@@ -70,5 +70,5 @@ public interface Uberspect
* @param info
* @return A Velocity Setter.
*/
- public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info info);
+ VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info info);
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
index 6e30fa1a..fd5839ec 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
@@ -524,10 +524,10 @@ public class UberspectImpl implements Uberspect, RuntimeServicesAware
Class last = formal[formal.length - 1];
// if the last arg is an array, then
// we consider this a varargs method
- this.isVarArg = Boolean.valueOf(last.isArray());
+ this.isVarArg = last.isArray();
}
}
- return isVarArg.booleanValue();
+ return isVarArg;
}
/**
@@ -580,10 +580,7 @@ public class UberspectImpl implements Uberspect, RuntimeServicesAware
// put all into a new actual array of the appropriate size
Object[] newActual = new Object[index + 1];
- for (int i = 0; i < index; i++)
- {
- newActual[i] = actual[i];
- }
+ System.arraycopy(actual, 0, newActual, 0, index);
newActual[index] = lastActual;
// replace the old actual array
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java
index 5bf36149..50318416 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java
@@ -41,7 +41,7 @@ public interface VelMethod
* @return The resulting object.
* @throws IllegalAccessException, InvocationTargetException
*/
- public Object invoke(Object o, Object[] params)
+ Object invoke(Object o, Object[] params)
throws IllegalAccessException, InvocationTargetException;
/**
@@ -50,24 +50,24 @@ public interface VelMethod
*
* @return true if can be reused for this class, false if not
*/
- public boolean isCacheable();
+ boolean isCacheable();
/**
* returns the method name used
* @return The method name used
*/
- public String getMethodName();
+ String getMethodName();
/**
* returns the underlying Method
* @return the method
* @since 2.0
*/
- public Method getMethod();
+ Method getMethod();
/**
* returns the return type of the method invoked
* @return The return type of the method invoked
*/
- public Class getReturnType();
+ Class getReturnType();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java
index c91832ec..1d0b9e23 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java
@@ -37,7 +37,7 @@ public interface VelPropertyGet
* @return The resulting Object.
* @throws Exception
*/
- public Object invoke(Object o) throws Exception;
+ Object invoke(Object o) throws Exception;
/**
* specifies if this VelPropertyGet is cacheable and able to be
@@ -45,11 +45,11 @@ public interface VelPropertyGet
*
* @return true if can be reused for this class, false if not
*/
- public boolean isCacheable();
+ boolean isCacheable();
/**
* returns the method name used to return this 'property'
* @return The method name used to return this 'property'
*/
- public String getMethodName();
+ String getMethodName();
}
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java
index 75811b61..342f094f 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java
@@ -38,7 +38,7 @@ public interface VelPropertySet
* @return the value returned from the set operation (impl specific)
* @throws Exception
*/
- public Object invoke(Object o, Object arg) throws Exception;
+ Object invoke(Object o, Object arg) throws Exception;
/**
* specifies if this VelPropertySet is cacheable and able to be
@@ -46,11 +46,11 @@ public interface VelPropertySet
*
* @return true if can be reused for this class, false if not
*/
- public boolean isCacheable();
+ boolean isCacheable();
/**
* returns the method name used to set this 'property'
* @return The method name used to set this 'property'
*/
- public String getMethodName();
+ String getMethodName();
}