ConfigObject
.
+ *
+ * @param path
+ * the path to the list value.
+ * @return the list at the path
+ * @throws ConfigException.Missing
+ * if value is absent or null
+ * @throws ConfigException.WrongType
+ * if value is not convertible to a list of objects
+ */
List extends ConfigObject> getObjectList(String path);
+ /**
+ * Gets a list value with Config
elements.
+ * Throws if the path is unset or null or not a list or
+ * contains values not convertible to Config
.
+ *
+ * @param path
+ * the path to the list value.
+ * @return the list at the path
+ * @throws ConfigException.Missing
+ * if value is absent or null
+ * @throws ConfigException.WrongType
+ * if value is not convertible to a list of configs
+ */
List extends Config> getConfigList(String path);
+ /**
+ * Gets a list value with any kind of elements. Throws if the
+ * path is unset or null or not a list. Each element is
+ * "unwrapped" (see {@link ConfigValue#unwrapped()}).
+ *
+ * @param path
+ * the path to the list value.
+ * @return the list at the path
+ * @throws ConfigException.Missing
+ * if value is absent or null
+ * @throws ConfigException.WrongType
+ * if value is not convertible to a list
+ */
List extends Object> getAnyRefList(String path);
+ /**
+ * Gets a list value with elements representing a size in
+ * bytes. Throws if the path is unset or null or not a list
+ * or contains values not convertible to memory sizes.
+ *
+ * @param path
+ * the path to the list value.
+ * @return the list at the path
+ * @throws ConfigException.Missing
+ * if value is absent or null
+ * @throws ConfigException.WrongType
+ * if value is not convertible to a list of memory sizes
+ */
Listklass.getClassLoader()
will be used to load
+ * resources, and non-absolute resource names will have this
+ * class's package added
+ * @param resource
+ * resource to look up, relative to klass
's package
+ * or absolute starting with a "/"
+ * @return the parsed configuration
+ */
public static Config parseResources(Class> klass, String resource) {
return parseResources(klass, resource, ConfigParseOptions.defaults());
}
@@ -805,6 +886,19 @@ public final class ConfigFactory {
options).toConfig();
}
+ /**
+ * Like {@link #parseResourcesAnySyntax(Class,String,ConfigParseOptions)}
+ * but always uses default parse options.
+ *
+ * @param klass
+ * klass.getClassLoader()
will be used to load
+ * resources, and non-absolute resource names will have this
+ * class's package added
+ * @param resourceBasename
+ * a resource name as in {@link java.lang.Class#getResource},
+ * with or without extension
+ * @return the parsed configuration
+ */
public static Config parseResourcesAnySyntax(Class> klass, String resourceBasename) {
return parseResourcesAnySyntax(klass, resourceBasename, ConfigParseOptions.defaults());
}
@@ -836,6 +930,16 @@ public final class ConfigFactory {
return parseResources(resource, options.setClassLoader(loader));
}
+ /**
+ * Like {@link #parseResources(ClassLoader,String,ConfigParseOptions)} but always uses
+ * default parse options.
+ *
+ * @param loader
+ * will be used to load resources
+ * @param resource
+ * resource to look up in the loader
+ * @return the parsed configuration
+ */
public static Config parseResources(ClassLoader loader, String resource) {
return parseResources(loader, resource, ConfigParseOptions.defaults());
}
@@ -869,6 +973,18 @@ public final class ConfigFactory {
.toConfig();
}
+ /**
+ * Like {@link #parseResourcesAnySyntax(ClassLoader,String,ConfigParseOptions)} but always uses
+ * default parse options.
+ *
+ * @param loader
+ * will be used to load resources
+ * @param resourceBasename
+ * a resource name as in
+ * {@link java.lang.ClassLoader#getResource}, with or without
+ * extension
+ * @return the parsed configuration
+ */
public static Config parseResourcesAnySyntax(ClassLoader loader, String resourceBasename) {
return parseResourcesAnySyntax(loader, resourceBasename, ConfigParseOptions.defaults());
}
@@ -877,6 +993,9 @@ public final class ConfigFactory {
* Like {@link #parseResources(ClassLoader,String,ConfigParseOptions)} but
* uses thread's current context class loader if none is set in the
* ConfigParseOptions.
+ * @param resource the resource name
+ * @param options parse options
+ * @return the parsed configuration
*/
public static Config parseResources(String resource, ConfigParseOptions options) {
ConfigParseOptions withLoader = ensureClassLoader(options, "parseResources");
@@ -886,6 +1005,8 @@ public final class ConfigFactory {
/**
* Like {@link #parseResources(ClassLoader,String)} but uses thread's
* current context class loader.
+ * @param resource the resource name
+ * @return the parsed configuration
*/
public static Config parseResources(String resource) {
return parseResources(resource, ConfigParseOptions.defaults());
@@ -895,6 +1016,9 @@ public final class ConfigFactory {
* Like
* {@link #parseResourcesAnySyntax(ClassLoader,String,ConfigParseOptions)}
* but uses thread's current context class loader.
+ * @param resourceBasename the resource basename (no file type suffix)
+ * @param options parse options
+ * @return the parsed configuration
*/
public static Config parseResourcesAnySyntax(String resourceBasename, ConfigParseOptions options) {
return ConfigImpl.parseResourcesAnySyntax(resourceBasename, options).toConfig();
@@ -903,15 +1027,31 @@ public final class ConfigFactory {
/**
* Like {@link #parseResourcesAnySyntax(ClassLoader,String)} but uses
* thread's current context class loader.
+ * @param resourceBasename the resource basename (no file type suffix)
+ * @return the parsed configuration
*/
public static Config parseResourcesAnySyntax(String resourceBasename) {
return parseResourcesAnySyntax(resourceBasename, ConfigParseOptions.defaults());
}
+ /**
+ * Parses a string (which should be valid HOCON or JSON by default, or
+ * the syntax specified in the options otherwise).
+ *
+ * @param s string to parse
+ * @param options parse options
+ * @return the parsed configuration
+ */
public static Config parseString(String s, ConfigParseOptions options) {
return Parseable.newString(s, options).parse().toConfig();
}
+ /**
+ * Parses a string (which should be valid HOCON or JSON).
+ *
+ * @param s string to parse
+ * @return the parsed configuration
+ */
public static Config parseString(String s) {
return parseString(s, ConfigParseOptions.defaults());
}
@@ -932,7 +1072,7 @@ public final class ConfigFactory {
* object of "b". The caller of this method should ensure that doesn't
* happen.
*
- * @param values
+ * @param values map from paths to plain Java objects
* @param originDescription
* description of what this map represents, like a filename, or
* "default settings" (origin description is used in error
@@ -948,7 +1088,7 @@ public final class ConfigFactory {
* See the other overload of {@link #parseMap(Map, String)} for details,
* this one just uses a default origin description.
*
- * @param values
+ * @param values map from paths to plain Java values
* @return the map converted to a {@code Config}
*/
public static Config parseMap(Map* Note that when the given comments are equal to the comments on this object, * a new instance may not be created and {@code this} is returned directly. - * + * * @param comments the comments used on the returned origin * @return the ConfigOrigin with the given comments */ @@ -97,17 +97,17 @@ public interface ConfigOrigin { /** * Returns a {@code ConfigOrigin} based on this one, but with the given - * line number. This origin must be a FILE, URL or RESOURCE. Does not modify + * line number. This origin must be a FILE, URL or RESOURCE. Does not modify * this instance or any {@code ConfigValue}s with this origin (since they are * immutable). To set the returned origin to a {@code ConfigValue}, use - * {@link ConfigValue#withOrigin}. - * + * {@link ConfigValue#withOrigin}. + * *
* Note that when the given lineNumber are equal to the lineNumber on this
* object, a new instance may not be created and {@code this} is returned
* directly.
- *
- * @param comments the comments used on the returned origin
+ *
+ * @param lineNumber the new line number
* @return the created ConfigOrigin
*/
public ConfigOrigin withLineNumber(int lineNumber);
diff --git a/config/src/main/java/com/typesafe/config/ConfigOriginFactory.java b/config/src/main/java/com/typesafe/config/ConfigOriginFactory.java
index 86004f6e..9a9a0413 100644
--- a/config/src/main/java/com/typesafe/config/ConfigOriginFactory.java
+++ b/config/src/main/java/com/typesafe/config/ConfigOriginFactory.java
@@ -15,43 +15,43 @@ import com.typesafe.config.impl.ConfigImpl;
public final class ConfigOriginFactory {
private ConfigOriginFactory() {
}
-
+
/**
* Returns the default origin for values when no other information is
* provided. This is the origin used in {@link ConfigValueFactory
* #fromAnyRef(Object)}.
- *
+ *
* @return the default origin
*/
public static ConfigOrigin newSimple() {
return newSimple(null);
}
-
+
/**
- * Returns a origin with the given description.
- *
+ * Returns an origin with the given description.
+ *
* @param description brief description of what the origin is
- * @return
+ * @return a new origin
*/
public static ConfigOrigin newSimple(String description) {
return ConfigImpl.newSimpleOrigin(description);
}
-
+
/**
* Creates a file origin with the given filename.
- *
+ *
* @param filename the filename of this origin
- * @return
+ * @return a new origin
*/
public static ConfigOrigin newFile(String filename) {
return ConfigImpl.newFileOrigin(filename);
}
-
+
/**
* Creates a url origin with the given URL object.
- *
+ *
* @param url the url of this origin
- * @return
+ * @return a new origin
*/
public static ConfigOrigin newURL(URL url) {
return ConfigImpl.newURLOrigin(url);
diff --git a/config/src/main/java/com/typesafe/config/ConfigParseOptions.java b/config/src/main/java/com/typesafe/config/ConfigParseOptions.java
index 6b793204..e1c1a770 100644
--- a/config/src/main/java/com/typesafe/config/ConfigParseOptions.java
+++ b/config/src/main/java/com/typesafe/config/ConfigParseOptions.java
@@ -36,6 +36,12 @@ public final class ConfigParseOptions {
this.classLoader = classLoader;
}
+ /**
+ * Gets an instance of ConfigParseOptions
with all fields
+ * set to the default values. Start with this instance and make any
+ * changes you need.
+ * @return the default parse options
+ */
public static ConfigParseOptions defaults() {
return new ConfigParseOptions(null, null, true, null, null);
}
@@ -56,6 +62,10 @@ public final class ConfigParseOptions {
this.includer, this.classLoader);
}
+ /**
+ * Gets the current syntax option, which may be null for "any".
+ * @return the current syntax or null
+ */
public ConfigSyntax getSyntax() {
return syntax;
}
@@ -67,7 +77,7 @@ public final class ConfigParseOptions {
* library to come up with something automatically. This description is the
* basis for the {@link ConfigOrigin} of the parsed values.
*
- * @param originDescription
+ * @param originDescription description to put in the {@link ConfigOrigin}
* @return options with the origin description set
*/
public ConfigParseOptions setOriginDescription(String originDescription) {
@@ -82,6 +92,10 @@ public final class ConfigParseOptions {
this.includer, this.classLoader);
}
+ /**
+ * Gets the current origin description, which may be null for "automatic".
+ * @return the current origin description or null
+ */
public String getOriginDescription() {
return originDescription;
}
@@ -99,7 +113,7 @@ public final class ConfigParseOptions {
* a file) is missing. Set to true to just return an empty document in that
* case.
*
- * @param allowMissing
+ * @param allowMissing true to silently ignore missing item
* @return options with the "allow missing" flag set
*/
public ConfigParseOptions setAllowMissing(boolean allowMissing) {
@@ -110,14 +124,19 @@ public final class ConfigParseOptions {
this.includer, this.classLoader);
}
+ /**
+ * Gets the current "allow missing" flag.
+ * @return whether we allow missing files
+ */
public boolean getAllowMissing() {
return allowMissing;
}
/**
- * Set a ConfigIncluder which customizes how includes are handled.
+ * Set a {@link ConfigIncluder} which customizes how includes are handled.
+ * null means to use the default includer.
*
- * @param includer
+ * @param includer the includer to use or null for default
* @return new version of the parse options with different includer
*/
public ConfigParseOptions setIncluder(ConfigIncluder includer) {
@@ -128,7 +147,18 @@ public final class ConfigParseOptions {
includer, this.classLoader);
}
+ /**
+ * Prepends a {@link ConfigIncluder} which customizes how
+ * includes are handled. To prepend your includer, the
+ * library calls {@link ConfigIncluder#withFallback} on your
+ * includer to append the existing includer to it.
+ *
+ * @param includer the includer to prepend (may not be null)
+ * @return new version of the parse options with different includer
+ */
public ConfigParseOptions prependIncluder(ConfigIncluder includer) {
+ if (includer == null)
+ throw new NullPointerException("null includer passed to prependIncluder");
if (this.includer == includer)
return this;
else if (this.includer != null)
@@ -137,7 +167,17 @@ public final class ConfigParseOptions {
return setIncluder(includer);
}
+ /**
+ * Appends a {@link ConfigIncluder} which customizes how
+ * includes are handled. To append, the library calls {@link
+ * ConfigIncluder#withFallback} on the existing includer.
+ *
+ * @param includer the includer to append (may not be null)
+ * @return new version of the parse options with different includer
+ */
public ConfigParseOptions appendIncluder(ConfigIncluder includer) {
+ if (includer == null)
+ throw new NullPointerException("null includer passed to appendIncluder");
if (this.includer == includer)
return this;
else if (this.includer != null)
@@ -146,6 +186,10 @@ public final class ConfigParseOptions {
return setIncluder(includer);
}
+ /**
+ * Gets the current includer (will be null for the default includer).
+ * @return current includer or null
+ */
public ConfigIncluder getIncluder() {
return includer;
}
diff --git a/config/src/main/java/com/typesafe/config/ConfigParseable.java b/config/src/main/java/com/typesafe/config/ConfigParseable.java
index 8c190855..b63801a8 100644
--- a/config/src/main/java/com/typesafe/config/ConfigParseable.java
+++ b/config/src/main/java/com/typesafe/config/ConfigParseable.java
@@ -24,12 +24,14 @@ public interface ConfigParseable {
* @param options
* parse options, should be based on the ones from
* {@link ConfigParseable#options options()}
+ * @return the parsed object
*/
ConfigObject parse(ConfigParseOptions options);
/**
* Returns a {@link ConfigOrigin} describing the origin of the parseable
* item.
+ * @return the origin of the parseable item
*/
ConfigOrigin origin();
@@ -37,6 +39,7 @@ public interface ConfigParseable {
* Get the initial options, which can be modified then passed to parse().
* These options will have the right description, includer, and other
* parameters already set up.
+ * @return the initial options
*/
ConfigParseOptions options();
}
diff --git a/config/src/main/java/com/typesafe/config/ConfigValue.java b/config/src/main/java/com/typesafe/config/ConfigValue.java
index 795454cd..59c0525f 100644
--- a/config/src/main/java/com/typesafe/config/ConfigValue.java
+++ b/config/src/main/java/com/typesafe/config/ConfigValue.java
@@ -40,6 +40,7 @@ public interface ConfigValue extends ConfigMergeable {
* {@code List