Author: nbubna
Date: Fri Apr 27 20:26:40 2007
New Revision: 533281
URL: http://svn.apache.org/viewvc?view=rev&rev=533281
Log:
add auto-conversion for boolean simple properties
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/Configuration.java
Modified:
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/Configuration.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/Configuration.java?view=diff&rev=533281&r1=533280&r2=533281
==============================================================================
---
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/Configuration.java
(original)
+++
velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/Configuration.java
Fri Apr 27 20:26:40 2007
@@ -45,12 +45,28 @@
return convertableProperties;
}
- public void setProperty(String name, Object value)
+ public void setProperty(String name, String value)
{
//TODO: it could be very convenient to support some very simple
// auto-conversion here, where we'd test if a string value
// is "true" or "false" or "123" and convert those to boolean
// or number values without it being necessary to specify type
+ if ("true".equals(value))
+ {
+ setProperty(name, Boolean.TRUE);
+ }
+ else if ("false".equals(value))
+ {
+ setProperty(name, Boolean.FALSE);
+ }
+ else
+ {
+ simpleProperties.put(name, value);
+ }
+ }
+
+ public void setProperty(String name, Object value)
+ {
simpleProperties.put(name, value);
}