You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by eb...@apache.org on 2004/06/24 14:35:15 UTC
cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration AbstractConfiguration.java BaseConfiguration.java BasePathConfiguration.java BasePathLoader.java BasePropertiesConfiguration.java ClassPropertiesConfiguration.java CompositeConfiguration.java ConfigurationComparator.java ConfigurationConverter.java ConfigurationXMLDocument.java ConfigurationXMLReader.java DatabaseConfiguration.java HierarchicalConfiguration.java HierarchicalConfigurationConverter.java HierarchicalConfigurationXMLReader.java HierarchicalDOM4JConfiguration.java HierarchicalDOMConfiguration.java JNDIConfiguration.java PropertiesConfiguration.java XMLConfiguration.java
ebourg 2004/06/24 05:35:15
Modified: configuration/conf checkstyle.xml
configuration/src/java/org/apache/commons/configuration
AbstractConfiguration.java BaseConfiguration.java
BasePathConfiguration.java BasePathLoader.java
BasePropertiesConfiguration.java
ClassPropertiesConfiguration.java
CompositeConfiguration.java
ConfigurationComparator.java
ConfigurationConverter.java
ConfigurationXMLDocument.java
ConfigurationXMLReader.java
DatabaseConfiguration.java
HierarchicalConfiguration.java
HierarchicalConfigurationConverter.java
HierarchicalConfigurationXMLReader.java
HierarchicalDOM4JConfiguration.java
HierarchicalDOMConfiguration.java
JNDIConfiguration.java PropertiesConfiguration.java
XMLConfiguration.java
Added: configuration/conf HEADER.txt
Log:
code formatting
Revision Changes Path
1.2 +13 -9 jakarta-commons/configuration/conf/checkstyle.xml
Index: checkstyle.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/conf/checkstyle.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- checkstyle.xml 23 Jun 2004 11:15:44 -0000 1.1
+++ checkstyle.xml 24 Jun 2004 12:35:14 -0000 1.2
@@ -6,6 +6,7 @@
<!-- Checkstyle configuration that checks the commons-configuration coding conventions -->
<module name="Checker">
+ <property name="localeLanguage" value="en"/>
<!-- Checks that a package.html file exists for each package. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
@@ -26,8 +27,12 @@
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
- <module name="JavadocMethod"/>
- <module name="JavadocType"/>
+ <module name="JavadocMethod">
+ <property name="allowUndeclaredRTE" value="true"/>
+ </module>
+ <module name="JavadocType">
+ <property name="authorFormat" value="\S"/>
+ </module>
<module name="JavadocVariable"/>
@@ -47,11 +52,8 @@
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<module name="Header">
- <!-- The follow property value demonstrates the ability -->
- <!-- to have access to ANT properties. In this case it uses -->
- <!-- the ${basedir} property to allow Checkstyle to be run -->
- <!-- from any directory within a project. -->
- <property name="headerFile" value="${checkstyle.header.file}"/>
+ <property name="headerFile" value="${basedir}/conf/HEADER.txt"/>
+ <property name="ignoreLines" value="2"/>
</module>
<!-- Following interprets the header file as regular expressions. -->
@@ -112,7 +114,10 @@
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
- <module name="HiddenField"/>
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true"/>
+ <property name="ignoreSetter" value="true"/>
+ </module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
@@ -132,7 +137,6 @@
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
- <!--<module name="FinalParameters"/>-->
<module name="GenericIllegalRegexp">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
1.1 jakarta-commons/configuration/conf/HEADER.txt
Index: HEADER.txt
===================================================================
/*
* Copyright 2001-2004 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
1.15 +23 -13 jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java
Index: AbstractConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/AbstractConfiguration.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AbstractConfiguration.java 22 Jun 2004 09:35:54 -0000 1.14
+++ AbstractConfiguration.java 24 Jun 2004 12:35:14 -0000 1.15
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -35,6 +35,8 @@
* store any data. If you want to write your own Configuration class
* then you should implement only abstract methods from this class.
*
+ * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public abstract class AbstractConfiguration implements Configuration
@@ -209,7 +211,8 @@
// prop.name=${some.other.prop1}/blahblah/${some.other.prop2}
priorVariables.remove(priorVariables.size() - 1);
}
- else {
+ else
+ {
//variable not defined - so put it back in the value
result.append(START_TOKEN).append(variable).append(END_TOKEN);
}
@@ -324,13 +327,16 @@
*
* @return An Iterator of keys that match the prefix.
*/
- public Iterator getKeys(final String prefix) {
-
- return new FilterIterator(getKeys(), new Predicate() {
- public boolean evaluate(Object obj) {
+ public Iterator getKeys(final String prefix)
+ {
+ return new FilterIterator(getKeys(), new Predicate()
+ {
+ public boolean evaluate(Object obj)
+ {
boolean matching = false;
- if (obj instanceof String) {
+ if (obj instanceof String)
+ {
String key = (String) obj;
matching = key.startsWith(prefix + ".") || key.equals(prefix);
}
@@ -1028,7 +1034,8 @@
}
}
- public BigDecimal getBigDecimal(String key) throws NoSuchElementException {
+ public BigDecimal getBigDecimal(String key)
+ {
BigDecimal number = getBigDecimal(key, null);
if (number != null)
{
@@ -1041,7 +1048,8 @@
}
}
- public BigDecimal getBigDecimal(String key, BigDecimal defaultValue) {
+ public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
+ {
Object value = resolveContainerStore(key);
if (value instanceof BigDecimal)
@@ -1070,7 +1078,8 @@
}
}
- public BigInteger getBigInteger(String key) throws NoSuchElementException {
+ public BigInteger getBigInteger(String key)
+ {
BigInteger number = getBigInteger(key, null);
if (number != null)
{
@@ -1083,7 +1092,8 @@
}
}
- public BigInteger getBigInteger(String key, BigInteger defaultValue) {
+ public BigInteger getBigInteger(String key, BigInteger defaultValue)
+ {
Object value = resolveContainerStore(key);
if (value instanceof BigInteger)
1.7 +16 -4 jakarta-commons/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java
Index: BaseConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseConfiguration.java 23 Jun 2004 11:15:45 -0000 1.6
+++ BaseConfiguration.java 24 Jun 2004 12:35:14 -0000 1.7
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.util.Iterator;
import java.util.Map;
@@ -30,7 +30,19 @@
* to use the same key many times concatenating the value strings
* instead of overwriting them.
*
- *
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
+ * @author <a href="mailto:kjohnson@transparent.com">Kent Johnson</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:ipriha@surfeu.fi">Ilkka Priha</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:ksh@scand.com">Konstantin Shaposhnikov</a>
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public class BaseConfiguration extends AbstractConfiguration
1.4 +3 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePathConfiguration.java
Index: BasePathConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePathConfiguration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BasePathConfiguration.java 23 Jun 2004 11:15:45 -0000 1.3
+++ BasePathConfiguration.java 24 Jun 2004 12:35:14 -0000 1.4
@@ -20,6 +20,8 @@
* This is exactly the same as the BaseConfiguration but the backing
* store is based on a path (e.g. a file path) from which it is loaded.
*
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public abstract class BasePathConfiguration extends BaseConfiguration implements BasePathLoader
1.3 +6 -3 jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePathLoader.java
Index: BasePathLoader.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePathLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BasePathLoader.java 27 Feb 2004 17:41:35 -0000 1.2
+++ BasePathLoader.java 24 Jun 2004 12:35:14 -0000 1.3
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,12 +14,15 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
/**
* <p>Definition of an interface for objects that load configuration data
* from a URL.</p>
* <p>The interface defines methods for getting and setting a base path.
* A file name will then be interpreted relative to this base path.</p>
*
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public interface BasePathLoader
@@ -29,6 +30,7 @@
/**
* Returns the base path. Relative path names will be resolved based on
* this path.
+ *
* @return the base path
*/
String getBasePath();
@@ -36,6 +38,7 @@
/**
* Sets the base path. Relative path names will be resolved based on
* this path. For maximum flexibility this base path should be a URL.
+ *
* @param path the base path
*/
void setBasePath(String path);
1.14 +16 -4 jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePropertiesConfiguration.java
Index: BasePropertiesConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/BasePropertiesConfiguration.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BasePropertiesConfiguration.java 23 Jun 2004 11:15:45 -0000 1.13
+++ BasePropertiesConfiguration.java 24 Jun 2004 12:35:14 -0000 1.14
@@ -111,6 +111,18 @@
* second.prop = ${first.prop}/second
* </pre>
*
+ * @author <a href="mailto:e.bourg@cross-systems.com">Emmanuel Bourg</a>
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
+ * @author <a href="mailto:kjohnson@transparent.com">Kent Johnson</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:ipriha@surfeu.fi">Ilkka Priha</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
public abstract class BasePropertiesConfiguration extends BasePathConfiguration
@@ -218,7 +230,7 @@
}
catch (IOException ioe)
{
- throw new ConfigurationException("Could not load configuration from input stream.",ioe);
+ throw new ConfigurationException("Could not load configuration from input stream.", ioe);
}
}
@@ -241,7 +253,7 @@
}
catch (IOException e)
{
- throw new ConfigurationException("Could not save to file " + filename, e);
+ throw new ConfigurationException("Could not save to file " + filename, e);
}
finally
{
@@ -486,7 +498,7 @@
* drop escaped commas (i.e '\,').
*
* @param str the <code>String</code> to unescape, may be null
- *
+ *
* @throws IllegalArgumentException if the Writer is <code>null</code>
*/
protected static String unescapeJava(String str)
1.8 +3 -3 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java
Index: ClassPropertiesConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ClassPropertiesConfiguration.java 23 Jun 2004 11:15:45 -0000 1.7
+++ ClassPropertiesConfiguration.java 24 Jun 2004 12:35:14 -0000 1.8
@@ -31,6 +31,7 @@
*
* @see org.apache.commons.configuration.BasePropertiesConfiguration
*
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
public class ClassPropertiesConfiguration extends BasePropertiesConfiguration implements Configuration
@@ -92,8 +93,7 @@
if (resource == null)
{
- throw new FileNotFoundException("Could not open Resource "
- + resourceName);
+ throw new FileNotFoundException("Could not open Resource " + resourceName);
}
return resource;
1.15 +17 -10 jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java
Index: CompositeConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/CompositeConfiguration.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CompositeConfiguration.java 21 Jun 2004 12:37:40 -0000 1.14
+++ CompositeConfiguration.java 24 Jun 2004 12:35:14 -0000 1.15
@@ -28,6 +28,8 @@
* You can add multiple different types or the same type of properties file.
* If Configuration1 doesn't have the property, then Configuration2 will be checked.
*
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
public class CompositeConfiguration extends AbstractConfiguration
@@ -136,8 +138,6 @@
{
return null;
}
- /*throw new NoSuchElementException(
- '\'' + key + "' doesn't map to an existing object");*/
}
/**
@@ -152,7 +152,9 @@
for (Iterator i = configList.iterator(); i.hasNext();)
{
Configuration config = (Configuration) i.next();
- for (Iterator j = config.getKeys(); j.hasNext();)
+
+ Iterator j = config.getKeys();
+ while (j.hasNext())
{
String key = (String) j.next();
if (!keys.contains(key))
@@ -161,6 +163,7 @@
}
}
}
+
return keys.iterator();
}
@@ -176,7 +179,9 @@
for (Iterator i = configList.iterator(); i.hasNext();)
{
Configuration config = (Configuration) i.next();
- for (Iterator j = config.getKeys(key); j.hasNext();)
+
+ Iterator j = config.getKeys(key);
+ while (j.hasNext())
{
String newKey = (String) j.next();
if (!keys.contains(newKey))
@@ -185,6 +190,7 @@
}
}
}
+
return keys.iterator();
}
@@ -199,15 +205,16 @@
return false;
}
}
+
return isEmpty;
}
/**
- * Gets a property from the configuration.
+ * Gets a property from the configuration.
*
- * @param key property to retrieve
- * @return value as object. Will return user value if exists,
- * if not then default value if exists, otherwise null
+ * @param key property to retrieve
+ * @return value as object. Will return user value if exists,
+ * if not then default value if exists, otherwise null
*/
public Object getProperty(String key)
{
@@ -243,7 +250,7 @@
}
/**
- * check if the configuration contains the key
+ * Check if the configuration contains the key
*/
public boolean containsKey(String key)
{
1.4 +2 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationComparator.java
Index: ConfigurationComparator.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationComparator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConfigurationComparator.java 22 Jun 2004 09:56:38 -0000 1.3
+++ ConfigurationComparator.java 24 Jun 2004 12:35:15 -0000 1.4
@@ -20,7 +20,7 @@
* Comparator for configurations interface.
*
* @since 1.0
- *
+ *
* @author <a href="mailto:herve.quiroz@esil.univ-mrs.fr">Herve Quiroz</a>
* @version $Revision$, $Date$
*/
1.6 +7 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java
Index: ConfigurationConverter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConfigurationConverter.java 16 Jun 2004 15:17:09 -0000 1.5
+++ ConfigurationConverter.java 24 Jun 2004 12:35:15 -0000 1.6
@@ -31,8 +31,13 @@
* @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
* @version $Revision$, $Date$
*/
-public class ConfigurationConverter
+public final class ConfigurationConverter
{
+ private ConfigurationConverter()
+ {
+ // to prevent instanciation...
+ }
+
/**
* Convert a ExtendedProperties class into a Configuration class.
*
1.5 +45 -31 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationXMLDocument.java
Index: ConfigurationXMLDocument.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationXMLDocument.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ConfigurationXMLDocument.java 8 Mar 2004 23:42:16 -0000 1.4
+++ ConfigurationXMLDocument.java 24 Jun 2004 12:35:15 -0000 1.5
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.IOException;
import java.io.Writer;
import java.util.NoSuchElementException;
@@ -61,6 +61,7 @@
/**
* Creates a new instance of <code>ConfigurationXMLDocument</code>
* and sets the configuration object to be processed.
+ *
* @param config the configuration object
*/
public ConfigurationXMLDocument(Configuration config)
@@ -70,6 +71,7 @@
/**
* Returns the <code>Configuration</code> object for this document.
+ *
* @return the <code>Configuration</code> object
*/
public Configuration getConfiguration()
@@ -79,6 +81,7 @@
/**
* Sets the <code>Configuration</code> object this document operates on.
+ *
* @param configuration the <code>Configuration</code> object
*/
public void setConfiguration(Configuration configuration)
@@ -90,6 +93,7 @@
* Returns a <code>XMLReader</code> object for the specified configuration
* object. This reader can then be used to perform XML-like processing on
* the configuration.
+ *
* @param config the configuration object
* @return a XMLReader for this configuration
*/
@@ -97,18 +101,18 @@
{
if (config instanceof HierarchicalConfiguration)
{
- return new HierarchicalConfigurationXMLReader(
- (HierarchicalConfiguration) config);
- } /* if */
+ return new HierarchicalConfigurationXMLReader((HierarchicalConfiguration) config);
+ }
else
{
return new BaseConfigurationXMLReader(config);
- } /* else */
+ }
}
/**
* Returns a <code>XMLReader</code> object for the actual configuration
* object.
+ *
* @return a XMLReader for the actual configuration
*/
public ConfigurationXMLReader createXMLReader()
@@ -121,6 +125,7 @@
* configuration specified by the given prefix. If no properties are found
* under this prefix, a <code>NoSuchElementException</code>
* exception will be thrown.
+ *
* @param prefix the prefix of the configuration keys that belong to the
* subset; can be <b>null</b>, then the whole configuration is affected
* @return a XMLReader for the specified subset configuration
@@ -132,6 +137,7 @@
/**
* Transforms the wrapped configuration into a dom4j document.
+ *
* @param prefix a prefix for the keys to process; can be <b>null</b>,
* then all keys in the configuration will be added to the document
* @param rootName the name of the root element in the document; can be
@@ -139,14 +145,13 @@
* @return the document
* @throws DocumentException if an error occurs
*/
- public Document getDocument(String prefix, String rootName)
- throws DocumentException
+ public Document getDocument(String prefix, String rootName) throws DocumentException
{
ConfigurationXMLReader xmlReader = createXMLReader(prefix);
if (rootName != null)
{
xmlReader.setRootName(rootName);
- } /* if */
+ }
SAXReader reader = new SAXReader(xmlReader);
return reader.read(getClass().getName());
@@ -155,6 +160,7 @@
/**
* Transforms the wrapped configuration into a dom4j document. The root
* element will be given a default name.
+ *
* @param prefix a prefix for the keys to process; can be <b>null</b>,
* then all keys in the configuration will be added to the document
* @return the document
@@ -168,6 +174,7 @@
/**
* Transforms the wrapped configuration into a dom4j document. The root
* element will be given a default name.
+ *
* @return the document
* @throws DocumentException if an error occurs
*/
@@ -178,6 +185,7 @@
/**
* Transforms the wrapped configuration into a w3c document.
+ *
* @param prefix a prefix for the keys to process; can be <b>null</b>,
* then all keys in the configuration will be added to the document
* @param rootName the name of the root element in the document; can be
@@ -185,8 +193,7 @@
* @return the document
* @throws DocumentException if an error occurs
*/
- public org.w3c.dom.Document getW3cDocument(String prefix, String rootName)
- throws DocumentException
+ public org.w3c.dom.Document getW3cDocument(String prefix, String rootName) throws DocumentException
{
return toW3cDocument(getDocument(prefix, rootName));
}
@@ -194,13 +201,13 @@
/**
* Transforms the wrapped configuration into a w3c document. The root
* element will be given a default name.
+ *
* @param prefix a prefix for the keys to process; can be <b>null</b>,
* then all keys in the configuration will be added to the document
* @return the document
* @throws DocumentException if an error occurs
*/
- public org.w3c.dom.Document getW3cDocument(String prefix)
- throws DocumentException
+ public org.w3c.dom.Document getW3cDocument(String prefix) throws DocumentException
{
return getW3cDocument(prefix, null);
}
@@ -208,6 +215,7 @@
/**
* Transforms the wrapped configuration into a w3c document. The root
* element will be given a default name.
+ *
* @return the document
* @throws DocumentException if an error occurs
*/
@@ -218,12 +226,12 @@
/**
* Converts a dom4j document into a w3c document.
+ *
* @param doc the dom4j document
* @return the w3c document
* @throws DocumentException if an error occurs
*/
- static org.w3c.dom.Document toW3cDocument(Document doc)
- throws DocumentException
+ static org.w3c.dom.Document toW3cDocument(Document doc) throws DocumentException
{
return new DOMWriter().write(doc);
}
@@ -232,6 +240,7 @@
* Helper method for constructing a subset if necessary. Depending on
* the passed in key this method either returns the wrapped configuration
* or the specified subset of it.
+ *
* @param key the key
* @return the configuration for that key
*/
@@ -240,14 +249,14 @@
Configuration conf = (key == null)
? getConfiguration()
: getConfiguration().subset(key);
-
+
// undefined?
- if(conf == null || (conf instanceof CompositeConfiguration
+ if (conf == null || (conf instanceof CompositeConfiguration
&& ((CompositeConfiguration) conf).getNumberOfConfigurations() < 2))
{
throw new NoSuchElementException("No subset with key " + key);
- } /* if */
-
+ }
+
return conf;
}
@@ -272,6 +281,7 @@
* </args>
* ...
* </pre></p>
+ *
* @param prefix the prefix of the keys that are passed to Digester; can
* be <b>null</b>, then the whole configuration will be processed
* @return the result of the Digester processing
@@ -287,6 +297,7 @@
/**
* Returns a default Digester instance. This instance is used for the
* simple object creation feature.
+ *
* @param prefix the prefix of the keys to be processed; can be
* <b>null</b>, then the whole configuration is meant
* @return the default Digester instance
@@ -302,6 +313,7 @@
/**
* Creates the default Digester instance for the given prefix. This method
* is called by <code>getDefaultDigester()</code>.
+ *
* @param prefix the prefix of the keys to be processed; can be
* <b>null</b>, then the whole configuration is meant
* @return the default Digester instance
@@ -316,6 +328,7 @@
* creation. Here all needed properties and rules can be set. This base
* implementation sets default rules for object creation as explained in
* the comment for the <code>callDigester()</code> methods.
+ *
* @param digester the digester instance to be initialized
*/
protected void setupDefaultDigester(Digester digester)
@@ -326,6 +339,7 @@
/**
* Writes a configuration (or parts of it) to the given writer.
+ *
* @param out the output writer
* @param prefix the prefix of the subset to write; if <b>null</b>, the
* whole configuration is written
@@ -335,8 +349,7 @@
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
*/
- public void write(Writer out, String prefix, String root, boolean pretty)
- throws IOException, DocumentException
+ public void write(Writer out, String prefix, String root, boolean pretty) throws IOException, DocumentException
{
OutputFormat format =
(pretty)
@@ -348,8 +361,9 @@
}
/**
- * Writes a configuration (or parts of it) to the given writer.
+ * Writes a configuration (or parts of it) to the given writer.
* This overloaded version always uses pretty print mode.
+ *
* @param out the output writer
* @param prefix the prefix of the subset to write; if <b>null</b>, the
* whole configuration is written
@@ -358,8 +372,7 @@
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
*/
- public void write(Writer out, String prefix, String root)
- throws IOException, DocumentException
+ public void write(Writer out, String prefix, String root) throws IOException, DocumentException
{
write(out, prefix, root, true);
}
@@ -367,6 +380,7 @@
/**
* Writes a configuration (or parts of it) to the given writer.
* The resulting document's root element will be given a default name.
+ *
* @param out the output writer
* @param prefix the prefix of the subset to write; if <b>null</b>, the
* whole configuration is written
@@ -374,8 +388,7 @@
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
*/
- public void write(Writer out, String prefix, boolean pretty)
- throws IOException, DocumentException
+ public void write(Writer out, String prefix, boolean pretty) throws IOException, DocumentException
{
write(out, prefix, null, pretty);
}
@@ -384,14 +397,14 @@
* Writes a configuration (or parts of it) to the given writer.
* The resulting document's root element will be given a default name.
* This overloaded version always uses pretty print mode.
+ *
* @param out the output writer
* @param prefix the prefix of the subset to write; if <b>null</b>, the
* whole configuration is written
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
*/
- public void write(Writer out, String prefix)
- throws IOException, DocumentException
+ public void write(Writer out, String prefix) throws IOException, DocumentException
{
write(out, prefix, true);
}
@@ -399,13 +412,13 @@
/**
* Writes the wrapped configuration to the given writer.
* The resulting document's root element will be given a default name.
+ *
* @param out the output writer
* @param pretty flag for the pretty print mode
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
*/
- public void write(Writer out, boolean pretty)
- throws IOException, DocumentException
+ public void write(Writer out, boolean pretty) throws IOException, DocumentException
{
write(out, null, null, pretty);
}
@@ -414,6 +427,7 @@
* Writes the wrapped configuration to the given writer.
* The resulting document's root element will be given a default name.
* This overloaded version always uses pretty print mode.
+ *
* @param out the output writer
* @throws IOException if an IO error occurs
* @throws DocumentException if there is an error during processing
1.3 +39 -15 jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationXMLReader.java
Index: ConfigurationXMLReader.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ConfigurationXMLReader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConfigurationXMLReader.java 27 Feb 2004 17:41:35 -0000 1.2
+++ ConfigurationXMLReader.java 24 Jun 2004 12:35:15 -0000 1.3
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.IOException;
import org.xml.sax.Attributes;
@@ -36,6 +36,7 @@
* special purpose. There will be concrete sub classes that process specific
* configuration classes.</p>
*
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public abstract class ConfigurationXMLReader implements XMLReader
@@ -70,6 +71,7 @@
/**
* Parses the acutal configuration object. The passed system ID will be
* ignored.
+ *
* @param systemId the system ID (ignored)
* @throws IOException if no configuration was specified
* @throws SAXException if an error occurs during parsing
@@ -82,6 +84,7 @@
/**
* Parses the acutal configuration object. The passed input source will be
* ignored.
+ *
* @param input the input source (ignored)
* @throws IOException if no configuration was specified
* @throws SAXException if an error occurs during parsing
@@ -93,6 +96,7 @@
/**
* Dummy implementation of the interface method.
+ *
* @param name the name of the feature
* @return always <b>false</b> (no features are supported)
*/
@@ -103,6 +107,7 @@
/**
* Dummy implementation of the interface method.
+ *
* @param name the name of the feature to be set
* @param value the value of the feature
*/
@@ -112,6 +117,7 @@
/**
* Returns the actually set content handler.
+ *
* @return the content handler
*/
public ContentHandler getContentHandler()
@@ -122,6 +128,7 @@
/**
* Sets the content handler. The object specified here will receive SAX
* events during parsing.
+ *
* @param handler the content handler
*/
public void setContentHandler(ContentHandler handler)
@@ -132,6 +139,7 @@
/**
* Returns the DTD handler. This class does not support DTD handlers,
* so this method always returns <b>null</b>.
+ *
* @return the DTD handler
*/
public DTDHandler getDTDHandler()
@@ -141,6 +149,7 @@
/**
* Sets the DTD handler. The passed value is ignored.
+ *
* @param handler the handler to be set
*/
public void setDTDHandler(DTDHandler handler)
@@ -150,6 +159,7 @@
/**
* Returns the entity resolver. This class does not support an entity
* resolver, so this method always returns <b>null</b>.
+ *
* @return the entity resolver
*/
public EntityResolver getEntityResolver()
@@ -159,6 +169,7 @@
/**
* Sets the entity resolver. The passed value is ignored.
+ *
* @param resolver the entity resolver
*/
public void setEntityResolver(EntityResolver resolver)
@@ -168,6 +179,7 @@
/**
* Returns the error handler. This class does not support an error handler,
* so this method always returns <b>null</b>.
+ *
* @return the error handler
*/
public ErrorHandler getErrorHandler()
@@ -177,6 +189,7 @@
/**
* Sets the error handler. The passed value is ignored.
+ *
* @param handler the error handler
*/
public void setErrorHandler(ErrorHandler handler)
@@ -186,6 +199,7 @@
/**
* Dummy implementation of the interface method. No properties are
* supported, so this method always returns <b>null</b>.
+ *
* @param name the name of the requested property
* @return the property value
*/
@@ -197,6 +211,7 @@
/**
* Dummy implementation of the interface method. No properties are
* supported, so a call of this method just has no effect.
+ *
* @param name the property name
* @param value the property value
*/
@@ -206,6 +221,7 @@
/**
* Returns the name to be used for the root element.
+ *
* @return the name for the root element
*/
public String getRootName()
@@ -215,6 +231,7 @@
/**
* Sets the name for the root element.
+ *
* @param string the name for the root element.
*/
public void setRootName(String string)
@@ -224,6 +241,7 @@
/**
* Fires a SAX element start event.
+ *
* @param name the name of the actual element
* @param attribs the attributes of this element (can be <b>null</b>)
*/
@@ -235,16 +253,17 @@
{
Attributes at = (attribs == null) ? EMPTY_ATTRS : attribs;
getContentHandler().startElement(NS_URI, name, name, at);
- } /* try */
+ }
catch (SAXException ex)
{
exception = ex;
- } /* catch */
- } /* if */
+ }
+ }
}
/**
* Fires a SAX element end event.
+ *
* @param name the name of the affected element
*/
protected void fireElementEnd(String name)
@@ -254,16 +273,17 @@
try
{
getContentHandler().endElement(NS_URI, name, name);
- } /* try */
+ }
catch (SAXException ex)
{
exception = ex;
- } /* catch */
- } /* if */
+ }
+ }
}
/**
* Fires a SAX characters event.
+ *
* @param text the text
*/
protected void fireCharacters(String text)
@@ -274,16 +294,17 @@
{
char[] ch = text.toCharArray();
getContentHandler().characters(ch, 0, ch.length);
- } /* try */
+ }
catch (SAXException ex)
{
exception = ex;
- } /* catch */
- } /* if */
+ }
+ }
}
/**
* Returns a reference to an exception that occurred during parsing.
+ *
* @return a SAXExcpetion or <b>null</b> if none occurred
*/
public SAXException getException()
@@ -294,6 +315,7 @@
/**
* Parses the configuration object and generates SAX events. This is the
* main processing method.
+ *
* @throws IOException if no configuration has been specified
* @throws SAXException if an error occurs during parsing
*/
@@ -302,7 +324,7 @@
if (getParsedConfiguration() == null)
{
throw new IOException("No configuration specified!");
- } /* if */
+ }
if (getContentHandler() != null)
{
@@ -312,13 +334,14 @@
if (getException() != null)
{
throw getException();
- } /* if */
+ }
getContentHandler().endDocument();
- } /* if */
+ }
}
/**
* Returns a reference to the configuration that is parsed by this object.
+ *
* @return the parsed configuration
*/
public abstract Configuration getParsedConfiguration();
@@ -330,6 +353,7 @@
* <code>startDocument()</code> and <code>endElement()</code> methods
* and cares for exception handling. The remaining actions are left to this
* method that must be implemented in a concrete sub class.
+ *
* @throws IOException if an IO error occurs
* @throws SAXException if a SAX error occurs
*/
1.6 +4 -1 jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java
Index: DatabaseConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/DatabaseConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DatabaseConfiguration.java 23 Jun 2004 11:15:45 -0000 1.5
+++ DatabaseConfiguration.java 24 Jun 2004 12:35:15 -0000 1.6
@@ -352,6 +352,9 @@
/**
* Close a <code>Connection</code> and, <code>Statement</code>.
* Avoid closing if null and hide any SQLExceptions that occur.
+ *
+ * @param conn The database connection to close
+ * @param stmt The statement to close
*/
private void closeQuietly(Connection conn, Statement stmt)
{
1.8 +107 -70 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
Index: HierarchicalConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HierarchicalConfiguration.java 2 Jun 2004 17:04:51 -0000 1.7
+++ HierarchicalConfiguration.java 24 Jun 2004 12:35:15 -0000 1.8
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -88,6 +88,7 @@
* allowed index that can be added to a given property key. This method can be
* used to iterate over all values defined for a certain property.</p>
*
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public class HierarchicalConfiguration extends AbstractConfiguration
@@ -108,6 +109,7 @@
/**
* Returns the root node of this hierarchical configuration.
+ *
* @return the root node
*/
public Node getRoot()
@@ -117,6 +119,7 @@
/**
* Sets the root node of this hierarchical configuration.
+ *
* @param node the root node
*/
public void setRoot(Node node)
@@ -124,13 +127,14 @@
if (node == null)
{
throw new IllegalArgumentException("Root node must not be null!");
- } /* if */
+ }
root = node;
}
/**
* Fetches the specified property. Performs a recursive lookup in the
* tree with the configuration properties.
+ *
* @param key the key to be looked up
* @return the found value
*/
@@ -141,7 +145,7 @@
if (nodes.size() == 0)
{
return null;
- } /* if */
+ }
else
{
Container cont = new Container();
@@ -151,18 +155,18 @@
if (nd.getValue() != null)
{
cont.add(nd.getValue());
- } /* if */
- } /* for */
+ }
+ }
if (cont.size() < 1)
{
return null;
- } /* if */
+ }
else
{
return (cont.size() == 1) ? cont.get(0) : cont;
- } /* else */
- } /* else */
+ }
+ }
}
/**
@@ -224,6 +228,7 @@
* <p>(Note that because after the <code>table</code> element a new
* branch is created indices in following elements are not relevant; the
* branch is new so there cannot be any ambiguities.)</p>
+ *
* @param key the key of the new property
* @param obj the value of the new property
*/
@@ -244,6 +249,7 @@
* collection of nodes can be added - and thus complete configuration
* sub trees. E.g. with this method it is possible to add parts of
* another <code>HierarchicalConfiguration</code> object to this object.
+ *
* @param key the key where the nodes are to be added; can be <b>null</b>,
* then they are added to the root node
* @param nodes a collection with the <code>Node</code> objects to be
@@ -254,13 +260,13 @@
if (nodes == null || nodes.isEmpty())
{
return;
- } /* if */
+ }
Node parent;
if (StringUtils.isEmpty(key))
{
parent = getRoot();
- } /* if */
+ }
else
{
ConfigurationKey.KeyIterator kit =
@@ -273,24 +279,25 @@
new ConfigurationKey(kit.currentKey(true));
keyNew.append(NEW_KEY);
parent = fetchAddNode(keyNew.iterator(), parent);
- } /* else */
+ }
for (Iterator it = nodes.iterator(); it.hasNext();)
{
parent.addChild((Node) it.next());
- } /* for */
+ }
}
/**
* Checks if this configuration is empty. Empty means that there are
* no keys with any values, though there can be some (empty) nodes.
+ *
* @return a flag if this configuration is empty
*/
public boolean isEmpty()
{
return !nodeDefined(getRoot());
}
-
+
/**
* Creates a new <code>Configuration</code> object containing all keys
* that start with the specified prefix. This implementation will return
@@ -305,7 +312,7 @@
if (nodes.isEmpty())
{
return new HierarchicalConfiguration();
- } /* if */
+ }
HierarchicalConfiguration result = new HierarchicalConfiguration();
CloneVisitor visitor = new CloneVisitor();
@@ -321,19 +328,20 @@
for (int i = 0; i < children.size(); i++)
{
result.getRoot().addChild((Node) children.get(i));
- } /* for */
- } /* if */
- } /* for */
+ }
+ }
+ }
return (result.isEmpty()) ? new HierarchicalConfiguration() : result;
}
-
+
/**
* Checks if the specified key is contained in this configuration.
* Note that for this configuration the term "contained" means
* that the key has an associated value. If there is a node for this key
* that has no value but children (either defined or undefined), this
* method will still return <b>false</b>.
+ *
* @param key the key to be chekced
* @return a flag if this key is contained in this configuration
*/
@@ -344,6 +352,7 @@
/**
* Removes all values of the property with the given name.
+ *
* @param key the key of the property to be removed
*/
public void clearProperty(String key)
@@ -353,13 +362,14 @@
for (Iterator it = nodes.iterator(); it.hasNext();)
{
removeNode((Node) it.next());
- } /* for */
+ }
}
/**
* <p>Returns an iterator with all keys defined in this configuration.</p>
* <p>Note that the keys returned by this method will not contain
* any indices. This means that some structure will be lost.</p>
+ *
* @return an iterator with the defined keys in this configuration
*/
public Iterator getKeys()
@@ -374,6 +384,7 @@
* useful if there are multiple values for this key. They can then be
* addressed separately by specifying indices from 0 to the return value
* of this method.
+ *
* @param key the key to be checked
* @return the maximum defined index for this key
*/
@@ -385,6 +396,7 @@
/**
* Helper method for fetching a list of all nodes that are addressed by
* the specified key.
+ *
* @param key the key
* @return a list with all affected nodes (never <b>null</b>)
*/
@@ -402,6 +414,7 @@
* Recursive helper method for fetching a property. This method
* processes all facets of a configuration key, traverses the tree of
* properties and fetches the the nodes of all matching properties.
+ *
* @param keyPart the configuration key iterator
* @param node the actual node
* @param data here the found nodes are stored
@@ -414,8 +427,7 @@
if (!keyPart.hasNext())
{
data.add(node);
- } /* if */
-
+ }
else
{
String key = keyPart.nextKey(true);
@@ -429,9 +441,8 @@
(ConfigurationKey.KeyIterator) keyPart.clone(),
(Node) children.get(keyPart.getIndex()),
data);
- } /* if */
- } /* if */
-
+ }
+ }
else
{
for (Iterator it = children.iterator(); it.hasNext();)
@@ -440,13 +451,14 @@
(ConfigurationKey.KeyIterator) keyPart.clone(),
(Node) it.next(),
data);
- } /* for */
- } /* else */
+ }
+ }
}
}
/**
* Checks if the specified node is defined.
+ *
* @param node the node to be checked
* @return a flag if this node is defined
*/
@@ -461,6 +473,7 @@
* Removes the specified node from this configuration. This method
* ensures that parent nodes that become undefined by this operation
* are also removed.
+ *
* @param node the node to be removed
*/
protected void removeNode(Node node)
@@ -472,8 +485,8 @@
if (!nodeDefined(parent))
{
removeNode(parent);
- } /* if */
- } /* if */
+ }
+ }
}
/**
@@ -481,18 +494,17 @@
* Nodes for new properties can be added as children of this node.
* If the path for the specified key does not exist so far, it is created
* now.
+ *
* @param keyIt the iterator for the key of the new property
* @param startNode the node to start the search with
* @return the parent node for the add operation
*/
- protected Node fetchAddNode(
- ConfigurationKey.KeyIterator keyIt,
- Node startNode)
+ protected Node fetchAddNode(ConfigurationKey.KeyIterator keyIt, Node startNode)
{
if (!keyIt.hasNext())
{
throw new IllegalArgumentException("Key must be defined!");
- } /* if */
+ }
return createAddPath(keyIt, findLastPathNode(keyIt, startNode));
}
@@ -501,13 +513,12 @@
* Finds the last existing node for an add operation. This method
* traverses the configuration tree along the specified key. The last
* existing node on this path is returned.
+ *
* @param keyIt the key iterator
* @param node the actual node
* @return the last existing node on the given path
*/
- protected Node findLastPathNode(
- ConfigurationKey.KeyIterator keyIt,
- Node node)
+ protected Node findLastPathNode(ConfigurationKey.KeyIterator keyIt, Node node)
{
String keyPart = keyIt.nextKey(true);
@@ -518,23 +529,24 @@
if (idx < 0 || idx >= c.size())
{
return node;
- } /* if */
+ }
else
{
return findLastPathNode(keyIt, (Node) c.get(idx));
- } /* else */
- } /* if */
+ }
+ }
else
{
return node;
- } /* else */
+ }
}
/**
* Creates the missing nodes for adding a new property. This method
* ensures that there are corresponding nodes for all components of the
* specified configuration key.
+ *
* @param keyIt the key iterator
* @param root the base node of the path to be created
* @return the last node of the path
@@ -547,16 +559,16 @@
root.addChild(child);
keyIt.next();
return createAddPath(keyIt, child);
- } /* if */
+ }
else
{
return root;
- } /* else */
+ }
}
/**
- * Helper method for adding all elements of a collection to a
- * container.
+ * Helper method for adding all elements of a collection to a container.
+ *
* @param cont the container
* @param items the collection to be added
*/
@@ -565,7 +577,7 @@
for (Iterator it = items.iterator(); it.hasNext();)
{
cont.add(it.next());
- } /* for */
+ }
}
/**
@@ -597,6 +609,7 @@
/**
* Creates a new instance of <code>Node</code> and sets the name.
+ *
* @param name the node's name
*/
public Node(String name)
@@ -606,6 +619,7 @@
/**
* Returns the name of this node.
+ *
* @return the node name
*/
public String getName()
@@ -615,6 +629,7 @@
/**
* Returns the value of this node.
+ *
* @return the node value (may be <b>null</b>)
*/
public Object getValue()
@@ -624,6 +639,7 @@
/**
* Returns the parent of this node.
+ *
* @return this node's parent (can be <b>null</b>)
*/
public Node getParent()
@@ -633,6 +649,7 @@
/**
* Sets the name of this node.
+ *
* @param string the node name
*/
public void setName(String string)
@@ -642,6 +659,7 @@
/**
* Sets the value of this node.
+ *
* @param object the node value
*/
public void setValue(Object object)
@@ -651,6 +669,7 @@
/**
* Sets the parent of this node.
+ *
* @param node the parent node
*/
public void setParent(Node node)
@@ -661,6 +680,7 @@
/**
* Adds the specified child object to this node. Note that there can
* be multiple children with the same name.
+ *
* @param child the child to be added
*/
public void addChild(Node child)
@@ -668,14 +688,14 @@
if (children == null)
{
children = new LinkedMap();
- } /* if */
+ }
List c = (List) children.get(child.getName());
if (c == null)
{
c = new ArrayList();
children.put(child.getName(), c);
- } /* if */
+ }
c.add(child);
child.setParent(this);
@@ -683,6 +703,7 @@
/**
* Returns a list with the child nodes of this node.
+ *
* @return a list with the children (can be empty, but never
* <b>null</b>)
*/
@@ -695,14 +716,15 @@
for (Iterator it = children.values().iterator(); it.hasNext();)
{
addContainer(result, (Collection) it.next());
- } /* for */
- } /* if */
+ }
+ }
return result;
}
/**
* Returns a list with this node's children with the given name.
+ *
* @param name the name of the children
* @return a list with all chidren with this name; may be empty, but
* never <b>null</b>
@@ -712,20 +734,21 @@
if (name == null || children == null)
{
return getChildren();
- } /* if */
+ }
Container cont = new Container();
List c = (List) children.get(name);
if (c != null)
{
addContainer(cont, c);
- } /* if */
+ }
return cont;
}
/**
* Removes the specified child from this node.
+ *
* @param child the child node to be removed
* @return a flag if the child could be found
*/
@@ -734,13 +757,13 @@
if (children == null)
{
return false;
- } /* if */
+ }
List c = (List) children.get(child.getName());
if (c == null)
{
return false;
- } /* if */
+ }
else
{
@@ -749,18 +772,19 @@
if (c.isEmpty())
{
children.remove(child.getName());
- } /* if */
+ }
return true;
- } /* if */
+ }
else
{
return false;
- } /* else */
- } /* else */
+ }
+ }
}
/**
* Removes all children with the given name.
+ *
* @param name the name of the children to be removed
* @return a flag if children with this name existed
*/
@@ -769,7 +793,7 @@
if (children == null)
{
return false;
- } /* if */
+ }
return children.remove(name) != null;
}
@@ -786,6 +810,7 @@
* A generic method for traversing this node and all of its children.
* This method sends the passed in visitor to this node and all of its
* children.
+ *
* @param visitor the visitor
* @param key here a configuration key with the name of the root node
* of the iteration can be passed; if this key is not <b>null</b>, the
@@ -801,8 +826,8 @@
if (getName() != null)
{
key.append(getName());
- } /* if */
- } /* if */
+ }
+ }
visitor.visitBeforeChildren(this, key);
@@ -818,20 +843,21 @@
)
{
((Node) it2.next()).visit(visitor, key);
- } /* for */
- } /* for */
- } /* if */
+ }
+ }
+ }
if (key != null)
{
key.setLength(length);
- } /* if */
+ }
visitor.visitAfterChildren(this, key);
}
/**
* Creates a copy of this object. This is not a deep copy, the children
* are not cloned.
+ *
* @return a copy of this object
*/
protected Object clone()
@@ -839,11 +865,11 @@
try
{
return super.clone();
- } /* try */
+ }
catch (CloneNotSupportedException cex)
{
return null; // should not happen
- } /* catch */
+ }
}
}
@@ -863,6 +889,7 @@
/**
* Visits the specified node. This method is called during iteration
* for each node before its children have been visited.
+ *
* @param node the actual node
* @param key the key of this node (may be <b>null</b>)
*/
@@ -874,6 +901,7 @@
* Visits the specified node after its children have been processed.
* This gives a visitor the opportunity of collecting additional data
* after the child nodes have been visited.
+ *
* @param node the node to be visited
* @param key the key of this node (may be <b>null</b>)
*/
@@ -887,6 +915,7 @@
* visitors that search a specific node. If this node is found, the
* whole process can be stopped. This base implementation always
* returns <b>false</b>.
+ *
* @return a flag if iteration should be stopped
*/
public boolean terminate()
@@ -909,6 +938,7 @@
/**
* Checks if iteration should be stopped. This can be done if the first
* defined node is found.
+ *
* @return a flag if iteration should be stopped
*/
public boolean terminate()
@@ -918,6 +948,7 @@
/**
* Visits the node. Checks if a value is defined.
+ *
* @param node the actual node
* @param key the key of this node
*/
@@ -928,6 +959,7 @@
/**
* Returns the defined flag.
+ *
* @return the defined flag
*/
public boolean isDefined()
@@ -956,6 +988,7 @@
/**
* Returns the list with all defined keys.
+ *
* @return the list with the defined keys
*/
public Set getKeyList()
@@ -966,6 +999,7 @@
/**
* Visits the specified node. If this node has a value, its key is
* added to the internal list.
+ *
* @param node the node to be visited
* @param key the key of this node
*/
@@ -974,7 +1008,7 @@
if (node.getValue() != null && key != null)
{
keyList.add(key.toString());
- } /* if */
+ }
}
}
@@ -1001,6 +1035,7 @@
/**
* Visits the specified node after its children have been processed.
+ *
* @param node the node
* @param key the key of this node
*/
@@ -1010,11 +1045,12 @@
if (copyStack.isEmpty())
{
result = node;
- } /* if */
+ }
}
/**
* Visits and copies the specified node.
+ *
* @param node the node
* @param key the key of this node
*/
@@ -1026,7 +1062,7 @@
if (!copyStack.isEmpty())
{
((Node) copyStack.peek()).addChild(copy);
- } /* if */
+ }
copyStack.push(copy);
}
@@ -1034,6 +1070,7 @@
/**
* Returns the result of the clone process. This is the root node of
* the cloned node hierarchy.
+ *
* @return the cloned root node
*/
public Node getClone()
1.3 +24 -22 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfigurationConverter.java
Index: HierarchicalConfigurationConverter.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfigurationConverter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HierarchicalConfigurationConverter.java 27 Feb 2004 17:41:35 -0000 1.2
+++ HierarchicalConfigurationConverter.java 24 Jun 2004 12:35:15 -0000 1.3
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -34,8 +34,9 @@
* <code>HierarchicalConfiguration</code> root node. All in all with this class
* it is possible to treat a default configuration as if it was a hierarchical
* configuration, which can be sometimes useful.</p>
- * @see HierarchicalConfiguration
+ * @see HierarchicalConfiguration
*
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
abstract class HierarchicalConfigurationConverter
@@ -46,6 +47,7 @@
* translated into a set of element start and end events represented by
* calls to the <code>elementStart()</code> and
* <code>elementEnd()</code> methods.
+ *
* @param config the configuration to be processed
*/
public void process(Configuration config)
@@ -63,7 +65,7 @@
String elem = openElements(keyLast, keyAct);
fireValue(elem, config.getProperty(key));
keyLast = keyAct;
- } /* for */
+ }
closeElements(keyLast, keyEmpty); // close all open
}
@@ -72,7 +74,8 @@
/**
* An event handler method that is called when an element starts.
* Concrete sub classes must implement it to perform a proper event
- * handling.
+ * handling.
+ *
* @param name the name of the new element
* @param value the element's value; can be <b>null</b> if the element
* does not have any value
@@ -84,6 +87,7 @@
* call of <code>elementStart()</code> there will be a corresponding call
* of this method. Concrete sub classes must implement it to perform a
* proper event handling.
+ *
* @param name the name of the ending element
*/
protected abstract void elementEnd(String name);
@@ -94,12 +98,11 @@
* converted. It calculates the common part of the actual and the last
* processed key and thus determines how many elements must be
* closed.
+ *
* @param keyLast the last processed key
* @param keyAct the actual key
*/
- protected void closeElements(
- ConfigurationKey keyLast,
- ConfigurationKey keyAct)
+ protected void closeElements(ConfigurationKey keyLast, ConfigurationKey keyAct)
{
ConfigurationKey keyDiff = keyAct.differenceKey(keyLast);
Iterator it = reverseIterator(keyDiff);
@@ -107,18 +110,19 @@
{
// Skip first because it has already been closed by fireValue()
it.next();
- } /* if */
+ }
while (it.hasNext())
{
elementEnd((String) it.next());
- } /* while */
+ }
}
/**
* Helper method for determining a reverse iterator for the specified key.
* This implementation returns an iterator that returns the parts of the
* given key in reverse order, ignoring indices.
+ *
* @param key the key
* @return a reverse iterator for the parts of this key
*/
@@ -128,7 +132,7 @@
for (ConfigurationKey.KeyIterator it = key.iterator(); it.hasNext();)
{
list.add(it.nextKey());
- } /* for */
+ }
Collections.reverse(list);
return list.iterator();
@@ -139,21 +143,19 @@
* method is called for each key obtained from the configuration to be
* converted. It ensures that all elements "between" the last key and the
* actual key are opened.
+ *
* @param keyLast the last processed key
* @param keyAct the actual key
* @return the name of the last element on the path
*/
- protected String openElements(
- ConfigurationKey keyLast,
- ConfigurationKey keyAct)
+ protected String openElements(ConfigurationKey keyLast, ConfigurationKey keyAct)
{
- ConfigurationKey.KeyIterator it =
- keyLast.differenceKey(keyAct).iterator();
+ ConfigurationKey.KeyIterator it = keyLast.differenceKey(keyAct).iterator();
for (it.nextKey(); it.hasNext(); it.nextKey())
{
elementStart(it.currentKey(), null);
- } /* for */
+ }
return it.currentKey();
}
@@ -163,6 +165,7 @@
* This method is called for each key obtained from the configuration to be
* processed with the last part of the key as argument. The value can be
* either a single value or a collection.
+ *
* @param name the name of the actual element
* @param value the element's value
*/
@@ -173,13 +176,12 @@
for (Iterator it = ((Collection) value).iterator(); it.hasNext();)
{
fireValue(name, it.next());
- } /* for */
- } /* if */
-
+ }
+ }
else
{
elementStart(name, value);
elementEnd(name);
- } /* else */
+ }
}
}
1.4 +27 -21 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfigurationXMLReader.java
Index: HierarchicalConfigurationXMLReader.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfigurationXMLReader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HierarchicalConfigurationXMLReader.java 27 Feb 2004 17:41:35 -0000 1.3
+++ HierarchicalConfigurationXMLReader.java 24 Jun 2004 12:35:15 -0000 1.4
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -16,6 +14,8 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
+
import org.apache.commons.configuration.HierarchicalConfiguration.Node;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
@@ -32,10 +32,10 @@
* This object will be processed by the <code>parse()</code> methods. Note
* that these methods ignore their argument.</p>
*
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
-public class HierarchicalConfigurationXMLReader
-extends ConfigurationXMLReader
+public class HierarchicalConfigurationXMLReader extends ConfigurationXMLReader
{
/** Stores the configuration object to be parsed.*/
private HierarchicalConfiguration configuration;
@@ -53,10 +53,10 @@
* Creates a new instance of
* <code>HierarchicalConfigurationXMLReader</code> and sets the
* configuration to be parsed.
+ *
* @param config the configuration object
*/
- public HierarchicalConfigurationXMLReader(
- HierarchicalConfiguration config)
+ public HierarchicalConfigurationXMLReader(HierarchicalConfiguration config)
{
this();
setConfiguration(config);
@@ -64,6 +64,7 @@
/**
* Returns the configuration object to be parsed.
+ *
* @return the configuration object to be parsed
*/
public HierarchicalConfiguration getConfiguration()
@@ -73,6 +74,7 @@
/**
* Sets the configuration object to be parsed.
+ *
* @param config the configuration object to be parsed
*/
public void setConfiguration(HierarchicalConfiguration config)
@@ -82,6 +84,7 @@
/**
* Returns the configuration object to be processed.
+ *
* @return the actual configuration object
*/
public Configuration getParsedConfiguration()
@@ -90,10 +93,7 @@
}
/**
- * Processes the actual configuration object to generate SAX parsing
- * events.
- * @throws IOException if no configuration has been specified
- * @throws SAXException if an error occurs during parsing
+ * Processes the actual configuration object to generate SAX parsing events.
*/
protected void processKeys()
{
@@ -112,38 +112,41 @@
/**
* Visits the specified node after its children have been processed.
+ *
* @param node the actual node
* @param key the key of this node
*/
public void visitAfterChildren(Node node, ConfigurationKey key)
{
- if(!isAttributeNode(node))
+ if (!isAttributeNode(node))
{
fireElementEnd(nodeName(node));
- } /* if */
+ }
}
/**
* Visits the specified node.
+ *
* @param node the actual node
* @param key the key of this node
*/
public void visitBeforeChildren(Node node, ConfigurationKey key)
{
- if(!isAttributeNode(node))
+ if (!isAttributeNode(node))
{
fireElementStart(nodeName(node), fetchAttributes(node));
- if(node.getValue() != null)
+ if (node.getValue() != null)
{
fireCharacters(node.getValue().toString());
- } /* if */
- } /* if */
+ }
+ }
}
/**
* Checks if iteration should be terminated. This implementation stops
* iteration after an exception has occurred.
+ *
* @return a flag if iteration should be stopped
*/
public boolean terminate()
@@ -153,6 +156,7 @@
/**
* Returns an object with all attributes for the specified node.
+ *
* @param node the actual node
* @return an object with all attributes of this node
*/
@@ -161,17 +165,17 @@
AttributesImpl attrs = new AttributesImpl();
AbstractConfiguration.Container children = node.getChildren();
- for(int i = 0; i < children.size(); i++)
+ for (int i = 0; i < children.size(); i++)
{
Node child = (Node) children.get(i);
- if(isAttributeNode(child) && child.getValue() != null)
+ if (isAttributeNode(child) && child.getValue() != null)
{
String attr = ConfigurationKey.attributeName(
child.getName());
attrs.addAttribute(NS_URI, attr, attr, ATTR_TYPE,
child.getValue().toString());
- } /* if */
- } /* for */
+ }
+ }
return attrs;
}
@@ -180,6 +184,7 @@
* Helper method for determining the name of a node. If a node has no
* name (which is true for the root node), the specified default name
* will be used.
+ *
* @param node the node to be checked
* @return the name for this node
*/
@@ -192,6 +197,7 @@
* Checks if the specified node is an attribute node. In the node
* hierarchy attributes are stored as normal child nodes, but with
* special names.
+ *
* @param node the node to be checked
* @return a flag if this is an attribute node
*/
1.8 +5 -4 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalDOM4JConfiguration.java
Index: HierarchicalDOM4JConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalDOM4JConfiguration.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HierarchicalDOM4JConfiguration.java 23 Jun 2004 11:15:45 -0000 1.7
+++ HierarchicalDOM4JConfiguration.java 24 Jun 2004 12:35:15 -0000 1.8
@@ -29,6 +29,7 @@
/**
* <p>A specialized hierarchical configuration class that is able to parse
* XML documents using DOM4J.</p>
+ *
* <p>The parsed document will be stored keeping its structure. The
* contained properties can be accessed using all methods supported by
* the base class <code>HierarchicalProperties</code>.
@@ -151,7 +152,7 @@
if (element.getTextTrim().length() > 0)
{
node.setValue(element.getTextTrim());
- } /* if */
+ }
processAttributes(node, element);
for (Iterator it = element.elementIterator(); it.hasNext();)
@@ -160,7 +161,7 @@
Node childNode = new Node(child.getName());
constructHierarchy(childNode, child);
node.addChild(childNode);
- } /* for */
+ }
}
/**
@@ -180,6 +181,6 @@
ConfigurationKey.constructAttributeKey(attr.getName()));
child.setValue(attr.getValue());
node.addChild(child);
- } /* for */
+ }
}
}
1.4 +3 -6 jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalDOMConfiguration.java
Index: HierarchicalDOMConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalDOMConfiguration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HierarchicalDOMConfiguration.java 23 Jun 2004 11:15:45 -0000 1.3
+++ HierarchicalDOMConfiguration.java 24 Jun 2004 12:35:15 -0000 1.4
@@ -110,9 +110,7 @@
}
catch (MalformedURLException mue)
{
- throw new ConfigurationException(
- "Could not load from " + getBasePath() +
- ", " + getFileName());
+ throw new ConfigurationException("Could not load from " + getBasePath() + ", " + getFileName(), mue);
}
}
@@ -126,8 +124,7 @@
{
try
{
- DocumentBuilder builder =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
initProperties(builder.parse(url.toExternalForm()));
}
catch (Exception e)
1.15 +2 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java
Index: JNDIConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/JNDIConfiguration.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- JNDIConfiguration.java 23 Jun 2004 11:15:45 -0000 1.14
+++ JNDIConfiguration.java 24 Jun 2004 12:35:15 -0000 1.15
@@ -267,7 +267,7 @@
key = StringUtils.replace(key, ".", "/");
try
{
- // throws a NamingException if JNDI doesn't contain the key.
+ // throws a NamingException if JNDI doesn't contain the key.
getContext().lookup(key);
return true;
}
1.11 +22 -7 jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
Index: PropertiesConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PropertiesConfiguration.java 23 Jun 2004 11:15:45 -0000 1.10
+++ PropertiesConfiguration.java 24 Jun 2004 12:35:15 -0000 1.11
@@ -37,6 +37,19 @@
* resources without an absolute path, please take a look at the
* ClassPropertiesConfiguration which is intended to be used for this.
*
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
+ * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
+ * @author <a href="mailto:kjohnson@transparent.com">Kent Johnson</a>
+ * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
+ * @author <a href="mailto:ipriha@surfeu.fi">Ilkka Priha</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @author <a href="mailto:oliver.heger@t-online.de">Oliver Heger</a>
* @version $Id$
*/
public class PropertiesConfiguration extends BasePropertiesConfiguration
@@ -46,7 +59,8 @@
/**
* The name of the file to be loaded. This is used in conjuction with
- * the load method. */
+ * the load method.
+ */
protected String fileName = null;
/**
@@ -143,12 +157,11 @@
try
{
url = ConfigurationUtils.getURL(getBasePath(), resourceName);
- } /* try */
- catch(MalformedURLException uex)
+ }
+ catch (MalformedURLException uex)
{
- throw new IOException("Cannot obtain URL for resource "
- + resourceName);
- } /* catch */
+ throw new IOException("Cannot obtain URL for resource " + resourceName);
+ }
resource = url.openStream();
@@ -160,6 +173,7 @@
/**
* Returns the fileName.
+ *
* @return String
*/
public String getFileName()
@@ -169,6 +183,7 @@
/**
* Sets the fileName.
+ *
* @param fileName The fileName to set
*/
public void setFileName(String fileName)
1.3 +4 -2 jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java
Index: XMLConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLConfiguration.java 27 Feb 2004 17:41:35 -0000 1.2
+++ XMLConfiguration.java 24 Jun 2004 12:35:15 -0000 1.3
@@ -1,5 +1,3 @@
-package org.apache.commons.configuration;
-
/*
* Copyright 2004 The Apache Software Foundation.
*
@@ -16,11 +14,15 @@
* limitations under the License.
*/
+package org.apache.commons.configuration;
/**
* Base class for reading an XML configuration file.
*
* @since 0.8.1
+ *
+ * @author <a href="mailto:dlr@apache.org">Daniel Rall</a>
+ * @version $Revision$, $Date$
*/
public abstract class XMLConfiguration extends BasePathConfiguration
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org