You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@apache.org on 2001/03/04 22:09:56 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/configuration Configuration.java ConfigurationsRepository.java
jvanzyl 01/03/04 13:09:56
Modified: src/java/org/apache/velocity/runtime/configuration
Configuration.java ConfigurationsRepository.java
Log:
- fixing the problem where a property value that is meant to
be overriden is clumped together with the value it should
be replacing into a vector causing a ClassCastException.
velocity lays down a set of default properties first,
so when a value was meant to be replaced it was being
combined into a vector with the default value which
is not what we want.
so i added a setOverridingProperty(k,v) when you specifically
want to replace a property which is what we want to do
in the runtime when we are setting overriding properties :-)
Revision Changes Path
1.7 +12 -1 jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java
Index: Configuration.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Configuration.java 2001/03/04 00:39:24 1.6
+++ Configuration.java 2001/03/04 21:09:55 1.7
@@ -64,7 +64,7 @@
* Based upon TurbineResources
*
* @author Dave Bryson
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class Configuration
{
@@ -168,6 +168,17 @@
public void setProperty( String name, String value )
{
conf.getRepository().setProperty( name, value );
+ }
+
+ /**
+ * Add properties from the external but override.
+ *
+ * @param the name of the value
+ * @param the value
+ */
+ public void setOverridingProperty( String name, String value )
+ {
+ conf.getRepository().setOverridingProperty( name, value );
}
/**
1.4 +18 -1 jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/ConfigurationsRepository.java
Index: ConfigurationsRepository.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/ConfigurationsRepository.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConfigurationsRepository.java 2001/03/04 20:15:13 1.3
+++ ConfigurationsRepository.java 2001/03/04 21:09:55 1.4
@@ -75,7 +75,7 @@
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Id: ConfigurationsRepository.java,v 1.3 2001/03/04 20:15:13 jvanzyl Exp $
+ * @version $Id: ConfigurationsRepository.java,v 1.4 2001/03/04 21:09:55 jvanzyl Exp $
*/
public abstract class ConfigurationsRepository
extends Hashtable
@@ -160,6 +160,7 @@
public void setProperty(String key, Object token)
{
Object o = this.get(key);
+
if (o instanceof String)
{
Vector v = new Vector(2);
@@ -175,6 +176,22 @@
{
this.put(key, token);
}
+ }
+
+ /**
+ * Set a property making sure that the property
+ * is overriden. We use this in the case where
+ * there is a default property all ready specified
+ * and we don't want a Vector created with the default
+ * and the new value which setProperty(k,v) above
+ * will do. We want to replace the value.
+ *
+ * @param String key
+ * @param String value
+ */
+ public void setOverridingProperty(String key, Object token)
+ {
+ this.put(key, token);
}
/**