You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by ap...@apache.org on 2010/12/01 13:15:41 UTC
svn commit: r1040976 [1/2] - in /velocity/engine/trunk/velocity-engine-core:
./ src/main/java/org/apache/velocity/app/event/implement/
src/main/java/org/apache/velocity/runtime/
src/main/java/org/apache/velocity/runtime/directive/ src/main/java/org/apa...
Author: apetrelli
Date: Wed Dec 1 12:15:39 2010
New Revision: 1040976
URL: http://svn.apache.org/viewvc?rev=1040976&view=rev
Log:
VELOCITY-789
Removed ORO, Avalon.
Commons Lang is only a test dependency.
First pass for removing Commons Collections.
Added:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/lang/
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/lang/Entities.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/lang/StringEscapeUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/lang/StringUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/thirdparty/commons/lang/UnhandledException.java
Removed:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/AvalonLogChute.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/VelocityFormatter.java
Modified:
velocity/engine/trunk/velocity-engine-core/pom.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeHtmlReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeJavaScriptReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeSqlReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeXmlReference.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/Block.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.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/DataSourceResourceLoader.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/introspection/ClassMap.java
velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties
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/sql/HsqlDB.java
Modified: velocity/engine/trunk/velocity-engine-core/pom.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/pom.xml?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-core/pom.xml Wed Dec 1 12:15:39 2010
@@ -52,18 +52,7 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
- </dependency>
- <dependency>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- <version>2.0.8</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeHtmlReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeHtmlReference.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeHtmlReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeHtmlReference.java Wed Dec 1 12:15:39 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.app.event.implement;
+import org.apache.velocity.thirdparty.commons.lang.StringEscapeUtils;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,11 +18,9 @@ package org.apache.velocity.app.event.im
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.commons.lang.StringEscapeUtils;
-
/**
* Escape all HTML entities.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)">StringEscapeUtils</a>
@@ -32,7 +32,7 @@ public class EscapeHtmlReference extends
/**
* Escape all HTML entities.
- *
+ *
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)">StringEscapeUtils</a>
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeJavaScriptReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeJavaScriptReference.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeJavaScriptReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeJavaScriptReference.java Wed Dec 1 12:15:39 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.app.event.implement;
+import org.apache.velocity.thirdparty.commons.lang.StringEscapeUtils;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,11 +18,9 @@ package org.apache.velocity.app.event.im
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.commons.lang.StringEscapeUtils;
-
/**
* Escapes the characters in a String to be suitable for use in JavaScript.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeJavaScript(java.lang.String)">StringEscapeUtils</a>
@@ -32,7 +32,7 @@ public class EscapeJavaScriptReference e
/**
* Escapes the characters in a String to be suitable for use in JavaScript.
- *
+ *
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeJavaScript(java.lang.String)">StringEscapeUtils</a>
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java Wed Dec 1 12:15:39 2010
@@ -16,13 +16,11 @@ package org.apache.velocity.app.event.im
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.oro.text.perl.MalformedPerl5PatternException;
-import org.apache.oro.text.perl.Perl5Util;
-//import java.util.regex.Pattern;
-//import java.util.regex.Matcher;
+import java.util.regex.PatternSyntaxException;
+
import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.util.RuntimeServicesAware;
@@ -59,9 +57,6 @@ import org.apache.velocity.util.StringUt
*/
public abstract class EscapeReference implements ReferenceInsertionEventHandler,RuntimeServicesAware {
-//
- private Perl5Util perl = new Perl5Util();
-
private RuntimeServices rs;
private String matchRegExp = null;
@@ -88,7 +83,7 @@ public abstract class EscapeReference im
/**
* Escape the provided text if it matches the configured regular expression.
- *
+ *
* @param reference
* @param value
* @return Escaped text.
@@ -106,8 +101,7 @@ public abstract class EscapeReference im
return escape(value);
}
- else if (perl.match(matchRegExp,reference))
- //else if (pattern.matcher(reference).matches())
+ else if (reference.matches(matchRegExp))
{
return escape(value);
}
@@ -120,7 +114,7 @@ public abstract class EscapeReference im
/**
* Called automatically when event cartridge is initialized.
- *
+ *
* @param rs instance of RuntimeServices
*/
public void setRuntimeServices(RuntimeServices rs)
@@ -143,9 +137,9 @@ public abstract class EscapeReference im
{
try
{
- perl.match(matchRegExp,"");
+ "".matches(matchRegExp);
}
- catch (MalformedPerl5PatternException E)
+ catch (PatternSyntaxException E)
{
rs.getLog().error("Invalid regular expression '" + matchRegExp
+ "'. No escaping will be performed.", E);
@@ -158,7 +152,7 @@ public abstract class EscapeReference im
/**
* Retrieve a reference to RuntimeServices. Use this for checking additional
* configuration properties.
- *
+ *
* @return The current runtime services object.
*/
protected RuntimeServices getRuntimeServices()
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeSqlReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeSqlReference.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeSqlReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeSqlReference.java Wed Dec 1 12:15:39 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.app.event.implement;
+import org.apache.velocity.thirdparty.commons.lang.StringEscapeUtils;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,11 +18,9 @@ package org.apache.velocity.app.event.im
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.commons.lang.StringEscapeUtils;
-
/**
* Escapes the characters in a String to be suitable to pass to an SQL query.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeSql(java.lang.String)">StringEscapeUtils</a>
@@ -32,7 +32,7 @@ public class EscapeSqlReference extends
/**
* Escapes the characters in a String to be suitable to pass to an SQL query.
- *
+ *
* @param text
* @return An escaped string.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeSql(java.lang.String)">StringEscapeUtils</a>
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeXmlReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeXmlReference.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeXmlReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeXmlReference.java Wed Dec 1 12:15:39 2010
@@ -1,5 +1,7 @@
package org.apache.velocity.app.event.implement;
+import org.apache.velocity.thirdparty.commons.lang.StringEscapeUtils;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -16,11 +18,9 @@ package org.apache.velocity.app.event.im
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.commons.lang.StringEscapeUtils;
-
/**
* Escape all XML entities.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeSql(java.lang.String)">StringEscapeUtils</a>
@@ -32,7 +32,7 @@ public class EscapeXmlReference extends
/**
* Escape all XML entities.
- *
+ *
* @param text
* @return An escaped String.
* @see <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeSql(java.lang.String)">StringEscapeUtils</a>
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -33,7 +33,6 @@ import java.util.Map;
import java.util.Properties;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.Template;
import org.apache.velocity.app.event.EventCartridge;
import org.apache.velocity.app.event.EventHandler;
@@ -1485,7 +1484,7 @@ public class RuntimeInstance implements
}
/* now just create the VM call, and use evaluate */
- StrBuilder template = new StrBuilder("#");
+ StringBuilder template = new StringBuilder("#");
template.append(vmName);
template.append("(");
for( int i = 0; i < params.length; i++)
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -16,7 +16,7 @@ package org.apache.velocity.runtime;
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.StringReader;
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Vector;
import java.util.ArrayList;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.Template;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.directive.Directive;
@@ -35,6 +34,7 @@ import org.apache.velocity.runtime.direc
import org.apache.velocity.runtime.log.LogDisplayWrapper;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
/**
* VelocimacroFactory.java
@@ -262,7 +262,7 @@ public class VelocimacroFactory
RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, false))
{
setReplacementPermission(true);
-
+
log.debug("allowInlineToOverride = true : VMs " +
"defined inline may replace previous VM definitions");
}
@@ -319,7 +319,7 @@ public class VelocimacroFactory
/**
* Adds a macro to the factory.
- *
+ *
* addVelocimacro(String, Node, String[] argArray, String) should be used internally
* instead of this.
*
@@ -328,7 +328,7 @@ public class VelocimacroFactory
* @param macroArgs Array of macro arguments, containing the
* #macro() arguments and default values. the 0th is the name.
* @param sourceTemplate Source template from which the macro gets registered.
- *
+ *
* @return true if Macro was registered successfully.
*/
public boolean addVelocimacro(String name, String macroBody,
@@ -370,7 +370,7 @@ public class VelocimacroFactory
/*
* see if the current ruleset allows this addition
*/
-
+
if (!canAddVelocimacro(name, sourceTemplate))
{
return false;
@@ -404,7 +404,7 @@ public class VelocimacroFactory
/**
* Adds a macro to the factory.
- *
+ *
* @param name Name of the Macro to add.
* @param macroBody root node of the parsed macro AST
* @param macroArgs Array of macro arguments, containing the
@@ -470,8 +470,8 @@ public class VelocimacroFactory
}
return true;
}
-
-
+
+
/**
* determines if a given macro/namespace (name, source) combo is allowed
* to be added
@@ -486,7 +486,7 @@ public class VelocimacroFactory
* short circuit and do it if autoloader is on, and the
* template is one of the library templates
*/
-
+
if (autoReloadLibrary && (macroLibVec != null))
{
if( macroLibVec.contains(sourceTemplate) )
@@ -524,7 +524,7 @@ public class VelocimacroFactory
* Concurrency fix: the log entry was changed to debug scope because it
* causes false alarms when several concurrent threads simultaneously (re)parse
* some macro
- */
+ */
if (log.isDebugEnabled())
log.debug("VM addition rejected : "+name+" : inline not allowed to replace existing VM");
return false;
@@ -562,12 +562,12 @@ public class VelocimacroFactory
/**
* Return a list of VelocimacroProxies that are defined by the given
* template name.
- */
+ */
public List<VelocimacroProxy> getVelocimacros(String sourceTemplate)
{
return vmManager.getVelocimacros(sourceTemplate);
}
-
+
/**
* @since 1.6
*/
@@ -663,7 +663,7 @@ public class VelocimacroFactory
/**
* tells the vmManager to dump the specified namespace
- *
+ *
* @param namespace Namespace to dump.
* @return True if namespace has been dumped successfully.
*/
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java Wed Dec 1 12:15:39 2010
@@ -16,14 +16,13 @@ package org.apache.velocity.runtime.dire
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.runtime.Renderable;
@@ -110,7 +109,7 @@ public abstract class Block extends Dire
*/
protected String id(InternalContextAdapter context)
{
- StrBuilder str = new StrBuilder(100)
+ StringBuilder str = new StringBuilder(100)
.append("block $").append(key);
if (!context.getCurrentTemplateName().equals(getTemplateName()))
{
@@ -118,7 +117,7 @@ public abstract class Block extends Dire
}
return str.toString();
}
-
+
/**
* actual class placed in the context, holds the context
* being used for the render, as well as the parent (which already holds
@@ -129,13 +128,13 @@ public abstract class Block extends Dire
private InternalContextAdapter context;
private Block parent;
private int depth;
-
+
public Reference(InternalContextAdapter context, Block parent)
{
this.context = context;
this.parent = parent;
}
-
+
/**
* Render the AST of this block into the writer using the context.
*/
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java Wed Dec 1 12:15:39 2010
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.Writer;
import java.util.List;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
@@ -37,7 +36,6 @@ import org.apache.velocity.runtime.log.L
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
-import org.apache.velocity.util.introspection.Info;
/**
* This class acts as a proxy for potential macros. When the AST is built
@@ -68,15 +66,15 @@ public class RuntimeMacro extends Direct
* Indicates if we are running in strict reference mode.
*/
protected boolean strictRef = false;
-
+
/**
* badArgsErrorMsg will be non null if the arguments to this macro
- * are deamed bad at init time, see the init method. If his is non null, then this macro
+ * are deamed bad at init time, see the init method. If his is non null, then this macro
* cannot be rendered, and if there is an attempt to render we throw an exception
* with this as the message.
*/
private String badArgsErrorMsg = null;
-
+
/**
* Create a RuntimeMacro instance. Macro name and source
* template stored for later use.
@@ -89,7 +87,7 @@ public class RuntimeMacro extends Direct
{
throw new IllegalArgumentException("Null arguments");
}
-
+
this.macroName = macroName.intern();
}
@@ -140,7 +138,7 @@ public class RuntimeMacro extends Direct
super.init(rs, context, node);
rsvc = rs;
this.node = node;
-
+
/**
* Apply strictRef setting only if this really looks like a macro,
* so strict mode doesn't balk at things like #E0E0E0 in a template.
@@ -153,7 +151,7 @@ public class RuntimeMacro extends Direct
{
strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
}
-
+
// Validate that none of the arguments are plain words, (VELOCITY-614)
// they should be string literals, references, inline maps, or inline lists
for (int n=0; n < node.jjtGetNumChildren(); n++)
@@ -161,9 +159,9 @@ public class RuntimeMacro extends Direct
Node child = node.jjtGetChild(n);
if (child.getType() == ParserTreeConstants.JJTWORD)
{
- badArgsErrorMsg = "Invalid arg '" + child.getFirstToken().image
+ badArgsErrorMsg = "Invalid arg '" + child.getFirstToken().image
+ "' in macro #" + macroName + " at " + Log.formatFileString(child);
-
+
if (strictRef) // If strict, throw now
{
/* indicate col/line assuming it starts at 0
@@ -172,7 +170,7 @@ public class RuntimeMacro extends Direct
context.getCurrentTemplateName(), 0, 0);
}
}
- }
+ }
}
/**
@@ -184,7 +182,7 @@ public class RuntimeMacro extends Direct
{
if (literal == null)
{
- StrBuilder buffer = new StrBuilder();
+ StringBuilder buffer = new StringBuilder();
Token t = node.getFirstToken();
while (t != null && t != node.getLastToken())
@@ -202,7 +200,7 @@ public class RuntimeMacro extends Direct
}
return literal;
}
-
+
/**
* Velocimacro implementation is not known at the init time. So look for
@@ -229,7 +227,7 @@ public class RuntimeMacro extends Direct
{
return render(context, writer, node, null);
}
-
+
/**
* This method is used with BlockMacro when we want to render a macro with a body AST.
*
@@ -250,7 +248,7 @@ public class RuntimeMacro extends Direct
{
VelocimacroProxy vmProxy = null;
String renderingTemplate = context.getCurrentTemplateName();
-
+
/**
* first look in the source template
*/
@@ -336,7 +334,7 @@ public class RuntimeMacro extends Direct
throw new VelocityException("Macro '#" + macroName + "' is not defined at "
+ Log.formatFileString(node));
}
-
+
/**
* If we cannot find an implementation write the literal text
*/
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/LogManager.java Wed Dec 1 12:15:39 2010
@@ -16,7 +16,7 @@ package org.apache.velocity.runtime.log;
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.util.List;
@@ -154,21 +154,13 @@ public class LogManager
throw new VelocityException(msg);
}
}
+ catch(ClassNotFoundException e)
+ {
+ treatMissingClass(log, claz, e);
+ }
catch(NoClassDefFoundError ncdfe)
{
- // note these errors for anyone debugging the app
- if (isProbablyProvidedLogChute(claz))
- {
- log.debug("Target log system for " + claz +
- " is not available (" + ncdfe.toString() +
- "). Falling back to next log system...");
- }
- else
- {
- log.debug("Couldn't find class " + claz +
- " or necessary supporting classes in classpath.",
- ncdfe);
- }
+ treatMissingClass(log, claz, ncdfe);
}
catch(UnsupportedOperationException uoe)
{
@@ -209,6 +201,24 @@ public class LogManager
return slc;
}
+ private static void treatMissingClass(Log log, String claz,
+ Throwable e)
+ {
+ // note these errors for anyone debugging the app
+ if (isProbablyProvidedLogChute(claz))
+ {
+ log.debug("Target log system for " + claz +
+ " is not available (" + e.toString() +
+ "). Falling back to next log system...");
+ }
+ else
+ {
+ log.debug("Couldn't find class " + claz +
+ " or necessary supporting classes in classpath.",
+ e);
+ }
+ }
+
/**
* Simply tells whether the specified classname probably is provided
* by Velocity or is implemented by someone else. Not surefire, but
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/Parser.java Wed Dec 1 12:15:39 2010
@@ -7,10 +7,7 @@ import org.apache.velocity.exception.Vel
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.node.*;
import org.apache.velocity.runtime.directive.Directive;
-import org.apache.velocity.runtime.directive.Macro;
import org.apache.velocity.runtime.directive.MacroParseException;
-import org.apache.velocity.util.StringUtils;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.runtime.RuntimeConstants;
/**
@@ -39,7 +36,7 @@ public class Parser/*@bgen(jjtree)*/impl
public String currentTemplateName = "";
/**
- * Set to true if the property
+ * Set to true if the property
* RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE is set to true
*/
public boolean strictEscape = false;
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/ParserTokenManager.java Wed Dec 1 12:15:39 2010
@@ -1,16 +1,8 @@
/* Generated By:JJTree&JavaCC: Do not edit this line. ParserTokenManager.java */
package org.apache.velocity.runtime.parser;
-import java.io.*;
-import java.util.*;
-import org.apache.velocity.exception.VelocityException;
-import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.parser.node.*;
-import org.apache.velocity.runtime.directive.Directive;
-import org.apache.velocity.runtime.directive.Macro;
-import org.apache.velocity.runtime.directive.MacroParseException;
-import org.apache.velocity.util.StringUtils;
-import org.apache.commons.lang.text.StrBuilder;
-import org.apache.velocity.runtime.RuntimeConstants;
+
+import java.util.ArrayList;
+import java.util.List;
/** Token Manager. */
public class ParserTokenManager implements ParserConstants
@@ -5101,21 +5093,21 @@ private int jjMoveNfa_7(int startState,
}
}
static final int[] jjnextStates = {
- 91, 93, 94, 95, 100, 101, 91, 94, 61, 100, 29, 31, 32, 35, 11, 13,
- 14, 15, 1, 2, 4, 11, 18, 13, 14, 15, 26, 27, 33, 34, 70, 71,
- 73, 74, 75, 76, 87, 89, 84, 85, 81, 82, 16, 17, 19, 21, 26, 27,
- 64, 65, 77, 78, 98, 99, 102, 103, 69, 71, 72, 73, 78, 79, 69, 72,
- 6, 78, 15, 16, 27, 28, 30, 38, 39, 41, 46, 28, 47, 62, 39, 63,
- 50, 53, 60, 67, 18, 19, 20, 21, 31, 36, 43, 9, 10, 22, 23, 76,
- 77, 80, 81, 5, 6, 7, 8, 6, 11, 39, 14, 15, 17, 18, 22, 24,
- 3, 4, 20, 21, 29, 30, 31, 32, 45, 47, 48, 49, 54, 55, 45, 48,
- 31, 54, 24, 26, 27, 30, 6, 8, 9, 10, 6, 13, 8, 9, 10, 21,
- 22, 28, 29, 37, 38, 39, 40, 11, 12, 14, 16, 21, 22, 34, 35, 41,
- 42, 52, 53, 56, 57, 8, 9, 10, 11, 12, 13, 6, 11, 33, 17, 18,
- 20, 21, 23, 24, 25, 26, 27, 28, 54, 56, 57, 58, 68, 69, 54, 57,
- 63, 68, 6, 11, 52, 32, 34, 35, 38, 14, 16, 17, 18, 14, 21, 16,
- 17, 18, 29, 30, 36, 37, 42, 43, 44, 45, 19, 20, 22, 24, 29, 30,
- 46, 47, 61, 62, 66, 67, 6, 11, 27, 17, 18, 19, 20,
+ 91, 93, 94, 95, 100, 101, 91, 94, 61, 100, 29, 31, 32, 35, 11, 13,
+ 14, 15, 1, 2, 4, 11, 18, 13, 14, 15, 26, 27, 33, 34, 70, 71,
+ 73, 74, 75, 76, 87, 89, 84, 85, 81, 82, 16, 17, 19, 21, 26, 27,
+ 64, 65, 77, 78, 98, 99, 102, 103, 69, 71, 72, 73, 78, 79, 69, 72,
+ 6, 78, 15, 16, 27, 28, 30, 38, 39, 41, 46, 28, 47, 62, 39, 63,
+ 50, 53, 60, 67, 18, 19, 20, 21, 31, 36, 43, 9, 10, 22, 23, 76,
+ 77, 80, 81, 5, 6, 7, 8, 6, 11, 39, 14, 15, 17, 18, 22, 24,
+ 3, 4, 20, 21, 29, 30, 31, 32, 45, 47, 48, 49, 54, 55, 45, 48,
+ 31, 54, 24, 26, 27, 30, 6, 8, 9, 10, 6, 13, 8, 9, 10, 21,
+ 22, 28, 29, 37, 38, 39, 40, 11, 12, 14, 16, 21, 22, 34, 35, 41,
+ 42, 52, 53, 56, 57, 8, 9, 10, 11, 12, 13, 6, 11, 33, 17, 18,
+ 20, 21, 23, 24, 25, 26, 27, 28, 54, 56, 57, 58, 68, 69, 54, 57,
+ 63, 68, 6, 11, 52, 32, 34, 35, 38, 14, 16, 17, 18, 14, 21, 16,
+ 17, 18, 29, 30, 36, 37, 42, 43, 44, 45, 19, 20, 22, 24, 29, 30,
+ 46, 47, 61, 62, 66, 67, 6, 11, 27, 17, 18, 19, 20,
};
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
{
@@ -5132,11 +5124,11 @@ private static final boolean jjCanMove_0
/** Token literal values. */
public static final String[] jjstrLiteralImages = {
-null, null, null, null, null, null, null, null, null, null, null, null, null,
-null, null, null, null, null, null, null, null, null, null, null, null, null, null,
-null, null, null, null, null, null, null, null, null, null, null, null, null, null,
-null, null, null, null, null, null, null, null, null, null, null, null, null, null,
-null, null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, null, null, null, null, null, null, null, null,
+null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, };
/** Lexer state names. */
@@ -5157,27 +5149,27 @@ public static final String[] lexStateNam
/** Lex State array. */
public static final int[] jjnewLexState = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static final long[] jjtoToken = {
- 0x637fffff9fe07fffL, 0x13cL,
+ 0x637fffff9fe07fffL, 0x13cL,
};
static final long[] jjtoSkip = {
- 0x20000000L, 0xc0L,
+ 0x20000000L, 0xc0L,
};
static final long[] jjtoSpecial = {
- 0x0L, 0xc0L,
+ 0x0L, 0xc0L,
};
static final long[] jjtoMore = {
- 0x401f8000L, 0x0L,
+ 0x401f8000L, 0x0L,
};
protected CharStream input_stream;
private final int[] jjrounds = new int[105];
private final int[] jjstateSet = new int[210];
-private final StrBuilder jjimage = new StrBuilder();
-private StrBuilder image = jjimage;
+private final StringBuilder jjimage = new StringBuilder();
+private StringBuilder image = jjimage;
private int jjimageLen;
private int lengthOfMatch;
protected char curChar;
@@ -5258,7 +5250,7 @@ int jjmatchedPos;
int jjmatchedKind;
/** Get the next Token. */
-public Token getNextToken()
+public Token getNextToken()
{
Token specialToken = null;
Token matchedToken;
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTDirective.java Wed Dec 1 12:15:39 2010
@@ -16,22 +16,21 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.IOException;
import java.io.Writer;
-import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
+import org.apache.velocity.runtime.directive.BlockMacro;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.RuntimeMacro;
-import org.apache.velocity.runtime.directive.BlockMacro;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
@@ -89,7 +88,7 @@ public class ASTDirective extends Simple
throws TemplateInitException
{
/** method is synchronized to avoid concurrent directive initialization **/
-
+
if (!isInitialized)
{
super.init( context, data );
@@ -97,16 +96,16 @@ public class ASTDirective extends Simple
/*
* only do things that are not context dependent
*/
-
+
if (parser.isDirective( directiveName ))
{
isDirective = true;
-
+
try
{
directive = (Directive) parser.getDirective( directiveName )
.getClass().newInstance();
- }
+ }
catch (InstantiationException e)
{
throw new VelocityException(
@@ -121,7 +120,7 @@ public class ASTDirective extends Simple
parser.getDirective(directiveName).getClass().getName(),
e);
}
-
+
directive.setLocation(getLine(), getColumn(), getTemplateName());
directive.init(rsvc, context,this);
}
@@ -163,7 +162,7 @@ public class ASTDirective extends Simple
*/
directive = new RuntimeMacro(directiveName);
directive.setLocation(getLine(), getColumn(), getTemplateName());
-
+
/**
* Initialize it
*/
@@ -171,7 +170,7 @@ public class ASTDirective extends Simple
{
directive.init( rsvc, context, this );
}
-
+
/**
* correct the line/column number if an exception is caught
*/
@@ -185,10 +184,10 @@ public class ASTDirective extends Simple
}
isDirective = true;
}
-
+
isInitialized = true;
}
-
+
return data;
}
@@ -233,16 +232,12 @@ public class ASTDirective extends Simple
{
return directiveName;
}
-
- /**
- * @since 1.5
- */
+
+ @Override
public String toString()
{
- return new ToStringBuilder(this)
- .appendSuper(super.toString())
- .append("directiveName", getDirectiveName())
- .toString();
+ return "ASTDirective [" + super.toString() + ", directiveName="
+ + directiveName + "]";
}
}
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTMethod.java Wed Dec 1 12:15:39 2010
@@ -16,13 +16,11 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.lang.reflect.InvocationTargetException;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
@@ -31,6 +29,7 @@ import org.apache.velocity.exception.Vel
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.directive.StopCommand;
import org.apache.velocity.runtime.parser.Parser;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
import org.apache.velocity.util.ClassUtils;
import org.apache.velocity.util.introspection.Info;
import org.apache.velocity.util.introspection.VelMethod;
@@ -53,6 +52,11 @@ import org.apache.velocity.util.introspe
*/
public class ASTMethod extends SimpleNode
{
+ /**
+ * An empty immutable <code>Class</code> array.
+ */
+ private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
+
private String methodName = "";
private int paramCount = 0;
@@ -115,7 +119,7 @@ public class ASTMethod extends SimpleNod
paramCount = jjtGetNumChildren() - 1;
strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
-
+
return data;
}
@@ -143,8 +147,8 @@ public class ASTMethod extends SimpleNod
* sadly, we do need recalc the values of the args, as this can
* change from visit to visit
*/
- final Class[] paramClasses =
- paramCount > 0 ? new Class[paramCount] : ArrayUtils.EMPTY_CLASS_ARRAY;
+ final Class[] paramClasses =
+ paramCount > 0 ? new Class[paramCount] : EMPTY_CLASS_ARRAY;
for (int j = 0; j < paramCount; j++)
{
@@ -154,8 +158,8 @@ public class ASTMethod extends SimpleNod
paramClasses[j] = params[j].getClass();
}
}
-
- VelMethod method = ClassUtils.getMethod(methodName, params, paramClasses,
+
+ VelMethod method = ClassUtils.getMethod(methodName, params, paramClasses,
o, context, this, strictRef);
if (method == null) return null;
@@ -186,13 +190,13 @@ public class ASTMethod extends SimpleNod
{
return handleInvocationException(o, context, ite.getTargetException());
}
-
+
/** Can also be thrown by method invocation **/
catch( IllegalArgumentException t )
{
return handleInvocationException(o, context, t);
}
-
+
/**
* pass through application level runtime exceptions
*/
@@ -270,23 +274,23 @@ public class ASTMethod extends SimpleNod
/**
* Internal class used as key for method cache. Combines
* ASTMethod fields with array of parameter classes. Has
- * public access (and complete constructor) for unit test
+ * public access (and complete constructor) for unit test
* purposes.
* @since 1.5
*/
public static class MethodCacheKey
{
- private final String methodName;
+ private final String methodName;
private final Class[] params;
public MethodCacheKey(String methodName, Class[] params)
{
- /**
- * Should never be initialized with nulls, but to be safe we refuse
+ /**
+ * Should never be initialized with nulls, but to be safe we refuse
* to accept them.
*/
this.methodName = (methodName != null) ? methodName : StringUtils.EMPTY;
- this.params = (params != null) ? params : ArrayUtils.EMPTY_CLASS_ARRAY;
+ this.params = (params != null) ? params : EMPTY_CLASS_ARRAY;
}
/**
@@ -294,17 +298,17 @@ public class ASTMethod extends SimpleNod
*/
public boolean equals(Object o)
{
- /**
+ /**
* note we skip the null test for methodName and params
* due to the earlier test in the constructor
- */
- if (o instanceof MethodCacheKey)
+ */
+ if (o instanceof MethodCacheKey)
{
- final MethodCacheKey other = (MethodCacheKey) o;
- if (params.length == other.params.length &&
- methodName.equals(other.methodName))
- {
- for (int i = 0; i < params.length; ++i)
+ final MethodCacheKey other = (MethodCacheKey) o;
+ if (params.length == other.params.length &&
+ methodName.equals(other.methodName))
+ {
+ for (int i = 0; i < params.length; ++i)
{
if (params[i] == null)
{
@@ -323,7 +327,7 @@ public class ASTMethod extends SimpleNod
}
return false;
}
-
+
/**
* @see java.lang.Object#hashCode()
@@ -332,10 +336,10 @@ public class ASTMethod extends SimpleNod
{
int result = 17;
- /**
+ /**
* 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)
{
final Class param = params[i];
@@ -344,11 +348,11 @@ public class ASTMethod extends SimpleNod
result = result * 37 + param.hashCode();
}
}
-
+
result = result * 37 + methodName.hashCode();
return result;
- }
+ }
}
/**
@@ -359,6 +363,6 @@ public class ASTMethod extends SimpleNod
{
return methodName;
}
-
-
+
+
}
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java Wed Dec 1 12:15:39 2010
@@ -7,9 +7,9 @@ package org.apache.velocity.runtime.pars
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
@@ -33,7 +32,7 @@ import org.apache.velocity.runtime.parse
/**
* ASTStringLiteral support. Will interpolate!
- *
+ *
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @version $Id$
@@ -72,7 +71,7 @@ public class ASTStringLiteral extends Si
/**
* init : we don't have to do much. Init the tree (there shouldn't be one)
* and then see if interpolation is turned on.
- *
+ *
* @param context
* @param data
* @return Init result.
@@ -91,7 +90,7 @@ public class ASTStringLiteral extends Si
* the stringlit is set at template parse time, so we can do this here
* for now. if things change and we can somehow create stringlits at
* runtime, this must move to the runtime execution path
- *
+ *
* so, only if interpolation is turned on AND it starts with a " AND it
* has a directive or reference, then we can interpolate. Otherwise,
* don't bother.
@@ -107,9 +106,9 @@ public class ASTStringLiteral extends Si
* get the contents of the string, minus the '/" at each end
*/
String img = getFirstToken().image;
-
+
image = img.substring(1, img.length() - 1);
-
+
if (img.startsWith("\""))
{
image = unescape(image);
@@ -126,7 +125,7 @@ public class ASTStringLiteral extends Si
* dreaded <MORE> kludge. Basically, the use of the <MORE> token eats
* the last character of an interpolated string. EXCEPT when a line
* comment (##) is in the string this isn't an issue.
- *
+ *
* So, to solve this we look for a line comment. If it isn't found we
* add a space here and remove it later.
*/
@@ -160,7 +159,7 @@ public class ASTStringLiteral extends Si
/*
* it's possible to not have an initialization context - or we don't
* want to trust the caller - so have a fallback value if so
- *
+ *
* Also, do *not* dump the VM namespace for this template
*/
@@ -178,7 +177,7 @@ public class ASTStringLiteral extends Si
}
adjTokenLineNums(nodeTree);
-
+
/*
* init with context. It won't modify anything
*/
@@ -188,7 +187,7 @@ public class ASTStringLiteral extends Si
return data;
}
-
+
/**
* 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.
@@ -203,15 +202,15 @@ public class ASTStringLiteral extends Si
// Test against null is probably not neccessary, but just being safe
while(tok != null && tok != node.getLastToken())
{
- // If tok is on the first line, then the actual column is
+ // If tok is on the first line, then the actual column is
// offset by the template column.
-
+
if (tok.beginLine == 1)
tok.beginColumn += getColumn();
-
+
if (tok.endLine == 1)
tok.endColumn += getColumn();
-
+
tok.beginLine += getLine()- 1;
tok.endLine += getLine() - 1;
tok = tok.next;
@@ -224,7 +223,7 @@ public class ASTStringLiteral extends Si
*
* @param s StringLiteral without the surrounding quotes
* @param literalQuoteChar char that starts the StringLiteral (" or ')
- */
+ */
private String replaceQuotes(String s, char literalQuoteChar)
{
if( (literalQuoteChar == '"' && s.indexOf("\"") == -1) ||
@@ -232,30 +231,30 @@ public class ASTStringLiteral extends Si
{
return s;
}
-
- StrBuilder result = new StrBuilder(s.length());
+
+ StringBuilder result = new StringBuilder(s.length());
char prev = ' ';
for(int i = 0, is = s.length(); i < is; i++)
{
char c = s.charAt(i);
result.append(c);
-
+
if( i + 1 < is )
{
char next = s.charAt(i + 1);
- // '""' -> "", "''" -> ''
+ // '""' -> "", "''" -> ''
// thus it is not necessary to double quotes if the "surrounding" quotes
// of the StringLiteral are different. See VELOCITY-785
- if( (literalQuoteChar == '"' && (next == '"' && c == '"')) ||
+ if( (literalQuoteChar == '"' && (next == '"' && c == '"')) ||
(literalQuoteChar == '\'' && (next == '\'' && c == '\'')) )
{
i++;
}
- }
+ }
}
return result.toString();
}
-
+
/**
* @since 1.6
*/
@@ -264,8 +263,8 @@ public class ASTStringLiteral extends Si
int u = string.indexOf("\\u");
if (u < 0) return string;
- StrBuilder result = new StrBuilder();
-
+ StringBuilder result = new StringBuilder();
+
int lastCopied = 0;
for (;;)
@@ -312,7 +311,7 @@ public class ASTStringLiteral extends Si
* renders the value of the string literal If the properties allow, and the
* string literal contains a $ or a # the literal is rendered against the
* context Otherwise, the stringlit is returned.
- *
+ *
* @param context
* @return result of the rendering.
*/
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/NodeUtils.java Wed Dec 1 12:15:39 2010
@@ -16,12 +16,9 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
-import org.apache.commons.lang.text.StrBuilder;
-import org.apache.velocity.context.Context;
-import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.runtime.parser.ParserConstants;
import org.apache.velocity.runtime.parser.Token;
@@ -44,10 +41,11 @@ public class NodeUtils
* extract them.
* @param t the Token
* @return StrBuilder with the special tokens.
+ * @since 2.0.0
*/
- public static StrBuilder getSpecialText(Token t)
+ public static StringBuilder getSpecialText(Token t)
{
- StrBuilder sb = new StrBuilder();
+ StringBuilder sb = new StringBuilder();
Token tmp_t = t.specialToken;
@@ -131,22 +129,22 @@ public class NodeUtils
public static String tokenLiteral( Token t )
{
// Look at kind of token and return "" when it's a multiline comment
- if (t.kind == ParserConstants.MULTI_LINE_COMMENT)
+ if (t.kind == ParserConstants.MULTI_LINE_COMMENT)
{
return "";
- }
+ }
else if (t.specialToken == null || t.specialToken.image.startsWith("##"))
{
return t.image;
}
- else
+ else
{
- StrBuilder special = getSpecialText(t);
+ StringBuilder special = getSpecialText(t);
if (special.length() > 0)
{
return special.append(t.image).toString();
}
return t.image;
}
- }
+ }
}
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java Wed Dec 1 12:15:39 2010
@@ -16,14 +16,14 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.lang.reflect.InvocationTargetException;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
import org.apache.velocity.util.introspection.Introspector;
/**
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java Wed Dec 1 12:15:39 2010
@@ -16,15 +16,14 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.lang.reflect.InvocationTargetException;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
import org.apache.velocity.util.introspection.Introspector;
/**
@@ -81,7 +80,7 @@ public class SetPropertyExecutor
try
{
- StrBuilder sb = new StrBuilder("set");
+ StringBuilder sb = new StringBuilder("set");
sb.append(property);
setMethod(introspector.getMethod(clazz, sb.toString(), params));
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java Wed Dec 1 12:15:39 2010
@@ -16,14 +16,13 @@ package org.apache.velocity.runtime.pars
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.IOException;
import java.io.Writer;
+import java.util.Arrays;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.text.StrBuilder;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
@@ -55,7 +54,7 @@ public class SimpleNode implements Node
protected int id;
/** */
- // TODO - It seems that this field is only valid when parsing, and should not be kept around.
+ // TODO - It seems that this field is only valid when parsing, and should not be kept around.
protected Parser parser;
/** */
@@ -72,16 +71,16 @@ public class SimpleNode implements Node
/** */
protected Token last;
-
-
+
+
protected String templateName;
-
+
public RuntimeServices getRuntimeServices()
{
return rsvc;
}
-
+
/**
* @param i
*/
@@ -280,7 +279,7 @@ public class SimpleNode implements Node
}
Token t = first;
- StrBuilder sb = new StrBuilder(NodeUtils.tokenLiteral(t));
+ StringBuilder sb = new StringBuilder(NodeUtils.tokenLiteral(t));
while (t != last)
{
t = t.next;
@@ -290,7 +289,7 @@ public class SimpleNode implements Node
}
/**
- * @throws TemplateInitException
+ * @throws TemplateInitException
* @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
*/
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
@@ -408,14 +407,14 @@ public class SimpleNode implements Node
{
return first.beginColumn;
}
-
+
/**
* @since 1.5
*/
public String toString()
{
- StrBuilder tokens = new StrBuilder();
-
+ StringBuilder tokens = new StringBuilder();
+
for (Token t = getFirstToken(); t != null; )
{
tokens.append("[").append(t.image).append("]");
@@ -433,16 +432,12 @@ public class SimpleNode implements Node
t = t.next;
}
- return new ToStringBuilder(this)
- .append("id", getType())
- .append("info", getInfo())
- .append("invalid", isInvalid())
- .append("children", jjtGetNumChildren())
- .append("tokens", tokens)
- .toString();
+ return "SimpleNode [id=" + id + ", info=" + info + ", invalid="
+ + invalid + ", children=" + Arrays.toString(children)
+ + ", tokens=" + tokens + "]";
}
- public String getTemplateName()
+ public String getTemplateName()
{
return templateName;
}
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java Wed Dec 1 12:15:39 2010
@@ -16,14 +16,16 @@ package org.apache.velocity.runtime.reso
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Map.Entry;
-import org.apache.commons.collections.map.LRUMap;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import java.util.concurrent.ConcurrentHashMap;
@@ -44,10 +46,48 @@ import java.util.concurrent.ConcurrentHa
*/
public class ResourceCacheImpl implements ResourceCache
{
+
+ /**
+ * A simple LRU Map based on {@link LinkedHashSet}.
+ *
+ * @param <K> The key type of the map.
+ * @param <V> The value type of the map.
+ */
+ private static class LRUMap<K, V> extends LinkedHashMap<K, V>{
+
+ /**
+ * The serial version uid;
+ */
+ private static final long serialVersionUID = 5889225121697975043L;
+
+ /**
+ * The size of the cache.
+ */
+ private int cacheSize;
+
+ /**
+ * Constructor.
+ *
+ * @param cacheSize The size of the cache. After reaching this size, the
+ * eldest-accessed element will be erased.
+ */
+ public LRUMap(int cacheSize)
+ {
+ this.cacheSize = cacheSize;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean removeEldestEntry(Entry<K, V> eldest)
+ {
+ return size() > cacheSize;
+ }
+ }
+
/**
* Cache storage, assumed to be thread-safe.
*/
- protected Map cache = new ConcurrentHashMap(512, 0.5f, 30);
+ protected Map<Object, Resource> cache = new ConcurrentHashMap<Object, Resource>(512, 0.5f, 30);
/**
* Runtime services, generally initialized by the
@@ -68,7 +108,7 @@ public class ResourceCacheImpl implement
{
// Create a whole new Map here to avoid hanging on to a
// handle to the unsynch'd LRUMap for our lifetime.
- Map lruCache = Collections.synchronizedMap(new LRUMap(maxSize));
+ Map<Object, Resource> lruCache = Collections.synchronizedMap(new LRUMap<Object, Resource>(maxSize));
lruCache.putAll(cache);
cache = lruCache;
}
@@ -103,7 +143,7 @@ public class ResourceCacheImpl implement
/**
* @see org.apache.velocity.runtime.resource.ResourceCache#enumerateKeys()
*/
- public Iterator enumerateKeys()
+ public Iterator<Object> enumerateKeys()
{
return cache.keySet().iterator();
}
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -100,7 +100,7 @@ public class ResourceManagerImpl
log.debug("Re-initialization of ResourceLoader attempted and ignored.");
return;
}
-
+
ResourceLoader resourceLoader = null;
this.rsvc = rsvc;
@@ -158,7 +158,7 @@ public class ResourceManagerImpl
Object cacheObject = null;
- if (org.apache.commons.lang.StringUtils.isNotEmpty(cacheClassName))
+ if (org.apache.velocity.thirdparty.commons.lang.StringUtils.isNotEmpty(cacheClassName))
{
try
{
@@ -173,12 +173,12 @@ public class ResourceManagerImpl
}
catch (IllegalAccessException ae)
{
- throw new VelocityException("Could not access class '"
+ throw new VelocityException("Could not access class '"
+ cacheClassName + "'", ae);
- }
+ }
catch (InstantiationException ie)
{
- throw new VelocityException("Could not instantiate class '"
+ throw new VelocityException("Could not instantiate class '"
+ cacheClassName + "'", ie);
}
@@ -230,7 +230,7 @@ public class ResourceManagerImpl
StringBuffer loaderID = new StringBuffer(loaderName);
loaderID.append(".").append(RuntimeConstants.RESOURCE_LOADER);
- ExtendedProperties loaderConfiguration =
+ ExtendedProperties loaderConfiguration =
rsvc.getConfiguration().subset(loaderID.toString());
/*
@@ -348,7 +348,7 @@ public class ResourceManagerImpl
{
/*
* it's not in the cache, so load it.
- */
+ */
resource = loadResource(resourceName, resourceType, encoding);
if (resource.getResourceLoader().isCachingOn())
@@ -533,7 +533,7 @@ public class ResourceManagerImpl
* this strikes me as bad...
*/
- if (!org.apache.commons.lang.StringUtils.equals(resource.getEncoding(), encoding))
+ if (!org.apache.velocity.thirdparty.commons.lang.StringUtils.equals(resource.getEncoding(), encoding))
{
log.warn("Declared encoding for template '%s' is different on reload. Old = '%s' New = '%s'",
resource.getName(), resource.getEncoding(), encoding);
@@ -548,12 +548,12 @@ public class ResourceManagerImpl
String resourceKey = resource.getType() + resource.getName();
- /*
+ /*
* we create a copy to avoid partially overwriting a
* template which may be in use in another thread
- */
+ */
- Resource newResource =
+ Resource newResource =
ResourceFactory.getResource(resource.getName(), resource.getType());
newResource.setRuntimeServices(rsvc);
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -16,15 +16,15 @@ package org.apache.velocity.runtime.reso
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.InputStream;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
import org.apache.velocity.util.ClassUtils;
/**
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java?rev=1040976&r1=1040975&r2=1040976&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java Wed Dec 1 12:15:39 2010
@@ -16,7 +16,7 @@ package org.apache.velocity.runtime.reso
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.BufferedInputStream;
@@ -217,7 +217,7 @@ public class DataSourceResourceLoader ex
public synchronized InputStream getResourceStream(final String name)
throws ResourceNotFoundException
{
- if (org.apache.commons.lang.StringUtils.isEmpty(name))
+ if (org.apache.velocity.thirdparty.commons.lang.StringUtils.isEmpty(name))
{
throw new ResourceNotFoundException("DataSourceResourceLoader: Template name was empty or null");
}
@@ -416,7 +416,7 @@ public class DataSourceResourceLoader ex
}
}
}
-
+
/**
* Closes the PreparedStatement.
*/
@@ -440,7 +440,7 @@ public class DataSourceResourceLoader ex
}
}
}
-
+
/**
* Creates the following PreparedStatement query :
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -118,7 +118,7 @@ public class FileResourceLoader extends
/*
* Make sure we have a valid templateName.
*/
- if (org.apache.commons.lang.StringUtils.isEmpty(templateName))
+ if (org.apache.velocity.thirdparty.commons.lang.StringUtils.isEmpty(templateName))
{
/*
* If we don't get a properly formed templateName then
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -16,7 +16,7 @@ package org.apache.velocity.runtime.reso
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.InputStream;
@@ -178,7 +178,7 @@ public class JarResourceLoader extends R
{
InputStream results = null;
- if (org.apache.commons.lang.StringUtils.isEmpty(source))
+ if (org.apache.velocity.thirdparty.commons.lang.StringUtils.isEmpty(source))
{
throw new ResourceNotFoundException("Need to have a resource!");
}
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -26,13 +26,13 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.runtime.resource.util.StringResource;
import org.apache.velocity.runtime.resource.util.StringResourceRepository;
import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
import org.apache.velocity.util.ClassUtils;
/**
@@ -41,7 +41,7 @@ import org.apache.velocity.util.ClassUti
*
* Below is an example configuration for this loader.
* Note that 'repository.class' is not necessary;
- * if not provided, the factory will fall back on using
+ * if not provided, the factory will fall back on using
* {@link StringResourceRepositoryImpl} as the default.
* <pre>
* resource.loader = string
@@ -80,8 +80,8 @@ import org.apache.velocity.util.ClassUti
* StringResourceRepository repo = velocityEngine.getApplicationAttribute("foo");
* </code></pre>
* If you did not specify a name for the repository, then it will be stored under the
- * class name of the repository implementation class (for which the default is
- * 'org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl').
+ * class name of the repository implementation class (for which the default is
+ * 'org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl').
* Incidentally, this is also true for the default statically stored repository.
* </p>
* <p>Whether your repository is stored statically or in Velocity's application
@@ -354,14 +354,14 @@ public class StringResourceLoader extend
}
StringResource resource = this.repository.getStringResource(name);
-
+
if(resource == null)
{
throw new ResourceNotFoundException("Could not locate resource '" + name + "'");
}
-
+
byte [] byteArray = null;
-
+
try
{
byteArray = resource.getBody().getBytes(resource.getEncoding());
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=1040976&r1=1040975&r2=1040976&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 Wed Dec 1 12:15:39 2010
@@ -16,7 +16,7 @@ package org.apache.velocity.runtime.reso
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
import java.io.InputStream;
@@ -26,10 +26,10 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.commons.lang.StringUtils;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.thirdparty.commons.lang.StringUtils;
/**
* This is a simple URL-based loader.