geirm 01/03/20 09:19:34
Modified: src/java/org/apache/velocity/runtime/configuration
Configuration.java
Log:
Added two things related to the keysAsListed array :
1) protect to ensure that we don't add the same value twice, as this can
result in much pain and suffering when making subsets, especially when
the key is vector-valued - you get a vector that consists of the
normal elements, followed by one or more vectors as elements because
they get added twice.
2) in clearProperty() ensure that we remove the key from keysAsListed. I
think this makes the first safety check redundant, but as this is only
init-time stuff, the miniscule performance hit of 1) is worth it.
Revision Changes Path
1.17 +29 -3
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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Configuration.java 2001/03/20 00:49:03 1.16
+++ Configuration.java 2001/03/20 17:19:24 1.17
@@ -153,7 +153,7 @@
* @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Configuration.java,v 1.16 2001/03/20 00:49:03 jon Exp $
+ * @version $Id: Configuration.java,v 1.17 2001/03/20 17:19:24 geirm Exp $
*/
public class Configuration extends Hashtable
{
@@ -522,8 +522,19 @@
* to perform operations with configuration
* in a definite order it will be possible.
*/
- keysAsListed.add(key);
-
+
+ /*
+ * safety check
+ */
+
+ if( !containsKey( key ) )
+ {
+ keysAsListed.add(key);
+ }
+
+ /*
+ * and the value
+ */
put(key, token);
}
}
@@ -633,6 +644,20 @@
{
if (containsKey(key))
{
+ /*
+ * we also need to rebuild the keysAsListed or else
+ * things get *very* confusing
+ */
+
+ for(int i = 0; i < keysAsListed.size(); i++)
+ {
+ if ( ( (String) keysAsListed.get(i)).equals( key ) )
+ {
+ keysAsListed.remove(i);
+ break;
+ }
+ }
+
remove(key);
}
}
@@ -720,6 +745,7 @@
* properties files or the order they are set
* dynamically.
*/
+
c.setProperty(newKey, get(key));
}
}
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/... jon
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... daveb
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... geirm
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... geirm
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jon
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... geirm
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... geirm
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... jvanzyl
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
- cvs commit: jakarta-velocity/src/java/org/apache/velocity/run... dlr
