This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
The following commit(s) were added to refs/heads/master by this push: new 33ae6f65 Javadoc 33ae6f65 is described below commit 33ae6f65a9e5ee7c842f04c4a940725368a40248 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Feb 8 10:16:18 2025 -0500 Javadoc --- .../commons/configuration2/DataConfiguration.java | 9 +++ .../DynamicCombinedConfiguration.java | 15 ++++- .../commons/configuration2/INIConfiguration.java | 13 +++- .../configuration2/interpol/ExprLookup.java | 39 +++++++++++- .../interpol/InterpolatorSpecification.java | 3 + .../commons/configuration2/io/FileSystem.java | 71 +++++++++++++++++++++- .../spring/ConfigurationPropertySource.java | 11 ++++ 7 files changed, 154 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/configuration2/DataConfiguration.java b/src/main/java/org/apache/commons/configuration2/DataConfiguration.java index 81f258e7..9b9783db 100644 --- a/src/main/java/org/apache/commons/configuration2/DataConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/DataConfiguration.java @@ -805,6 +805,15 @@ public class DataConfiguration extends AbstractConfiguration { return getDateArray(key, EMPTY_DATE_ARRAY, format); } + /** + * Gets a list of Dates associated with the given configuration key. If the property is a list of Strings, they will be + * parsed with the format defined by the user in the {@link #DATE_FORMAT_KEY} property, or if it's not defined with the + * {@link #DEFAULT_DATE_FORMAT} pattern. If the key doesn't map to an existing object, a new list is returned. + * + * @param key The configuration key. + * @return The associated Date list if the key is found. If the key doesn't map to an existing object, a new list is returned. + * @throws ConversionException is thrown if the key maps to an object that is not a list of Dates. + */ public List<Date> getDateList(final String key) { return getDateList(key, new ArrayList<>()); } diff --git a/src/main/java/org/apache/commons/configuration2/DynamicCombinedConfiguration.java b/src/main/java/org/apache/commons/configuration2/DynamicCombinedConfiguration.java index 25715e2d..dacb8a2b 100644 --- a/src/main/java/org/apache/commons/configuration2/DynamicCombinedConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/DynamicCombinedConfiguration.java @@ -197,7 +197,7 @@ public class DynamicCombinedConfiguration extends CombinedConfiguration { /** Stores a map with the named configurations. */ private final Map<String, Configuration> namedConfigurations = new HashMap<>(); - /** The key pattern for the CombinedConfiguration map */ + /** The key pattern for the CombinedConfiguration map. */ private String keyPattern; /** Stores the combiner. */ @@ -582,6 +582,11 @@ public class DynamicCombinedConfiguration extends CombinedConfiguration { return getCurrentConfig().getInteger(key, defaultValue); } + /** + * Gets the key pattern for the CombinedConfiguration map. + * + * @return the key pattern for the CombinedConfiguration map. + */ public String getKeyPattern() { return this.keyPattern; } @@ -767,6 +772,9 @@ public class DynamicCombinedConfiguration extends CombinedConfiguration { getCurrentConfig().invalidate(); } + /** + * Invalidates all CombinedConfigurations. + */ public void invalidateAll() { configs.values().forEach(CombinedConfiguration::invalidate); } @@ -852,6 +860,11 @@ public class DynamicCombinedConfiguration extends CombinedConfiguration { return super.removeEventListener(eventType, listener); } + /** + * Sets the key pattern for the CombinedConfiguration map. + * + * @param pattern the key pattern for the CombinedConfiguration map. + */ public void setKeyPattern(final String pattern) { this.keyPattern = pattern; } diff --git a/src/main/java/org/apache/commons/configuration2/INIConfiguration.java b/src/main/java/org/apache/commons/configuration2/INIConfiguration.java index f8a9b713..54f7b66c 100644 --- a/src/main/java/org/apache/commons/configuration2/INIConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/INIConfiguration.java @@ -211,14 +211,25 @@ public class INIConfiguration extends BaseHierarchicalConfiguration implements F public static class Builder { /** - * The flag for decision, whether inline comments on the section line are allowed. + * Whether in-line comments on the section line are allowed. */ private boolean sectionInLineCommentsAllowed; + /** + * Builds a new INIConfiguration. + * + * @return a new INIConfiguration. + */ public INIConfiguration build() { return new INIConfiguration(sectionInLineCommentsAllowed); } + /** + * Sets whether in-line comments on the section line are allowed. + * + * @param sectionInLineCommentsAllowed Whether in-line comments on the section line are allowed. + * @return this instance. + */ public Builder setSectionInLineCommentsAllowed(final boolean sectionInLineCommentsAllowed) { this.sectionInLineCommentsAllowed = sectionInLineCommentsAllowed; return this; diff --git a/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java b/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java index 1ad23515..3324d064 100644 --- a/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java +++ b/src/main/java/org/apache/commons/configuration2/interpol/ExprLookup.java @@ -67,32 +67,62 @@ public class ExprLookup implements Lookup { * The key and corresponding object that will be made available to the JexlContext for use in expressions. */ public static class Variable { - /** The name to be used in expressions */ + /** The name to be used in expressions. */ private String key; - /** The object to be accessed in expressions */ + /** The object to be accessed in expressions. */ private Object value; + /** + * Constructs a new instance. + */ public Variable() { } + /** + * Constructs a new instance. + * + * @param name The name to be used in expressions. + * @param value The object to be accessed in expressions. + */ public Variable(final String name, final Object value) { setName(name); setValue(value); } + /** + * Gets the name to be used in expressions. + * + * @return the name to be used in expressions. + */ public String getName() { return key; } + /** + * Sets the value to be used in expressions. + * + * @return the value to be used in expressions. + */ public Object getValue() { return value; } + /** + * Sets the name to be used in expressions. + * + * @param name the name to be used in expressions. + */ public void setName(final String name) { this.key = name; } + /** + * Sets the value to be used in expressions. + * + * @param value The object to be accessed in expressions. + * @throws ConfigurationRuntimeException Wraps an exception creating the value. + */ public void setValue(final Object value) throws ConfigurationRuntimeException { try { if (!(value instanceof String)) { @@ -138,6 +168,11 @@ public class ExprLookup implements Lookup { super(vars); } + /** + * Gets the variable or null if empty. + * + * @return the variable or null if empty. + */ public Variable getVariable() { return !isEmpty() ? get(size() - 1) : null; } diff --git a/src/main/java/org/apache/commons/configuration2/interpol/InterpolatorSpecification.java b/src/main/java/org/apache/commons/configuration2/interpol/InterpolatorSpecification.java index 497e90cc..edce9e81 100644 --- a/src/main/java/org/apache/commons/configuration2/interpol/InterpolatorSpecification.java +++ b/src/main/java/org/apache/commons/configuration2/interpol/InterpolatorSpecification.java @@ -89,6 +89,9 @@ public final class InterpolatorSpecification { /** Function used to convert interpolated values to strings. */ private Function<Object, String> stringConverter; + /** + * Constructs a new instance. + */ public Builder() { prefixLookups = new HashMap<>(); defLookups = new LinkedList<>(); diff --git a/src/main/java/org/apache/commons/configuration2/io/FileSystem.java b/src/main/java/org/apache/commons/configuration2/io/FileSystem.java index 4db8450f..5c454748 100644 --- a/src/main/java/org/apache/commons/configuration2/io/FileSystem.java +++ b/src/main/java/org/apache/commons/configuration2/io/FileSystem.java @@ -33,20 +33,44 @@ public abstract class FileSystem { /** Constant for the default logger. */ private static final ConfigurationLogger DEFAULT_LOG = ConfigurationLogger.newDummyLogger(); - /** The Logger */ + /** The Logger. */ private volatile ConfigurationLogger log; - /** FileSystem options provider */ + /** FileSystem options provider. */ private volatile FileOptionsProvider optionsProvider; + /** + * Gets the base path of the given path, for example a directory for a file. + * + * @param path the source path. + * @return the base path. + */ public abstract String getBasePath(String path); + /** + * Gets the file name of the given path. + * + * @param path the source path. + * @return the file name. + */ public abstract String getFileName(String path); + /** + * Gets the FileSystem options provider. + * + * @return the FileSystem options provider. + */ public FileOptionsProvider getFileOptionsProvider() { return this.optionsProvider; } + /** + * Gets an input stream for a URL. + * + * @param url the source URL. + * @return an input stream. + * @throws ConfigurationException if an problem occurs getting the input stream. + */ public abstract InputStream getInputStream(URL url) throws ConfigurationException; /** @@ -72,14 +96,55 @@ public abstract class FileSystem { return result != null ? result : DEFAULT_LOG; } + /** + * Gets an output stream for a File. + * + * @param file the source File. + * @return an output stream. + * @throws ConfigurationException if an problem occurs getting the output stream. + */ public abstract OutputStream getOutputStream(File file) throws ConfigurationException; + /** + * Gets an output stream for a URL. + * + * @param url the source URL. + * @return an output stream. + * @throws ConfigurationException if an problem occurs getting the output stream. + */ public abstract OutputStream getOutputStream(URL url) throws ConfigurationException; + /** + * Gets a path string for the given input where some values may be null. + * <p> + * The implementation decides on which argument take precedence. + * </p> + * + * @param file A file. + * @param url A URL. + * @param basePath A base path string. + * @param fileName A file name. + * @return A path string. + */ public abstract String getPath(File file, URL url, String basePath, String fileName); + /** + * Gets a URL for a base path and file name. + * + * @param basePath The base path. + * @param fileName The file name. + * @return a URL. + * @throws MalformedURLException if a problem occurs creating the URL. + */ public abstract URL getURL(String basePath, String fileName) throws MalformedURLException; + /** + * Locates a URL for a base path and file name. + * + * @param basePath The base path. + * @param fileName The file name. + * @return a URL. + */ public abstract URL locateFromURL(String basePath, String fileName); /** @@ -92,7 +157,7 @@ public abstract class FileSystem { } /** - * Allows setting the logger to be used by this FileSystem. This method makes it possible for clients to exactly control + * Sets the logger to be used by this FileSystem. This method makes it possible for clients to exactly control * logging behavior. Per default a logger is set that will ignore all log messages. Derived classes that want to enable * logging should call this method during their initialization with the logger to be used. Passing in a <strong>null</strong> * argument disables logging. diff --git a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java index 8035b1f0..e5ee819a 100644 --- a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java +++ b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java @@ -29,10 +29,21 @@ import org.springframework.core.env.EnumerablePropertySource; */ public class ConfigurationPropertySource extends EnumerablePropertySource<Configuration> { + /** + * Constructs a new instance. + * + * @param name the associated name. + */ protected ConfigurationPropertySource(final String name) { super(name); } + /** + * Constructs a new instance. + * + * @param name the associated name. + * @param source the source object. + */ public ConfigurationPropertySource(final String name, final Configuration source) { super(name, source); }