Author: cbrisson
Date: Mon Feb 20 08:41:00 2017
New Revision: 1783725
URL: http://svn.apache.org/viewvc?rev=1783725&view=rev
Log:
[engine] several coding style fixes (Michael remarks)
Modified:
velocity/engine/trunk/README.md
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
Modified: velocity/engine/trunk/README.md
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/README.md?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
--- velocity/engine/trunk/README.md (original)
+++ velocity/engine/trunk/README.md Mon Feb 20 08:41:00 2017
@@ -19,7 +19,7 @@ Here's a description of the top level di
Apache Velocity will run with any Java runtime engine v1.7 or greater.
-Building from source requires Java development kit v1.7 or greater and Maven 3
(3.3.3 at the time of writing).
+Building from source requires Java development kit v1.7 or greater and Maven 3
(3.0.5+).
At compile time, Maven should fetch all needed dependencies, which are:
* commons-lang v3.5
@@ -80,7 +80,7 @@ all arguments are evaluated once at star
copy of the reference to each argument).
* the UberspectLoggable interface has been removed.
-#### VTL Changes:
+#### VTL Changes:
* the hypen ( - ) cannot be used in variable names anymore
* method arguments can be arithmetic expressions
@@ -93,11 +93,11 @@ following values: none, bc (aka. backwar
See the related documentation section for details. To maximize backward
compatibility with 1.x, set it to bc.
-#### Dependencies changes:
+#### Dependencies changes:
* Velocity now requires a JDK version of 1.7 or higher.
* commons-collections and commons-logging aren't needed any more at runtime.
-* there's a new runtime dependency, slf4j-api 1.7.12.
+* there's a new compile-time and runtime dependency, slf4j-api 1.7.12.
* you'll need an SLF4J binding.
* commons-lang has to be upgraded to 3.5.
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
Mon Feb 20 08:41:00 2017
@@ -325,8 +325,7 @@ public class Template extends Resource
/*
* the macro lib wasn't found. Note it and throw
*/
- log.error("template.merge(): cannot find template {}",
- macroLibrary);
+ log.error("cannot find template {}", macroLibrary);
throw re;
}
catch (ParseErrorException pe)
@@ -335,14 +334,14 @@ public class Template extends Resource
* the macro lib was found, but didn't parse - syntax
error
* note it and throw
*/
- rsvc.getLog("parser").error("template.merge(): syntax
error in template {}: {}",
+ rsvc.getLog("parser").error("syntax error in template
{}: {}",
macroLibrary, pe.getMessage(), pe);
throw pe;
}
catch (Exception e)
{
- throw new RuntimeException("Template.merge(): parse
failed in template " +
+ throw new RuntimeException("parse failed in template
" +
(String) macroLibrary + ".", e);
}
}
@@ -411,8 +410,8 @@ public class Template extends Resource
* this shouldn't happen either, but just in case.
*/
- String msg = "Template.merge() failure. The document is null, " +
- "most likely due to parsing error.";
+ String msg = "Template merging failed. The document is null, " +
+ "most likely due to a parsing error.";
throw new RuntimeException(msg);
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
Mon Feb 20 08:41:00 2017
@@ -1220,7 +1220,7 @@ public class RuntimeInstance implements
/*
* if we couldn't get a parser from the pool make one and log it.
*/
- log.info("Runtime : ran out of parsers. Creating a new one. "
+ log.info("Runtime: ran out of parsers. Creating a new one. "
+ " Please increment the parser.pool.size property."
+ " The current value is too small.");
parser = createNewParser();
@@ -1446,7 +1446,7 @@ public class RuntimeInstance implements
* Invokes a currently registered Velocimacro with the params provided
* and places the rendered stream into the writer.
* <br>
- * Note : currently only accepts args to the VM if they are in the context.
+ * Note: currently only accepts args to the VM if they are in the context.
* <br>
* Note: only macros in the global context can be called. This method
doesn't find macros defined by
* templates during previous mergeTemplate calls if
Velocity.VM_PERM_INLINE_LOCAL has been enabled.
@@ -1468,7 +1468,7 @@ public class RuntimeInstance implements
/* check necessary parameters */
if (vmName == null || context == null || writer == null)
{
- String msg = "RuntimeInstance.invokeVelocimacro() : invalid call :
vmName, context, and writer must not be null";
+ String msg = "RuntimeInstance.invokeVelocimacro(): invalid call:
vmName, context, and writer must not be null";
log.error(msg);
throw new NullPointerException(msg);
}
@@ -1486,7 +1486,7 @@ public class RuntimeInstance implements
/* does the VM exist? (only global scope is scanned so this doesn't
find inline macros in templates) */
if (!isVelocimacro(vmName, null))
{
- String msg = "RuntimeInstance.invokeVelocimacro() : VM '" + vmName
+ String msg = "RuntimeInstance.invokeVelocimacro(): VM '" + vmName
+ "' is not registered.";
log.error(msg);
throw new VelocityException(msg);
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
Mon Feb 20 08:41:00 2017
@@ -56,7 +56,7 @@ public class VelocimacroFactory
private Logger log = null;
/**
- * VMManager : deal with namespace management
+ * VMManager: deal with namespace management
* and actually keeps all the VM definitions
*/
private VelocimacroManager vmManager = null;
@@ -189,7 +189,7 @@ public class VelocimacroFactory
vmManager.setRegisterFromLib(true);
- log.debug("adding VMs from VM library : {}", lib);
+ log.debug("adding VMs from VM library: {}", lib);
try
{
@@ -208,7 +208,7 @@ public class VelocimacroFactory
}
catch (Exception e)
{
- String msg = "Velocimacro : Error using VM
library : " + lib;
+ String msg = "Velocimacro: Error using VM
library: " + lib;
log.error(msg, e);
throw new VelocityException(msg, e);
}
@@ -226,7 +226,7 @@ public class VelocimacroFactory
/*
- * allowinline : anything after this will be an inline macro, I
think
+ * allowinline: anything after this will be an inline macro, I
think
* there is the question if a #include is an inline, and I think
so
*
* default = true
@@ -237,15 +237,15 @@ public class VelocimacroFactory
{
setAddMacroPermission(false);
- log.debug("allowInline = false : VMs can NOT be defined inline
in templates");
+ log.debug("allowInline = false: VMs can NOT be defined inline
in templates");
}
else
{
- log.debug("allowInline = true : VMs can be defined inline in
templates");
+ log.debug("allowInline = true: VMs can be defined inline in
templates");
}
/*
- * allowInlineToReplaceGlobal : allows an inline VM , if allowed
at all,
+ * allowInlineToReplaceGlobal: allows an inline VM , if allowed
at all,
* to replace an existing global VM
*
* default = false
@@ -257,12 +257,12 @@ public class VelocimacroFactory
{
setReplacementPermission(true);
- log.debug("allowInlineToOverride = true : VMs " +
+ log.debug("allowInlineToOverride = true: VMs " +
"defined inline may replace previous VM definitions");
}
else
{
- log.debug("allowInlineToOverride = false : VMs " +
+ log.debug("allowInlineToOverride = false: VMs " +
"defined inline may NOT replace previous VM definitions");
}
@@ -273,19 +273,19 @@ public class VelocimacroFactory
vmManager.setNamespaceUsage(true);
/*
- * template-local inline VM mode : default is off
+ * template-local inline VM mode: default is off
*/
setTemplateLocalInline(rsvc.getBoolean(
RuntimeConstants.VM_PERM_INLINE_LOCAL, false));
if (getTemplateLocalInline())
{
- log.debug("allowInlineLocal = true : VMs " +
+ log.debug("allowInlineLocal = true: VMs " +
"defined inline will be local to their defining template
only.");
}
else
{
- log.debug("allowInlineLocal = false : VMs " +
+ log.debug("allowInlineLocal = false: VMs " +
"defined inline will be global in scope if allowed.");
}
@@ -298,16 +298,16 @@ public class VelocimacroFactory
if (getAutoload())
{
- log.debug("autoload on : VM system " +
+ log.debug("autoload on: VM system " +
"will automatically reload global library macros");
}
else
{
- log.debug("autoload off : VM system " +
+ log.debug("autoload off: VM system " +
"will not automatically reload global library macros");
}
- log.trace("Velocimacro : initialization complete.");
+ log.trace("Velocimacro: initialization complete.");
}
}
@@ -331,14 +331,14 @@ public class VelocimacroFactory
* maybe we should throw an exception, maybe just tell
* the caller like this...
*
- * I hate this : maybe exceptions are in order here...
+ * I hate this: maybe exceptions are in order here...
* They definitely would be if this was only called by directly
* by users, but Velocity calls this internally.
*/
if (name == null || macroBody == null || macroArgs == null ||
definingTemplate == null)
{
- String msg = "VM '"+name+"' addition rejected : ";
+ String msg = "VM '"+name+"' addition rejected: ";
if (name == null)
{
msg += "name";
@@ -407,7 +407,7 @@ public class VelocimacroFactory
*/
if (!addNewAllowed)
{
- log.warn("VM addition rejected : {} : inline VelociMacros not
allowed.", name);
+ log.warn("VM addition rejected: {}: inline VelociMacros not
allowed.", name);
return false;
}
@@ -431,7 +431,7 @@ public class VelocimacroFactory
* causes false alarms when several concurrent threads
simultaneously (re)parse
* some macro
*/
- log.debug("VM addition rejected : {} : inline not allowed to
replace existing VM", name);
+ log.debug("VM addition rejected: {}: inline not allowed to
replace existing VM", name);
return false;
}
}
@@ -452,7 +452,7 @@ public class VelocimacroFactory
}
/**
- * actual factory : creates a Directive that will
+ * actual factory: creates a Directive that will
* behave correctly wrt getting the framework to
* dig out the correct # of args
* @param vmName Name of the Macro.
@@ -506,7 +506,7 @@ public class VelocimacroFactory
if (ft > tt)
{
- log.debug("auto-reloading VMs from VM library
: {}", lib);
+ log.debug("auto-reloading VMs from VM library:
{}", lib);
/*
* when there are VMs in a library that invoke
each other, there are
@@ -537,7 +537,7 @@ public class VelocimacroFactory
}
catch (Exception e)
{
- String msg = "Velocimacro : Error using VM library : "
+ lib;
+ String msg = "Velocimacro: Error using VM library: " +
lib;
log.error(msg, e);
throw new VelocityException(msg, e);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
Mon Feb 20 08:41:00 2017
@@ -35,7 +35,7 @@ import java.util.List;
/**
* Macro implements the macro definition directive of VTL.
*
- * example :
+ * example:
*
* #macro( isnull $i )
* #if( $i )
@@ -95,7 +95,7 @@ public class Macro extends Directive
throws IOException
{
/*
- * do nothing : We never render. The VelocimacroProxy object does
that
+ * do nothing: We never render. The VelocimacroProxy object does that
*/
return true;
@@ -228,8 +228,8 @@ public class Macro extends Directive
if (debugMode)
{
- StringBuilder msg = new StringBuilder("Macro.getArgArray() :
nbrArgs=");
- msg.append(numArgs).append(" : ");
+ StringBuilder msg = new StringBuilder("Macro.getArgArray():
nbrArgs=");
+ msg.append(numArgs).append(": ");
macroToString(msg, macroArgs);
rsvc.getLog("macro").debug(msg.toString());
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
Mon Feb 20 08:41:00 2017
@@ -197,7 +197,7 @@ public class Parse extends InputBase
{
path.append(" > " + aTemplateStack);
}
- log.error("Max recursion depth reached ({}) File stack: {}",
+ log.error("Max recursion depth reached ({}). File stack: {}",
templateStack.length, path);
return false;
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Mon Feb 20 08:41:00 2017
@@ -406,7 +406,7 @@ public class ASTReference extends Simple
String localNullString = null;
/*
- * if this reference is escaped (\$foo) then we want to do one of two
things : 1) if this is
+ * if this reference is escaped (\$foo) then we want to do one of two
things: 1) if this is
* a reference in the context, then we want to print $foo 2) if not,
then \$foo (its
* considered schmoo, not VTL)
*/
@@ -514,7 +514,7 @@ public class ASTReference extends Simple
if (logOnNull && referenceType != QUIET_REFERENCE)
{
- log.debug("Null reference [template '{}', line {}, column {}]
: {} cannot be resolved.",
+ log.debug("Null reference [template '{}', line {}, column {}]:
{} cannot be resolved.",
getTemplateName(), this.getLine(), this.getColumn(),
this.literal());
}
return true;
@@ -736,7 +736,7 @@ public class ASTReference extends Simple
/*
- * We support two ways of setting the value in a #set($ref.foo =
$value ) :
+ * We support two ways of setting the value in a #set($ref.foo =
$value ):
* 1) ref.setFoo( value )
* 2) ref,put("foo", value ) to parallel the get() map introspection
*/
@@ -770,7 +770,7 @@ public class ASTReference extends Simple
*/
throw new MethodInvocationException(
- "ASTReference : Invocation of method '"
+ "ASTReference: Invocation of method '"
+ identifier + "' in " + result.getClass()
+ " threw exception "
+ ite.getTargetException().toString(),
@@ -788,7 +788,7 @@ public class ASTReference extends Simple
/*
* maybe a security exception?
*/
- String msg = "ASTReference setValue() : exception : " + e
+ String msg = "ASTReference setValue(): exception: " + e
+ " template at " +
StringUtils.formatFileString(uberInfo);
log.error(msg, e);
throw new VelocityException(msg, e);
@@ -832,7 +832,7 @@ public class ASTReference extends Simple
*/
/*
- * count the escapes : even # -> not escaped, odd -> escaped
+ * count the escapes: even # -> not escaped, odd -> escaped
*/
int i = 0;
@@ -843,7 +843,7 @@ public class ASTReference extends Simple
if (i == -1)
{
/* yikes! */
- log.error("ASTReference.getRoot() : internal error : "
+ log.error("ASTReference.getRoot(): internal error: "
+ "no $ found for slashbang.");
computableReference = false;
nullString = t.image;
@@ -896,7 +896,7 @@ public class ASTReference extends Simple
if (t.image.startsWith("\\"))
{
/*
- * count the escapes : even # -> not escaped, odd -> escaped
+ * count the escapes: even # -> not escaped, odd -> escaped
*/
int i = 0;
@@ -958,7 +958,7 @@ public class ASTReference extends Simple
if (t.image.startsWith("$!{"))
{
/*
- * ex : $!{provider.Title}
+ * ex: $!{provider.Title}
*/
return t.next.image;
@@ -966,7 +966,7 @@ public class ASTReference extends Simple
else
{
/*
- * ex : $!provider.Title
+ * ex: $!provider.Title
*/
return t.image.substring(2);
@@ -975,7 +975,7 @@ public class ASTReference extends Simple
else if (t.image.equals("${"))
{
/*
- * ex : ${provider.Title}
+ * ex: ${provider.Title}
*/
referenceType = FORMAL_REFERENCE;
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
Mon Feb 20 08:41:00 2017
@@ -207,7 +207,7 @@ public class ASTSetDirective extends Sim
* puts the value of the RHS into the context under the key of the LHS
* @param context
* @param writer
- * @return True if rendering was sucessfull.
+ * @return True if rendering was sucessful.
* @throws IOException
* @throws MethodInvocationException
*/
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
Mon Feb 20 08:41:00 2017
@@ -349,7 +349,7 @@ public class ResourceManagerImpl
}
catch (ResourceNotFoundException rnfe)
{
- log.error("ResourceManager : unable to find resource '{}' in
any resource loader.", resourceName);
+ log.error("ResourceManager: unable to find resource '{}' in
any resource loader.", resourceName);
throw rnfe;
}
catch (ParseErrorException pee)
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
Mon Feb 20 08:41:00 2017
@@ -35,7 +35,7 @@ import java.io.Reader;
* <br>
* <br>
* Will load templates from from multiple instances of
- * and arbitrary combinations of :
+ * and arbitrary combinations of:
* <ul>
* <li> jar files
* <li> zip files
@@ -44,7 +44,7 @@ import java.io.Reader;
* This is a configuration-free loader, in that there are no
* parameters to be specified in the configuration properties,
* other than specifying this as the loader to use. For example
- * the following is all that the loader needs to be functional :
+ * the following is all that the loader needs to be functional:
* <br>
* <br>
* resource.loader = class
@@ -85,7 +85,7 @@ public class ClasspathResourceLoader ext
*/
public void init( ExtProperties configuration)
{
- log.trace("ClasspathResourceLoader : initialization complete.");
+ log.trace("ClasspathResourceLoader: initialization complete.");
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
Mon Feb 20 08:41:00 2017
@@ -70,7 +70,7 @@ public class FileResourceLoader extends
*/
public void init( ExtProperties configuration)
{
- log.trace("FileResourceLoader : initialization starting.");
+ log.trace("FileResourceLoader: initialization starting.");
paths.addAll( configuration.getVector("path") );
@@ -79,9 +79,9 @@ public class FileResourceLoader extends
{
String path = StringUtils.trim(it.next());
it.set(path);
- log.debug("FileResourceLoader : adding path '{}'", path);
+ log.debug("FileResourceLoader: adding path '{}'", path);
}
- log.trace("FileResourceLoader : initialization complete.");
+ log.trace("FileResourceLoader: initialization complete.");
}
/**
@@ -114,11 +114,11 @@ public class FileResourceLoader extends
String template = FilenameUtils.normalize( templateName, true );
if ( template == null || template.length() == 0 )
{
- String msg = "File resource error : argument " + template +
+ String msg = "File resource error: argument " + template +
" contains .. and may be trying to access " +
"content outside of template root. Rejected.";
- log.error("FileResourceLoader : {}", msg);
+ log.error("FileResourceLoader: {}", msg);
throw new ResourceNotFoundException ( msg );
}
@@ -161,7 +161,7 @@ public class FileResourceLoader extends
* templates and we didn't find anything so
* throw an exception.
*/
- throw new ResourceNotFoundException("FileResourceLoader : cannot find
" + template);
+ throw new ResourceNotFoundException("FileResourceLoader: cannot find "
+ template);
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
Mon Feb 20 08:41:00 2017
@@ -89,13 +89,13 @@ public class JarResourceLoader extends R
*/
public void init( ExtProperties configuration)
{
- log.trace("JarResourceLoader : initialization starting.");
+ log.trace("JarResourceLoader: initialization starting.");
List paths = configuration.getList("path");
if (paths != null)
{
- log.debug("JarResourceLoader # of paths : {}", paths.size() );
+ log.debug("JarResourceLoader # of paths: {}", paths.size() );
for (ListIterator<String> it = paths.listIterator(); it.hasNext();
)
{
@@ -105,23 +105,23 @@ public class JarResourceLoader extends R
}
}
- log.trace("JarResourceLoader : initialization complete.");
+ log.trace("JarResourceLoader: initialization complete.");
}
private void loadJar( String path )
{
- log.debug("JarResourceLoader : trying to load \"{}\"", path);
+ log.debug("JarResourceLoader: trying to load \"{}\"", path);
// Check path information
if ( path == null )
{
- String msg = "JarResourceLoader : can not load JAR - JAR path is
null";
+ String msg = "JarResourceLoader: can not load JAR - JAR path is
null";
log.error(msg);
throw new RuntimeException(msg);
}
if ( !path.startsWith("jar:") )
{
- String msg = "JarResourceLoader : JAR path must start with jar: ->
see java.net.JarURLConnection for information";
+ String msg = "JarResourceLoader: JAR path must start with jar: ->
see java.net.JarURLConnection for information";
log.error(msg);
throw new RuntimeException(msg);
}
@@ -189,11 +189,11 @@ public class JarResourceLoader extends R
if ( normalizedPath == null || normalizedPath.length() == 0 )
{
- String msg = "JAR resource error : argument " + normalizedPath +
+ String msg = "JAR resource error: argument " + normalizedPath +
" contains .. and may be trying to access " +
"content outside of template root. Rejected.";
- log.error( "JarResourceLoader : {}", msg );
+ log.error( "JarResourceLoader: {}", msg );
throw new ResourceNotFoundException ( msg );
}
@@ -228,7 +228,7 @@ public class JarResourceLoader extends R
}
catch (IOException ioe) {}
}
- String msg = "JAR resource error : Exception while loading
" + source;
+ String msg = "JAR resource error: Exception while loading
" + source;
log.error(msg, e);
throw new VelocityException(msg, e);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
Mon Feb 20 08:41:00 2017
@@ -211,7 +211,7 @@ public class StringResourceLoader extend
*/
public void init(final ExtProperties configuration)
{
- log.trace("StringResourceLoader : initialization starting.");
+ log.trace("StringResourceLoader: initialization starting.");
// get the repository configuration info
String repoClass = configuration.getString(REPOSITORY_CLASS,
REPOSITORY_CLASS_DEFAULT);
@@ -273,7 +273,7 @@ public class StringResourceLoader extend
}
}
- log.trace("StringResourceLoader : initialization complete.");
+ log.trace("StringResourceLoader: initialization complete.");
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/URLResourceLoader.java
Mon Feb 20 08:41:00 2017
@@ -46,46 +46,29 @@ public class URLResourceLoader extends R
private String[] roots = null;
protected HashMap templateRoots = null;
private int timeout = -1;
- private Method[] timeoutMethods;
/**
* @see ResourceLoader#init(org.apache.velocity.util.ExtProperties)
*/
public void init(ExtProperties configuration)
{
- log.trace("URLResourceLoader : initialization starting.");
+ log.trace("URLResourceLoader: initialization starting.");
roots = configuration.getStringArray("root");
if (log.isDebugEnabled())
{
for (String root : roots)
{
- log.debug("URLResourceLoader : adding root '{}'", root);
+ log.debug("URLResourceLoader: adding root '{}'", root);
}
}
timeout = configuration.getInt("timeout", -1);
- if (timeout > 0)
- {
- try
- {
- Class[] types = new Class[] { Integer.TYPE };
- Method conn =
URLConnection.class.getMethod("setConnectTimeout", types);
- Method read = URLConnection.class.getMethod("setReadTimeout",
types);
- timeoutMethods = new Method[] { conn, read };
- log.debug("URLResourceLoader : timeout set to {}", timeout);
- }
- catch (NoSuchMethodException nsme)
- {
- log.debug("URLResourceLoader : Java 1.5+ is required to
customize timeout!", nsme);
- timeout = -1;
- }
- }
// init the template paths map
templateRoots = new HashMap();
- log.trace("URLResourceLoader : initialization complete.");
+ log.trace("URLResourceLoader: initialization complete.");
}
/**
@@ -104,7 +87,7 @@ public class URLResourceLoader extends R
{
if (StringUtils.isEmpty(name))
{
- throw new ResourceNotFoundException("URLResourceLoader : No
template name provided");
+ throw new ResourceNotFoundException("URLResourceLoader: No
template name provided");
}
Reader reader = null;
@@ -116,7 +99,8 @@ public class URLResourceLoader extends R
{
URL u = new URL(root + name);
URLConnection conn = u.openConnection();
- tryToSetTimeout(conn);
+ conn.setConnectTimeout(timeout);
+ conn.setReadTimeout(timeout);
rawStream = conn.getInputStream();
reader = buildReader(rawStream, encoding);
@@ -157,7 +141,7 @@ public class URLResourceLoader extends R
String msg;
if (exception == null)
{
- msg = "URLResourceLoader : Resource '" + name + "' not found.";
+ msg = "URLResourceLoader: Resource '" + name + "' not found.";
}
else
{
@@ -201,7 +185,8 @@ public class URLResourceLoader extends R
// get a connection to the URL
URL u = new URL(root + name);
URLConnection conn = u.openConnection();
- tryToSetTimeout(conn);
+ conn.setConnectTimeout(timeout);
+ conn.setReadTimeout(timeout);
return conn.getLastModified();
}
catch (IOException ioe)
@@ -221,24 +206,4 @@ public class URLResourceLoader extends R
{
return timeout;
}
-
- private void tryToSetTimeout(URLConnection conn)
- {
- if (timeout > 0)
- {
- Object[] arg = new Object[] { new Integer(timeout) };
- try
- {
- timeoutMethods[0].invoke(conn, arg);
- timeoutMethods[1].invoke(conn, arg);
- }
- catch (Exception e)
- {
- String msg = "Unexpected exception while setting connection
timeout for "+conn;
- log.error(msg, e);
- throw new VelocityException(msg, e);
- }
- }
- }
-
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/ExtProperties.java
Mon Feb 20 08:41:00 2017
@@ -550,24 +550,23 @@ public class ExtProperties extends Hasht
*/
public synchronized void load(InputStream input, String enc) throws
IOException {
PropertiesReader reader = null;
- if (enc != null) {
- try {
+ if (enc != null)
+ {
+ try
+ {
reader = new PropertiesReader(new InputStreamReader(input,
enc));
- } catch (UnsupportedEncodingException ex) {
+ }
+ catch (UnsupportedEncodingException ex)
+ {
// Another try coming up....
}
}
- if (reader == null) {
- try {
- reader = new PropertiesReader(new InputStreamReader(input,
"8859_1"));
-
- } catch (UnsupportedEncodingException ex) {
- // ISO8859-1 support is required on java platforms but....
- // If it's not supported, use the system default encoding
- reader = new PropertiesReader(new InputStreamReader(input));
- }
+ // fall back to UTF-8
+ if (reader == null)
+ {
+ reader = new PropertiesReader(new InputStreamReader(input,
StandardCharsets.UTF_8));
}
try {
@@ -1585,7 +1584,7 @@ public class ExtProperties extends Hasht
* by the key has not a valid number format.
*/
public float getFloat(String key, float defaultValue) {
- return getFloat(key, new Float(defaultValue));
+ return getFloat(key, Float.valueOf(defaultValue));
}
/**
@@ -1655,7 +1654,7 @@ public class ExtProperties extends Hasht
* by the key has not a valid number format.
*/
public double getDouble(String key, double defaultValue) {
- return getDouble(key, new Double(defaultValue));
+ return getDouble(key, Double.valueOf(defaultValue));
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
Mon Feb 20 08:41:00 2017
@@ -23,6 +23,8 @@ import org.apache.velocity.runtime.direc
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.util.introspection.Info;
+import org.apache.commons.lang3.StringUtils;
+
/**
* This class provides some methods for dynamically
* invoking methods in objects, and some string
@@ -75,7 +77,7 @@ public class StringUtils
public static String formatFileString(String template, int linenum, int
colnum)
{
StringBuilder buffer = new StringBuilder();
- if (template == null || template.equals(""))
+ if (StringUtils.isEmpty(template))
{
template = "<unknown template>";
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java
Mon Feb 20 08:41:00 2017
@@ -98,7 +98,7 @@ public class Introspector extends Intros
* whoops. Ambiguous. Make a nice log message and return null...
*/
- StringBuilder msg = new StringBuilder("Introspection Error :
Ambiguous method invocation ")
+ StringBuilder msg = new StringBuilder("Introspection Error:
Ambiguous method invocation ")
.append(name)
.append("(");
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java
Mon Feb 20 08:41:00 2017
@@ -32,6 +32,8 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.Locale;
/**
@@ -465,35 +467,11 @@ public abstract class BaseTestCase exten
protected String getFileContents(String file)
{
- String contents = "";
+ String contents;
- File f = null;
try
{
- f = new File(file);
-
- if (f.exists())
- {
- FileReader fr = null;
- try
- {
- fr = new FileReader(f);
- char[] template = new char[(int) f.length()];
- fr.read(template);
- contents = new String(template);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- if (fr != null)
- {
- fr.close();
- }
- }
- }
+ contents = new String(Files.readAllBytes(path),
StandardCharsets.UTF_8);
}
catch (Exception e)
{
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java
Mon Feb 20 08:41:00 2017
@@ -114,7 +114,7 @@ public class IntrospectorTestCase extend
{
// Test double primitive.
- Object[] doubleParams = {(double) 1};
+ Object[] doubleParams = { 1.0 };
String type = "double";
Method method = introspector.getMethod(
MethodProvider.class, type + "Method", doubleParams);
@@ -128,7 +128,7 @@ public class IntrospectorTestCase extend
{
// Test float primitive.
- Object[] floatParams = {(float) 1};
+ Object[] floatParams = { 1.0f };
String type = "float";
Method method = introspector.getMethod(
MethodProvider.class, type + "Method", floatParams);
@@ -142,7 +142,7 @@ public class IntrospectorTestCase extend
{
// Test integer primitive.
- Object[] integerParams = {(int) 1};
+ Object[] integerParams = { 1 };
String type = "integer";
Method method = introspector.getMethod(
MethodProvider.class, type + "Method", integerParams);
@@ -156,7 +156,7 @@ public class IntrospectorTestCase extend
{
// Test long primitive.
- Object[] longParams = {(long) 1};
+ Object[] longParams = { 1L };
String type = "long";
Method method = introspector.getMethod(
MethodProvider.class, type + "Method", longParams);
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java
Mon Feb 20 08:41:00 2017
@@ -513,7 +513,7 @@ extends TestCase
// good object, bad property; change the value
case "$a4.foobar":
- assertEquals(new Integer(5), object);
+ assertEquals(Integer.valueOf(5), object);
assertEquals("foobar", property);
return "zzz";
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java
Mon Feb 20 08:41:00 2017
@@ -86,7 +86,7 @@ public class NumberMethodCallsTestCase e
vc.put("AShort",new Short("10"));
vc.put("AInteger", 10);
vc.put("ALong", 10L);
- vc.put("ADouble", 10d);
+ vc.put("ADouble", 10.0);
vc.put("AFloat", 10f);
vc.put("ABigDecimal",new BigDecimal(10));
vc.put("ABigInteger",new BigInteger("10"));
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java?rev=1783725&r1=1783724&r2=1783725&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/eventhandler/Handler1.java
Mon Feb 20 08:41:00 2017
@@ -44,7 +44,7 @@ public class Handler1
if (value == null)
return null;
else
- return value.toString().toUpperCase() +
value.toString().toLowerCase(Locale.ROOT);
+ return value.toString().toUpperCase(Locale.ROOT) +
value.toString().toLowerCase(Locale.ROOT);
}
/**