You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2006/07/19 00:44:50 UTC
svn commit: r423272 - in /jakarta/commons/proper/collections/trunk:
RELEASE-NOTES.html
src/java/org/apache/commons/collections/ExtendedProperties.java
src/test/org/apache/commons/collections/TestExtendedProperties.java
Author: scolebourne
Date: Tue Jul 18 15:44:49 2006
New Revision: 423272
URL: http://svn.apache.org/viewvc?rev=423272&view=rev
Log:
COLLECTIONS-214 - ExtendedProperties - Include property name had confused static/instance semantics
Modified:
jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java
Modified: jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html?rev=423272&r1=423271&r2=423272&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html (original)
+++ jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html Tue Jul 18 15:44:49 2006
@@ -55,6 +55,7 @@
<center><h3>BUG FIXES</h3></center>
<ul>
<li>Flat3Map - Fix setValue in MapIterator and EntrySetIterator to work correctly [COLLECTIONS-217]</li>
+<li>ExtendedProperties - Include property name had confused static/instance semantics [COLLECTIONS-214]</li>
</ul>
<center><h3>JAVADOC</h3></center>
Modified: jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java?rev=423272&r1=423271&r2=423272&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java (original)
+++ jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java Tue Jul 18 15:44:49 2006
@@ -175,6 +175,15 @@
* This is the name of the property that can point to other
* properties file for including other properties files.
*/
+ private String includePropertyName = null;
+
+ /**
+ * This is the default name of the property that can point to other
+ * properties file for including other properties files.
+ *
+ * @deprecated Use getInclude() and setInclude() methods which operate
+ * on an instance variable from v3.3. Due to be removed in v4.0.
+ */
protected static String include = "include";
/**
@@ -491,21 +500,42 @@
/**
* Gets the property value for including other properties files.
* By default it is "include".
+ * <p>
+ * NOTE: Prior to v3.3 this method accessed a static variable.
+ * It now accesses an instance variable. For compatability, if the
+ * instance variable has not been set then the previous static
+ * variable is then accessed. However, the protected static variable
+ * can now only be set by subclasses.
+ * In v4.0, the static variable will be removed.
*
- * @return A String.
+ * @return the property name which includes another property
*/
public String getInclude() {
- return include;
+ if (includePropertyName == null) {
+ return include; // backwards compatability
+ }
+ if ("".equals(includePropertyName)) {
+ return null; // hack to allow backwards compatability
+ }
+ return includePropertyName;
}
/**
* Sets the property value for including other properties files.
* By default it is "include".
+ * <p>
+ * NOTE: Prior to v3.3 this method set a static variable and affected all
+ * users of the class. It now sets an instance variable.
+ * An empty string is also now converted to null internally.
+ * In v4.0, the static variable will be removed.
*
- * @param inc A String.
+ * @param inc the property name which includes another property, empty converted to null
*/
public void setInclude(String inc) {
- include = inc;
+ if (inc == null) {
+ inc = ""; // hack to allow backwards compatability
+ }
+ includePropertyName = inc;
}
/**
@@ -549,6 +579,7 @@
}
try {
+ String includeProperty = getInclude();
while (true) {
String line = reader.readProperty();
if (line == null) {
@@ -565,7 +596,7 @@
continue;
}
- if (getInclude() != null && key.equalsIgnoreCase(getInclude())) {
+ if (includeProperty != null && key.equalsIgnoreCase(includeProperty)) {
// Recursively load properties files.
File file = null;
Modified: jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java?rev=423272&r1=423271&r2=423272&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java (original)
+++ jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/TestExtendedProperties.java Tue Jul 18 15:44:49 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 The Apache Software Foundation
+ * Copyright 2001-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -311,6 +311,30 @@
assertEquals("foo", extended.getString("test"));
assertEquals("class", extended.getString("resource.loader"));
+ }
+
+ public void testInclude() {
+ ExtendedProperties a = new ExtendedProperties();
+ ExtendedProperties b = new ExtendedProperties();
+
+ assertEquals("include", a.getInclude());
+ assertEquals("include", b.getInclude());
+
+ a.setInclude("import");
+ assertEquals("import", a.getInclude());
+ assertEquals("include", b.getInclude());
+
+ a.setInclude("");
+ assertEquals(null, a.getInclude());
+ assertEquals("include", b.getInclude());
+
+ a.setInclude("hi");
+ assertEquals("hi", a.getInclude());
+ assertEquals("include", b.getInclude());
+
+ a.setInclude(null);
+ assertEquals(null, a.getInclude());
+ assertEquals("include", b.getInclude());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org