Author: nbubna
Date: Thu May 3 20:17:15 2007
New Revision: 535068
URL: http://svn.apache.org/viewvc?view=rev&rev=535068
Log:
relax and allow toolboxes to be empty
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/Toolbox.java
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/Toolbox.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/Toolbox.java?view=diff&rev=535068&r1=535067&r2=535068
==============================================================================
---
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/Toolbox.java
(original)
+++
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/Toolbox.java
Thu May 3 20:17:15 2007
@@ -45,15 +45,16 @@
public Toolbox(Map<String,ToolInfo> toolInfo, Map<String,Object>
properties)
{
- if (toolInfo == null || toolInfo.isEmpty())
+ if (toolInfo == null)
{
- throw new IllegalArgumentException("Toolbox must have one or more
tools");
+ this.infoMap = Collections.emptyMap();
+ }
+ else
+ {
+ this.infoMap = toolInfo;
}
-
- this.infoMap = toolInfo;
this.properties = properties;
}
-
protected void cacheData(Map<String,Object> data)
{
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java?view=diff&rev=535068&r1=535067&r2=535068
==============================================================================
---
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
(original)
+++
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
Thu May 3 20:17:15 2007
@@ -195,19 +195,17 @@
public Toolbox getToolbox(String scope)
{
Map<String,ToolInfo> tools = scopedToolInfo.get(scope);
- if (tools == null)
- {
- return null;
- }
+ Map properties = scopedProperties.get(scope);
Toolbox toolbox;
- Map properties = scopedProperties.get(scope);
if (properties == null && globalProperties == null)
{
toolbox = new Toolbox(tools);
}
else
{
+ //TODO: this will waste cycles on subsequent retrievals
+ // of the same toolbox. consider improving...
if (globalProperties != null)
{
properties.putAll(globalProperties);