mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
commit
4b2fc5c6cb
@ -18,7 +18,7 @@ jdk:
|
|||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- sbt ++$TRAVIS_SCALA_VERSION test
|
- sbt ++$TRAVIS_SCALA_VERSION test doc
|
||||||
|
|
||||||
# Remove to avoid unnecessary cache updates
|
# Remove to avoid unnecessary cache updates
|
||||||
- find $HOME/.sbt -name "*.lock" -delete
|
- find $HOME/.sbt -name "*.lock" -delete
|
||||||
|
@ -7,7 +7,7 @@ import com.typesafe.sbt.SbtPgp.PgpKeys.{ useGpg, publishSigned, publishLocalSign
|
|||||||
// Release tags should follow: http://semver.org/
|
// Release tags should follow: http://semver.org/
|
||||||
|
|
||||||
SbtGit.versionWithGit
|
SbtGit.versionWithGit
|
||||||
SbtGit.git.baseVersion := "1.1.0"
|
SbtGit.git.baseVersion := "1.3.0"
|
||||||
|
|
||||||
organization in GlobalScope := "com.typesafe"
|
organization in GlobalScope := "com.typesafe"
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import de.johoop.jacoco4sbt.JacocoPlugin.jacoco
|
|||||||
import com.typesafe.sbt.SbtScalariform
|
import com.typesafe.sbt.SbtScalariform
|
||||||
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
|
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
|
||||||
import scalariform.formatter.preferences._
|
import scalariform.formatter.preferences._
|
||||||
|
import com.etsy.sbt.Checkstyle._
|
||||||
|
|
||||||
SbtScalariform.scalariformSettings
|
SbtScalariform.scalariformSettings
|
||||||
|
|
||||||
@ -25,6 +26,46 @@ libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
|
|||||||
|
|
||||||
externalResolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"
|
externalResolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"
|
||||||
|
|
||||||
|
checkstyleSettings
|
||||||
|
|
||||||
|
CheckstyleTasks.checkstyleConfig := baseDirectory.value / "checkstyle-config.xml"
|
||||||
|
|
||||||
|
CheckstyleTasks.checkstyle in Compile := {
|
||||||
|
val log = streams.value.log
|
||||||
|
(CheckstyleTasks.checkstyle in Compile).value
|
||||||
|
val resultFile = (target in Compile).value / "checkstyle-report.xml"
|
||||||
|
val results = scala.xml.XML.loadFile(resultFile)
|
||||||
|
val errorFiles = results \\ "checkstyle" \\ "file"
|
||||||
|
|
||||||
|
def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = {
|
||||||
|
val line: String = (node \ "@line" text)
|
||||||
|
val msg: String = (node \ "@message" text)
|
||||||
|
val source: String = (node \ "@source" text)
|
||||||
|
(line, msg, source)
|
||||||
|
}
|
||||||
|
def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = {
|
||||||
|
val name: String = (fileNode \ "@name" text)
|
||||||
|
val errors = (fileNode \\ "error") map { e => errorFromXml(e) }
|
||||||
|
errors map { case (line, error, source) => (name, line, error, source) }
|
||||||
|
}
|
||||||
|
|
||||||
|
val errors = errorFiles flatMap { f => errorsFromXml(f) }
|
||||||
|
|
||||||
|
if (errors.nonEmpty) {
|
||||||
|
for (e <- errors) {
|
||||||
|
log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})")
|
||||||
|
}
|
||||||
|
throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors")
|
||||||
|
}
|
||||||
|
log.info("No errors from checkstyle")
|
||||||
|
}
|
||||||
|
|
||||||
|
// add checkstyle as a dependency of doc
|
||||||
|
doc in Compile := {
|
||||||
|
(CheckstyleTasks.checkstyle in Compile).value
|
||||||
|
(doc in Compile).value
|
||||||
|
}
|
||||||
|
|
||||||
findbugsSettings
|
findbugsSettings
|
||||||
findbugsReportType := Some(ReportType.Html)
|
findbugsReportType := Some(ReportType.Html)
|
||||||
findbugsReportName := Some("findbugs.html")
|
findbugsReportName := Some("findbugs.html")
|
||||||
@ -39,6 +80,12 @@ javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.8", "
|
|||||||
// we have to run tests in serial.
|
// we have to run tests in serial.
|
||||||
parallelExecution in Test := false
|
parallelExecution in Test := false
|
||||||
|
|
||||||
sources in (Compile, doc) ~= (_.filter(_.getParentFile.getName != "impl"))
|
javacOptions in (Compile, doc) ++= Seq("-group", s"Public API (version ${version.value})", "com.typesafe.config",
|
||||||
|
"-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl")
|
||||||
|
|
||||||
|
javadocSourceBaseUrl := {
|
||||||
|
for (gitHead <- com.typesafe.sbt.SbtGit.GitKeys.gitHeadCommit.value)
|
||||||
|
yield s"https://github.com/typesafehub/config/blob/$gitHead/config/src/main/java"
|
||||||
|
}
|
||||||
|
|
||||||
javaVersionPrefix in javaVersionCheck := Some("1.8")
|
javaVersionPrefix in javaVersionCheck := Some("1.8")
|
||||||
|
21
config/checkstyle-config.xml
Normal file
21
config/checkstyle-config.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="config/checkstyle-suppressions.xml"/>
|
||||||
|
</module>
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="JavadocType">
|
||||||
|
<property name="scope" value="public"/>
|
||||||
|
</module>
|
||||||
|
<module name="JavadocMethod">
|
||||||
|
<property name="scope" value="public"/>
|
||||||
|
</module>
|
||||||
|
<module name="JavadocStyle">
|
||||||
|
<property name="scope" value="public"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
||||||
|
</module>
|
13
config/checkstyle-suppressions.xml
Normal file
13
config/checkstyle-suppressions.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||||
|
<suppressions>
|
||||||
|
<!-- don't care about javadoc coverage of methods in impl -->
|
||||||
|
<suppress checks="JavadocMethod"
|
||||||
|
files="com[\\/]typesafe[\\/]config[\\/]impl[\\/]"/>
|
||||||
|
<!-- ConfigException has a bunch of constructors that are
|
||||||
|
self-evident and would clutter the heck out of the file
|
||||||
|
to document -->
|
||||||
|
<suppress checks="JavadocMethod"
|
||||||
|
files="com[\\/]typesafe[\\/]config[\\/]ConfigException.java"/>
|
||||||
|
</suppressions>
|
@ -723,24 +723,154 @@ public interface Config extends ConfigMergeable {
|
|||||||
*/
|
*/
|
||||||
ConfigList getList(String path);
|
ConfigList getList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with boolean elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to boolean.
|
||||||
|
*
|
||||||
|
* @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 booleans
|
||||||
|
*/
|
||||||
List<Boolean> getBooleanList(String path);
|
List<Boolean> getBooleanList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with number elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to number.
|
||||||
|
*
|
||||||
|
* @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 numbers
|
||||||
|
*/
|
||||||
List<Number> getNumberList(String path);
|
List<Number> getNumberList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with int elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to int.
|
||||||
|
*
|
||||||
|
* @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 ints
|
||||||
|
*/
|
||||||
List<Integer> getIntList(String path);
|
List<Integer> getIntList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with long elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to long.
|
||||||
|
*
|
||||||
|
* @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 longs
|
||||||
|
*/
|
||||||
List<Long> getLongList(String path);
|
List<Long> getLongList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with double elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to double.
|
||||||
|
*
|
||||||
|
* @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 doubles
|
||||||
|
*/
|
||||||
List<Double> getDoubleList(String path);
|
List<Double> getDoubleList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with string elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to string.
|
||||||
|
*
|
||||||
|
* @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 strings
|
||||||
|
*/
|
||||||
List<String> getStringList(String path);
|
List<String> getStringList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with object elements. Throws if the
|
||||||
|
* path is unset or null or not a list or contains values not
|
||||||
|
* convertible to <code>ConfigObject</code>.
|
||||||
|
*
|
||||||
|
* @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);
|
List<? extends ConfigObject> getObjectList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list value with <code>Config</code> elements.
|
||||||
|
* Throws if the path is unset or null or not a list or
|
||||||
|
* contains values not convertible to <code>Config</code>.
|
||||||
|
*
|
||||||
|
* @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);
|
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);
|
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
|
||||||
|
*/
|
||||||
List<Long> getBytesList(String path);
|
List<Long> getBytesList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -751,23 +881,31 @@ public interface Config extends ConfigMergeable {
|
|||||||
* @param path
|
* @param path
|
||||||
* a path expression
|
* a path expression
|
||||||
* @return list of memory sizes
|
* @return list of memory sizes
|
||||||
|
* @throws ConfigException.Missing
|
||||||
|
* if value is absent or null
|
||||||
|
* @throws ConfigException.WrongType
|
||||||
|
* if value is not convertible to a list of memory sizes
|
||||||
*/
|
*/
|
||||||
List<ConfigMemorySize> getMemorySizeList(String path);
|
List<ConfigMemorySize> getMemorySizeList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
|
* @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
|
||||||
|
* @param path the path
|
||||||
|
* @return list of millisecond values
|
||||||
*/
|
*/
|
||||||
@Deprecated List<Long> getMillisecondsList(String path);
|
@Deprecated List<Long> getMillisecondsList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
|
* @deprecated As of release 1.1, replaced by {@link #getDurationList(String, TimeUnit)}
|
||||||
|
* @param path the path
|
||||||
|
* @return list of nanosecond values
|
||||||
*/
|
*/
|
||||||
@Deprecated List<Long> getNanosecondsList(String path);
|
@Deprecated List<Long> getNanosecondsList(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list, converting each value in the list to a duration, using the
|
* Gets a list, converting each value in the list to a duration, using the
|
||||||
* same rules as {@link #getDuration(String, TimeUnit)}.
|
* same rules as {@link #getDuration(String, TimeUnit)}.
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @param path
|
* @param path
|
||||||
* a path expression
|
* a path expression
|
||||||
|
@ -322,7 +322,10 @@ public abstract class ConfigException extends RuntimeException implements Serial
|
|||||||
this.problem = problem;
|
this.problem = problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the config setting causing the problem. */
|
/**
|
||||||
|
* Returns the config setting causing the problem.
|
||||||
|
* @return the path of the problem setting
|
||||||
|
*/
|
||||||
public String path() {
|
public String path() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@ -330,12 +333,16 @@ public abstract class ConfigException extends RuntimeException implements Serial
|
|||||||
/**
|
/**
|
||||||
* Returns where the problem occurred (origin may include info on the
|
* Returns where the problem occurred (origin may include info on the
|
||||||
* file, line number, etc.).
|
* file, line number, etc.).
|
||||||
|
* @return the origin of the problem setting
|
||||||
*/
|
*/
|
||||||
public ConfigOrigin origin() {
|
public ConfigOrigin origin() {
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a description of the problem. */
|
/**
|
||||||
|
* Returns a description of the problem.
|
||||||
|
* @return description of the problem
|
||||||
|
*/
|
||||||
public String problem() {
|
public String problem() {
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ public final class ConfigFactory {
|
|||||||
* {@link #defaultReference(ClassLoader)} and to load only the overrides use
|
* {@link #defaultReference(ClassLoader)} and to load only the overrides use
|
||||||
* {@link #defaultOverrides(ClassLoader)}.
|
* {@link #defaultOverrides(ClassLoader)}.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader class loader to look for resources in
|
||||||
* @param resourceBasename
|
* @param resourceBasename basename (no .conf/.json/.properties suffix)
|
||||||
* @return configuration for an application relative to given class loader
|
* @return configuration for an application relative to given class loader
|
||||||
*/
|
*/
|
||||||
public static Config load(ClassLoader loader, String resourceBasename) {
|
public static Config load(ClassLoader loader, String resourceBasename) {
|
||||||
@ -167,6 +167,16 @@ public final class ConfigFactory {
|
|||||||
return load(checkedContextClassLoader("load"), config);
|
return load(checkedContextClassLoader("load"), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link #load(Config)} but allows you to specify
|
||||||
|
* the class loader for looking up resources.
|
||||||
|
*
|
||||||
|
* @param loader
|
||||||
|
* the class loader to use to find resources
|
||||||
|
* @param config
|
||||||
|
* the application's portion of the configuration
|
||||||
|
* @return resolved configuration with overrides and fallbacks added
|
||||||
|
*/
|
||||||
public static Config load(ClassLoader loader, Config config) {
|
public static Config load(ClassLoader loader, Config config) {
|
||||||
return load(loader, config, ConfigResolveOptions.defaults());
|
return load(loader, config, ConfigResolveOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -269,7 +279,7 @@ public final class ConfigFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #load()} but allows specifying parse options
|
* Like {@link #load()} but allows specifying parse options.
|
||||||
*
|
*
|
||||||
* @param parseOptions
|
* @param parseOptions
|
||||||
* Options for parsing resources
|
* Options for parsing resources
|
||||||
@ -299,7 +309,7 @@ public final class ConfigFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #load()} but allows specifying a class loader other than the
|
* Like {@link #load()} but allows specifying a class loader other than the
|
||||||
* thread's current context class loader, and parse options
|
* thread's current context class loader and also specify parse options.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader
|
||||||
* class loader for finding resources (overrides any loader in parseOptions)
|
* class loader for finding resources (overrides any loader in parseOptions)
|
||||||
@ -313,7 +323,7 @@ public final class ConfigFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #load()} but allows specifying a class loader other than the
|
* Like {@link #load()} but allows specifying a class loader other than the
|
||||||
* thread's current context class loader, and resolve options
|
* thread's current context class loader and also specify resolve options.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader
|
||||||
* class loader for finding resources
|
* class loader for finding resources
|
||||||
@ -328,7 +338,7 @@ public final class ConfigFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #load()} but allows specifying a class loader other than the
|
* Like {@link #load()} but allows specifying a class loader other than the
|
||||||
* thread's current context class loader, parse options, and resolve options
|
* thread's current context class loader, parse options, and resolve options.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader
|
||||||
* class loader for finding resources (overrides any loader in parseOptions)
|
* class loader for finding resources (overrides any loader in parseOptions)
|
||||||
@ -396,7 +406,7 @@ public final class ConfigFactory {
|
|||||||
* Like {@link #defaultReference()} but allows you to specify a class loader
|
* Like {@link #defaultReference()} but allows you to specify a class loader
|
||||||
* to use rather than the current context class loader.
|
* to use rather than the current context class loader.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader class loader to look for resources in
|
||||||
* @return the default reference config for this class loader
|
* @return the default reference config for this class loader
|
||||||
*/
|
*/
|
||||||
public static Config defaultReference(ClassLoader loader) {
|
public static Config defaultReference(ClassLoader loader) {
|
||||||
@ -426,7 +436,7 @@ public final class ConfigFactory {
|
|||||||
* Like {@link #defaultOverrides()} but allows you to specify a class loader
|
* Like {@link #defaultOverrides()} but allows you to specify a class loader
|
||||||
* to use rather than the current context class loader.
|
* to use rather than the current context class loader.
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader class loader to look for resources in
|
||||||
* @return the default override configuration
|
* @return the default override configuration
|
||||||
*/
|
*/
|
||||||
public static Config defaultOverrides(ClassLoader loader) {
|
public static Config defaultOverrides(ClassLoader loader) {
|
||||||
@ -490,7 +500,7 @@ public final class ConfigFactory {
|
|||||||
*
|
*
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*
|
*
|
||||||
* @param loader
|
* @param loader class loader to look for resources in
|
||||||
* @return the default application configuration
|
* @return the default application configuration
|
||||||
*/
|
*/
|
||||||
public static Config defaultApplication(ClassLoader loader) {
|
public static Config defaultApplication(ClassLoader loader) {
|
||||||
@ -502,7 +512,7 @@ public final class ConfigFactory {
|
|||||||
*
|
*
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*
|
*
|
||||||
* @param parseOptions the options
|
* @param options the options
|
||||||
* @return the default application configuration
|
* @return the default application configuration
|
||||||
*/
|
*/
|
||||||
public static Config defaultApplication(ConfigParseOptions options) {
|
public static Config defaultApplication(ConfigParseOptions options) {
|
||||||
@ -620,6 +630,7 @@ public final class ConfigFactory {
|
|||||||
* @param properties
|
* @param properties
|
||||||
* a Java Properties object
|
* a Java Properties object
|
||||||
* @param options
|
* @param options
|
||||||
|
* the parse options
|
||||||
* @return the parsed configuration
|
* @return the parsed configuration
|
||||||
*/
|
*/
|
||||||
public static Config parseProperties(Properties properties,
|
public static Config parseProperties(Properties properties,
|
||||||
@ -627,22 +638,79 @@ public final class ConfigFactory {
|
|||||||
return Parseable.newProperties(properties, options).parse().toConfig();
|
return Parseable.newProperties(properties, options).parse().toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link parseProperties(Properties, ConfigParseOptions)} but uses default
|
||||||
|
* parse options.
|
||||||
|
* @param properties
|
||||||
|
* a Java Properties object
|
||||||
|
* @return the parsed configuration
|
||||||
|
*/
|
||||||
public static Config parseProperties(Properties properties) {
|
public static Config parseProperties(Properties properties) {
|
||||||
return parseProperties(properties, ConfigParseOptions.defaults());
|
return parseProperties(properties, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a Reader into a Config instance. Does not call
|
||||||
|
* {@link Config#resolve} or merge the parsed stream with any
|
||||||
|
* other configuration; this method parses a single stream and
|
||||||
|
* does nothing else. It does process "include" statements in
|
||||||
|
* the parsed stream, and may end up doing other IO due to those
|
||||||
|
* statements.
|
||||||
|
*
|
||||||
|
* @param reader
|
||||||
|
* the reader to parse
|
||||||
|
* @param options
|
||||||
|
* parse options to control how the reader is interpreted
|
||||||
|
* @return the parsed configuration
|
||||||
|
* @throws ConfigException on IO or parse errors
|
||||||
|
*/
|
||||||
public static Config parseReader(Reader reader, ConfigParseOptions options) {
|
public static Config parseReader(Reader reader, ConfigParseOptions options) {
|
||||||
return Parseable.newReader(reader, options).parse().toConfig();
|
return Parseable.newReader(reader, options).parse().toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a reader into a Config instance as with
|
||||||
|
* {@link #parseReader(Reader,ConfigParseOptions)} but always uses the
|
||||||
|
* default parse options.
|
||||||
|
*
|
||||||
|
* @param reader
|
||||||
|
* the reader to parse
|
||||||
|
* @return the parsed configuration
|
||||||
|
* @throws ConfigException on IO or parse errors
|
||||||
|
*/
|
||||||
public static Config parseReader(Reader reader) {
|
public static Config parseReader(Reader reader) {
|
||||||
return parseReader(reader, ConfigParseOptions.defaults());
|
return parseReader(reader, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a URL into a Config instance. Does not call
|
||||||
|
* {@link Config#resolve} or merge the parsed stream with any
|
||||||
|
* other configuration; this method parses a single stream and
|
||||||
|
* does nothing else. It does process "include" statements in
|
||||||
|
* the parsed stream, and may end up doing other IO due to those
|
||||||
|
* statements.
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* the url to parse
|
||||||
|
* @param options
|
||||||
|
* parse options to control how the url is interpreted
|
||||||
|
* @return the parsed configuration
|
||||||
|
* @throws ConfigException on IO or parse errors
|
||||||
|
*/
|
||||||
public static Config parseURL(URL url, ConfigParseOptions options) {
|
public static Config parseURL(URL url, ConfigParseOptions options) {
|
||||||
return Parseable.newURL(url, options).parse().toConfig();
|
return Parseable.newURL(url, options).parse().toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a url into a Config instance as with
|
||||||
|
* {@link #parseURL(URL,ConfigParseOptions)} but always uses the
|
||||||
|
* default parse options.
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* the url to parse
|
||||||
|
* @return the parsed configuration
|
||||||
|
* @throws ConfigException on IO or parse errors
|
||||||
|
*/
|
||||||
public static Config parseURL(URL url) {
|
public static Config parseURL(URL url) {
|
||||||
return parseURL(url, ConfigParseOptions.defaults());
|
return parseURL(url, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -765,6 +833,19 @@ public final class ConfigFactory {
|
|||||||
.toConfig();
|
.toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link #parseResources(Class,String,ConfigParseOptions)} but always uses
|
||||||
|
* default parse options.
|
||||||
|
*
|
||||||
|
* @param klass
|
||||||
|
* <code>klass.getClassLoader()</code> 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 <code>klass</code>'s package
|
||||||
|
* or absolute starting with a "/"
|
||||||
|
* @return the parsed configuration
|
||||||
|
*/
|
||||||
public static Config parseResources(Class<?> klass, String resource) {
|
public static Config parseResources(Class<?> klass, String resource) {
|
||||||
return parseResources(klass, resource, ConfigParseOptions.defaults());
|
return parseResources(klass, resource, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -805,6 +886,19 @@ public final class ConfigFactory {
|
|||||||
options).toConfig();
|
options).toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link #parseResourcesAnySyntax(Class,String,ConfigParseOptions)}
|
||||||
|
* but always uses default parse options.
|
||||||
|
*
|
||||||
|
* @param klass
|
||||||
|
* <code>klass.getClassLoader()</code> 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) {
|
public static Config parseResourcesAnySyntax(Class<?> klass, String resourceBasename) {
|
||||||
return parseResourcesAnySyntax(klass, resourceBasename, ConfigParseOptions.defaults());
|
return parseResourcesAnySyntax(klass, resourceBasename, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -836,6 +930,16 @@ public final class ConfigFactory {
|
|||||||
return parseResources(resource, options.setClassLoader(loader));
|
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) {
|
public static Config parseResources(ClassLoader loader, String resource) {
|
||||||
return parseResources(loader, resource, ConfigParseOptions.defaults());
|
return parseResources(loader, resource, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -869,6 +973,18 @@ public final class ConfigFactory {
|
|||||||
.toConfig();
|
.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) {
|
public static Config parseResourcesAnySyntax(ClassLoader loader, String resourceBasename) {
|
||||||
return parseResourcesAnySyntax(loader, resourceBasename, ConfigParseOptions.defaults());
|
return parseResourcesAnySyntax(loader, resourceBasename, ConfigParseOptions.defaults());
|
||||||
}
|
}
|
||||||
@ -877,6 +993,9 @@ public final class ConfigFactory {
|
|||||||
* Like {@link #parseResources(ClassLoader,String,ConfigParseOptions)} but
|
* Like {@link #parseResources(ClassLoader,String,ConfigParseOptions)} but
|
||||||
* uses thread's current context class loader if none is set in the
|
* uses thread's current context class loader if none is set in the
|
||||||
* ConfigParseOptions.
|
* ConfigParseOptions.
|
||||||
|
* @param resource the resource name
|
||||||
|
* @param options parse options
|
||||||
|
* @return the parsed configuration
|
||||||
*/
|
*/
|
||||||
public static Config parseResources(String resource, ConfigParseOptions options) {
|
public static Config parseResources(String resource, ConfigParseOptions options) {
|
||||||
ConfigParseOptions withLoader = ensureClassLoader(options, "parseResources");
|
ConfigParseOptions withLoader = ensureClassLoader(options, "parseResources");
|
||||||
@ -886,6 +1005,8 @@ public final class ConfigFactory {
|
|||||||
/**
|
/**
|
||||||
* Like {@link #parseResources(ClassLoader,String)} but uses thread's
|
* Like {@link #parseResources(ClassLoader,String)} but uses thread's
|
||||||
* current context class loader.
|
* current context class loader.
|
||||||
|
* @param resource the resource name
|
||||||
|
* @return the parsed configuration
|
||||||
*/
|
*/
|
||||||
public static Config parseResources(String resource) {
|
public static Config parseResources(String resource) {
|
||||||
return parseResources(resource, ConfigParseOptions.defaults());
|
return parseResources(resource, ConfigParseOptions.defaults());
|
||||||
@ -895,6 +1016,9 @@ public final class ConfigFactory {
|
|||||||
* Like
|
* Like
|
||||||
* {@link #parseResourcesAnySyntax(ClassLoader,String,ConfigParseOptions)}
|
* {@link #parseResourcesAnySyntax(ClassLoader,String,ConfigParseOptions)}
|
||||||
* but uses thread's current context class loader.
|
* 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) {
|
public static Config parseResourcesAnySyntax(String resourceBasename, ConfigParseOptions options) {
|
||||||
return ConfigImpl.parseResourcesAnySyntax(resourceBasename, options).toConfig();
|
return ConfigImpl.parseResourcesAnySyntax(resourceBasename, options).toConfig();
|
||||||
@ -903,15 +1027,31 @@ public final class ConfigFactory {
|
|||||||
/**
|
/**
|
||||||
* Like {@link #parseResourcesAnySyntax(ClassLoader,String)} but uses
|
* Like {@link #parseResourcesAnySyntax(ClassLoader,String)} but uses
|
||||||
* thread's current context class loader.
|
* 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) {
|
public static Config parseResourcesAnySyntax(String resourceBasename) {
|
||||||
return parseResourcesAnySyntax(resourceBasename, ConfigParseOptions.defaults());
|
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) {
|
public static Config parseString(String s, ConfigParseOptions options) {
|
||||||
return Parseable.newString(s, options).parse().toConfig();
|
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) {
|
public static Config parseString(String s) {
|
||||||
return parseString(s, ConfigParseOptions.defaults());
|
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
|
* object of "b". The caller of this method should ensure that doesn't
|
||||||
* happen.
|
* happen.
|
||||||
*
|
*
|
||||||
* @param values
|
* @param values map from paths to plain Java objects
|
||||||
* @param originDescription
|
* @param originDescription
|
||||||
* description of what this map represents, like a filename, or
|
* description of what this map represents, like a filename, or
|
||||||
* "default settings" (origin description is used in error
|
* "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,
|
* See the other overload of {@link #parseMap(Map, String)} for details,
|
||||||
* this one just uses a default origin description.
|
* 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}
|
* @return the map converted to a {@code Config}
|
||||||
*/
|
*/
|
||||||
public static Config parseMap(Map<String, ? extends Object> values) {
|
public static Config parseMap(Map<String, ? extends Object> values) {
|
||||||
|
@ -23,7 +23,7 @@ public interface ConfigIncluder {
|
|||||||
* the fallback is the same one you already have. The same fallback may be
|
* the fallback is the same one you already have. The same fallback may be
|
||||||
* added repeatedly.
|
* added repeatedly.
|
||||||
*
|
*
|
||||||
* @param fallback
|
* @param fallback the previous includer for chaining
|
||||||
* @return a new includer
|
* @return a new includer
|
||||||
*/
|
*/
|
||||||
ConfigIncluder withFallback(ConfigIncluder fallback);
|
ConfigIncluder withFallback(ConfigIncluder fallback);
|
||||||
|
@ -23,6 +23,8 @@ public final class ConfigMemorySize {
|
|||||||
* Constructs a ConfigMemorySize representing the given
|
* Constructs a ConfigMemorySize representing the given
|
||||||
* number of bytes.
|
* number of bytes.
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
|
* @param bytes a number of bytes
|
||||||
|
* @return an instance representing the number of bytes
|
||||||
*/
|
*/
|
||||||
public static ConfigMemorySize ofBytes(long bytes) {
|
public static ConfigMemorySize ofBytes(long bytes) {
|
||||||
return new ConfigMemorySize(bytes);
|
return new ConfigMemorySize(bytes);
|
||||||
@ -31,6 +33,7 @@ public final class ConfigMemorySize {
|
|||||||
/**
|
/**
|
||||||
* Gets the size in bytes.
|
* Gets the size in bytes.
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
|
* @return how many bytes
|
||||||
*/
|
*/
|
||||||
public long toBytes() {
|
public long toBytes() {
|
||||||
return bytes;
|
return bytes;
|
||||||
|
@ -79,17 +79,17 @@ public interface ConfigOrigin {
|
|||||||
* none
|
* none
|
||||||
*/
|
*/
|
||||||
public List<String> comments();
|
public List<String> comments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@code ConfigOrigin} based on this one, but with the given
|
* Returns a {@code ConfigOrigin} based on this one, but with the given
|
||||||
* comments. Does not modify this instance or any {@code ConfigValue}s with
|
* comments. Does not modify this instance or any {@code ConfigValue}s with
|
||||||
* this origin (since they are immutable). To set the returned origin to a
|
* this origin (since they are immutable). To set the returned origin to a
|
||||||
* {@code ConfigValue}, use {@link ConfigValue#withOrigin}.
|
* {@code ConfigValue}, use {@link ConfigValue#withOrigin}.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Note that when the given comments are equal to the comments on this object,
|
* 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.
|
* a new instance may not be created and {@code this} is returned directly.
|
||||||
*
|
*
|
||||||
* @param comments the comments used on the returned origin
|
* @param comments the comments used on the returned origin
|
||||||
* @return the ConfigOrigin with the given comments
|
* @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
|
* 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
|
* this instance or any {@code ConfigValue}s with this origin (since they are
|
||||||
* immutable). To set the returned origin to a {@code ConfigValue}, use
|
* immutable). To set the returned origin to a {@code ConfigValue}, use
|
||||||
* {@link ConfigValue#withOrigin}.
|
* {@link ConfigValue#withOrigin}.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Note that when the given lineNumber are equal to the lineNumber on this
|
* 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
|
* object, a new instance may not be created and {@code this} is returned
|
||||||
* directly.
|
* directly.
|
||||||
*
|
*
|
||||||
* @param comments the comments used on the returned origin
|
* @param lineNumber the new line number
|
||||||
* @return the created ConfigOrigin
|
* @return the created ConfigOrigin
|
||||||
*/
|
*/
|
||||||
public ConfigOrigin withLineNumber(int lineNumber);
|
public ConfigOrigin withLineNumber(int lineNumber);
|
||||||
|
@ -15,43 +15,43 @@ import com.typesafe.config.impl.ConfigImpl;
|
|||||||
public final class ConfigOriginFactory {
|
public final class ConfigOriginFactory {
|
||||||
private ConfigOriginFactory() {
|
private ConfigOriginFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default origin for values when no other information is
|
* Returns the default origin for values when no other information is
|
||||||
* provided. This is the origin used in {@link ConfigValueFactory
|
* provided. This is the origin used in {@link ConfigValueFactory
|
||||||
* #fromAnyRef(Object)}.
|
* #fromAnyRef(Object)}.
|
||||||
*
|
*
|
||||||
* @return the default origin
|
* @return the default origin
|
||||||
*/
|
*/
|
||||||
public static ConfigOrigin newSimple() {
|
public static ConfigOrigin newSimple() {
|
||||||
return newSimple(null);
|
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
|
* @param description brief description of what the origin is
|
||||||
* @return
|
* @return a new origin
|
||||||
*/
|
*/
|
||||||
public static ConfigOrigin newSimple(String description) {
|
public static ConfigOrigin newSimple(String description) {
|
||||||
return ConfigImpl.newSimpleOrigin(description);
|
return ConfigImpl.newSimpleOrigin(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a file origin with the given filename.
|
* Creates a file origin with the given filename.
|
||||||
*
|
*
|
||||||
* @param filename the filename of this origin
|
* @param filename the filename of this origin
|
||||||
* @return
|
* @return a new origin
|
||||||
*/
|
*/
|
||||||
public static ConfigOrigin newFile(String filename) {
|
public static ConfigOrigin newFile(String filename) {
|
||||||
return ConfigImpl.newFileOrigin(filename);
|
return ConfigImpl.newFileOrigin(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a url origin with the given URL object.
|
* Creates a url origin with the given URL object.
|
||||||
*
|
*
|
||||||
* @param url the url of this origin
|
* @param url the url of this origin
|
||||||
* @return
|
* @return a new origin
|
||||||
*/
|
*/
|
||||||
public static ConfigOrigin newURL(URL url) {
|
public static ConfigOrigin newURL(URL url) {
|
||||||
return ConfigImpl.newURLOrigin(url);
|
return ConfigImpl.newURLOrigin(url);
|
||||||
|
@ -36,6 +36,12 @@ public final class ConfigParseOptions {
|
|||||||
this.classLoader = classLoader;
|
this.classLoader = classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an instance of <code>ConfigParseOptions</code> 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() {
|
public static ConfigParseOptions defaults() {
|
||||||
return new ConfigParseOptions(null, null, true, null, null);
|
return new ConfigParseOptions(null, null, true, null, null);
|
||||||
}
|
}
|
||||||
@ -56,6 +62,10 @@ public final class ConfigParseOptions {
|
|||||||
this.includer, this.classLoader);
|
this.includer, this.classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current syntax option, which may be null for "any".
|
||||||
|
* @return the current syntax or null
|
||||||
|
*/
|
||||||
public ConfigSyntax getSyntax() {
|
public ConfigSyntax getSyntax() {
|
||||||
return syntax;
|
return syntax;
|
||||||
}
|
}
|
||||||
@ -67,7 +77,7 @@ public final class ConfigParseOptions {
|
|||||||
* library to come up with something automatically. This description is the
|
* library to come up with something automatically. This description is the
|
||||||
* basis for the {@link ConfigOrigin} of the parsed values.
|
* 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
|
* @return options with the origin description set
|
||||||
*/
|
*/
|
||||||
public ConfigParseOptions setOriginDescription(String originDescription) {
|
public ConfigParseOptions setOriginDescription(String originDescription) {
|
||||||
@ -82,6 +92,10 @@ public final class ConfigParseOptions {
|
|||||||
this.includer, this.classLoader);
|
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() {
|
public String getOriginDescription() {
|
||||||
return originDescription;
|
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
|
* a file) is missing. Set to true to just return an empty document in that
|
||||||
* case.
|
* case.
|
||||||
*
|
*
|
||||||
* @param allowMissing
|
* @param allowMissing true to silently ignore missing item
|
||||||
* @return options with the "allow missing" flag set
|
* @return options with the "allow missing" flag set
|
||||||
*/
|
*/
|
||||||
public ConfigParseOptions setAllowMissing(boolean allowMissing) {
|
public ConfigParseOptions setAllowMissing(boolean allowMissing) {
|
||||||
@ -110,14 +124,19 @@ public final class ConfigParseOptions {
|
|||||||
this.includer, this.classLoader);
|
this.includer, this.classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current "allow missing" flag.
|
||||||
|
* @return whether we allow missing files
|
||||||
|
*/
|
||||||
public boolean getAllowMissing() {
|
public boolean getAllowMissing() {
|
||||||
return allowMissing;
|
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
|
* @return new version of the parse options with different includer
|
||||||
*/
|
*/
|
||||||
public ConfigParseOptions setIncluder(ConfigIncluder includer) {
|
public ConfigParseOptions setIncluder(ConfigIncluder includer) {
|
||||||
@ -128,7 +147,18 @@ public final class ConfigParseOptions {
|
|||||||
includer, this.classLoader);
|
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) {
|
public ConfigParseOptions prependIncluder(ConfigIncluder includer) {
|
||||||
|
if (includer == null)
|
||||||
|
throw new NullPointerException("null includer passed to prependIncluder");
|
||||||
if (this.includer == includer)
|
if (this.includer == includer)
|
||||||
return this;
|
return this;
|
||||||
else if (this.includer != null)
|
else if (this.includer != null)
|
||||||
@ -137,7 +167,17 @@ public final class ConfigParseOptions {
|
|||||||
return setIncluder(includer);
|
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) {
|
public ConfigParseOptions appendIncluder(ConfigIncluder includer) {
|
||||||
|
if (includer == null)
|
||||||
|
throw new NullPointerException("null includer passed to appendIncluder");
|
||||||
if (this.includer == includer)
|
if (this.includer == includer)
|
||||||
return this;
|
return this;
|
||||||
else if (this.includer != null)
|
else if (this.includer != null)
|
||||||
@ -146,6 +186,10 @@ public final class ConfigParseOptions {
|
|||||||
return setIncluder(includer);
|
return setIncluder(includer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current includer (will be null for the default includer).
|
||||||
|
* @return current includer or null
|
||||||
|
*/
|
||||||
public ConfigIncluder getIncluder() {
|
public ConfigIncluder getIncluder() {
|
||||||
return includer;
|
return includer;
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,14 @@ public interface ConfigParseable {
|
|||||||
* @param options
|
* @param options
|
||||||
* parse options, should be based on the ones from
|
* parse options, should be based on the ones from
|
||||||
* {@link ConfigParseable#options options()}
|
* {@link ConfigParseable#options options()}
|
||||||
|
* @return the parsed object
|
||||||
*/
|
*/
|
||||||
ConfigObject parse(ConfigParseOptions options);
|
ConfigObject parse(ConfigParseOptions options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link ConfigOrigin} describing the origin of the parseable
|
* Returns a {@link ConfigOrigin} describing the origin of the parseable
|
||||||
* item.
|
* item.
|
||||||
|
* @return the origin of the parseable item
|
||||||
*/
|
*/
|
||||||
ConfigOrigin origin();
|
ConfigOrigin origin();
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ public interface ConfigParseable {
|
|||||||
* Get the initial options, which can be modified then passed to parse().
|
* Get the initial options, which can be modified then passed to parse().
|
||||||
* These options will have the right description, includer, and other
|
* These options will have the right description, includer, and other
|
||||||
* parameters already set up.
|
* parameters already set up.
|
||||||
|
* @return the initial options
|
||||||
*/
|
*/
|
||||||
ConfigParseOptions options();
|
ConfigParseOptions options();
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public interface ConfigValue extends ConfigMergeable {
|
|||||||
* {@code List<Object>}, or {@code null}, matching the {@link #valueType()}
|
* {@code List<Object>}, or {@code null}, matching the {@link #valueType()}
|
||||||
* of this {@code ConfigValue}. If the value is a {@link ConfigObject} or
|
* of this {@code ConfigValue}. If the value is a {@link ConfigObject} or
|
||||||
* {@link ConfigList}, it is recursively unwrapped.
|
* {@link ConfigList}, it is recursively unwrapped.
|
||||||
|
* @return a plain Java value corresponding to this ConfigValue
|
||||||
*/
|
*/
|
||||||
Object unwrapped();
|
Object unwrapped();
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ public final class ConfigValueFactory {
|
|||||||
* See also {@link ConfigFactory#parseMap(Map,String)} which interprets the
|
* See also {@link ConfigFactory#parseMap(Map,String)} which interprets the
|
||||||
* keys in the map as path expressions.
|
* keys in the map as path expressions.
|
||||||
*
|
*
|
||||||
* @param values
|
* @param values map from keys to plain Java values
|
||||||
* @param originDescription
|
* @param originDescription description to use in {@link ConfigOrigin} of created values
|
||||||
* @return a new {@link ConfigObject} value
|
* @return a new {@link ConfigObject} value
|
||||||
*/
|
*/
|
||||||
public static ConfigObject fromMap(Map<String, ? extends Object> values,
|
public static ConfigObject fromMap(Map<String, ? extends Object> values,
|
||||||
@ -104,9 +104,9 @@ public final class ConfigValueFactory {
|
|||||||
* See the {@link #fromAnyRef(Object,String)} documentation for details.
|
* See the {@link #fromAnyRef(Object,String)} documentation for details.
|
||||||
* This is a typesafe wrapper that only works on {@link java.lang.Iterable}
|
* This is a typesafe wrapper that only works on {@link java.lang.Iterable}
|
||||||
* and returns {@link ConfigList} rather than {@link ConfigValue}.
|
* and returns {@link ConfigList} rather than {@link ConfigValue}.
|
||||||
*
|
*
|
||||||
* @param values
|
* @param values list of plain Java values
|
||||||
* @param originDescription
|
* @param originDescription description to use in {@link ConfigOrigin} of created values
|
||||||
* @return a new {@link ConfigList} value
|
* @return a new {@link ConfigList} value
|
||||||
*/
|
*/
|
||||||
public static ConfigList fromIterable(Iterable<? extends Object> values,
|
public static ConfigList fromIterable(Iterable<? extends Object> values,
|
||||||
@ -118,7 +118,7 @@ public final class ConfigValueFactory {
|
|||||||
* See the other overload {@link #fromAnyRef(Object,String)} for details,
|
* See the other overload {@link #fromAnyRef(Object,String)} for details,
|
||||||
* this one just uses a default origin description.
|
* this one just uses a default origin description.
|
||||||
*
|
*
|
||||||
* @param object
|
* @param object a plain Java value
|
||||||
* @return a new {@link ConfigValue}
|
* @return a new {@link ConfigValue}
|
||||||
*/
|
*/
|
||||||
public static ConfigValue fromAnyRef(Object object) {
|
public static ConfigValue fromAnyRef(Object object) {
|
||||||
@ -133,7 +133,7 @@ public final class ConfigValueFactory {
|
|||||||
* See also {@link ConfigFactory#parseMap(Map)} which interprets the keys in
|
* See also {@link ConfigFactory#parseMap(Map)} which interprets the keys in
|
||||||
* the map as path expressions.
|
* the map as path expressions.
|
||||||
*
|
*
|
||||||
* @param values
|
* @param values map from keys to plain Java values
|
||||||
* @return a new {@link ConfigObject}
|
* @return a new {@link ConfigObject}
|
||||||
*/
|
*/
|
||||||
public static ConfigObject fromMap(Map<String, ? extends Object> values) {
|
public static ConfigObject fromMap(Map<String, ? extends Object> values) {
|
||||||
@ -144,7 +144,7 @@ public final class ConfigValueFactory {
|
|||||||
* See the other overload of {@link #fromIterable(Iterable, String)} for
|
* See the other overload of {@link #fromIterable(Iterable, String)} for
|
||||||
* details, this one just uses a default origin description.
|
* details, this one just uses a default origin description.
|
||||||
*
|
*
|
||||||
* @param values
|
* @param values list of plain Java values
|
||||||
* @return a new {@link ConfigList}
|
* @return a new {@link ConfigList}
|
||||||
*/
|
*/
|
||||||
public static ConfigList fromIterable(Iterable<? extends Object> values) {
|
public static ConfigList fromIterable(Iterable<? extends Object> values) {
|
||||||
|
@ -23,11 +23,19 @@ import com.typesafe.config.ConfigMemorySize;
|
|||||||
import com.typesafe.config.ConfigValue;
|
import com.typesafe.config.ConfigValue;
|
||||||
import com.typesafe.config.ConfigValueType;
|
import com.typesafe.config.ConfigValueType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation detail, not ABI stable, do not touch.
|
||||||
|
* For use only by the {@link com.typesafe.config} package.
|
||||||
|
*/
|
||||||
public class ConfigBeanImpl {
|
public class ConfigBeanImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
||||||
* may change.
|
* may change.
|
||||||
|
* @param <T> type of the bean
|
||||||
|
* @param config config to use
|
||||||
|
* @param clazz class of the bean
|
||||||
|
* @return the bean instance
|
||||||
*/
|
*/
|
||||||
public static <T> T createInternal(Config config, Class<T> clazz) {
|
public static <T> T createInternal(Config config, Class<T> clazz) {
|
||||||
if (((SimpleConfig)config).root().resolveStatus() != ResolveStatus.RESOLVED)
|
if (((SimpleConfig)config).root().resolveStatus() != ResolveStatus.RESOLVED)
|
||||||
|
@ -27,7 +27,10 @@ import com.typesafe.config.ConfigParseable;
|
|||||||
import com.typesafe.config.ConfigValue;
|
import com.typesafe.config.ConfigValue;
|
||||||
import com.typesafe.config.impl.SimpleIncluder.NameSource;
|
import com.typesafe.config.impl.SimpleIncluder.NameSource;
|
||||||
|
|
||||||
/** This is public but is only supposed to be used by the "config" package */
|
/**
|
||||||
|
* Internal implementation detail, not ABI stable, do not touch.
|
||||||
|
* For use only by the {@link com.typesafe.config} package.
|
||||||
|
*/
|
||||||
public class ConfigImpl {
|
public class ConfigImpl {
|
||||||
|
|
||||||
private static class LoaderCache {
|
private static class LoaderCache {
|
||||||
@ -78,7 +81,6 @@ public class ConfigImpl {
|
|||||||
static final LoaderCache cache = new LoaderCache();
|
static final LoaderCache cache = new LoaderCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static Config computeCachedConfig(ClassLoader loader, String key,
|
public static Config computeCachedConfig(ClassLoader loader, String key,
|
||||||
Callable<Config> updater) {
|
Callable<Config> updater) {
|
||||||
LoaderCache cache;
|
LoaderCache cache;
|
||||||
@ -118,21 +120,18 @@ public class ConfigImpl {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigObject parseResourcesAnySyntax(Class<?> klass, String resourceBasename,
|
public static ConfigObject parseResourcesAnySyntax(Class<?> klass, String resourceBasename,
|
||||||
ConfigParseOptions baseOptions) {
|
ConfigParseOptions baseOptions) {
|
||||||
NameSource source = new ClasspathNameSourceWithClass(klass);
|
NameSource source = new ClasspathNameSourceWithClass(klass);
|
||||||
return SimpleIncluder.fromBasename(source, resourceBasename, baseOptions);
|
return SimpleIncluder.fromBasename(source, resourceBasename, baseOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigObject parseResourcesAnySyntax(String resourceBasename,
|
public static ConfigObject parseResourcesAnySyntax(String resourceBasename,
|
||||||
ConfigParseOptions baseOptions) {
|
ConfigParseOptions baseOptions) {
|
||||||
NameSource source = new ClasspathNameSource();
|
NameSource source = new ClasspathNameSource();
|
||||||
return SimpleIncluder.fromBasename(source, resourceBasename, baseOptions);
|
return SimpleIncluder.fromBasename(source, resourceBasename, baseOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigObject parseFileAnySyntax(File basename, ConfigParseOptions baseOptions) {
|
public static ConfigObject parseFileAnySyntax(File basename, ConfigParseOptions baseOptions) {
|
||||||
NameSource source = new FileNameSource();
|
NameSource source = new FileNameSource();
|
||||||
return SimpleIncluder.fromBasename(source, basename.getPath(), baseOptions);
|
return SimpleIncluder.fromBasename(source, basename.getPath(), baseOptions);
|
||||||
@ -144,7 +143,6 @@ public class ConfigImpl {
|
|||||||
return emptyObject(origin);
|
return emptyObject(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static Config emptyConfig(String originDescription) {
|
public static Config emptyConfig(String originDescription) {
|
||||||
return emptyObject(originDescription).toConfig();
|
return emptyObject(originDescription).toConfig();
|
||||||
}
|
}
|
||||||
@ -191,13 +189,11 @@ public class ConfigImpl {
|
|||||||
return SimpleConfigOrigin.newSimple(originDescription);
|
return SimpleConfigOrigin.newSimple(originDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigValue fromAnyRef(Object object, String originDescription) {
|
public static ConfigValue fromAnyRef(Object object, String originDescription) {
|
||||||
ConfigOrigin origin = valueOrigin(originDescription);
|
ConfigOrigin origin = valueOrigin(originDescription);
|
||||||
return fromAnyRef(object, origin, FromMapMode.KEYS_ARE_KEYS);
|
return fromAnyRef(object, origin, FromMapMode.KEYS_ARE_KEYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigObject fromPathMap(
|
public static ConfigObject fromPathMap(
|
||||||
Map<String, ? extends Object> pathMap, String originDescription) {
|
Map<String, ? extends Object> pathMap, String originDescription) {
|
||||||
ConfigOrigin origin = valueOrigin(originDescription);
|
ConfigOrigin origin = valueOrigin(originDescription);
|
||||||
@ -328,12 +324,10 @@ public class ConfigImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static Config systemPropertiesAsConfig() {
|
public static Config systemPropertiesAsConfig() {
|
||||||
return systemPropertiesAsConfigObject().toConfig();
|
return systemPropertiesAsConfigObject().toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static void reloadSystemPropertiesConfig() {
|
public static void reloadSystemPropertiesConfig() {
|
||||||
// ConfigFactory.invalidateCaches() relies on this having the side
|
// ConfigFactory.invalidateCaches() relies on this having the side
|
||||||
// effect that it drops all caches
|
// effect that it drops all caches
|
||||||
@ -365,12 +359,10 @@ public class ConfigImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static Config envVariablesAsConfig() {
|
public static Config envVariablesAsConfig() {
|
||||||
return envVariablesAsConfigObject().toConfig();
|
return envVariablesAsConfigObject().toConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static Config defaultReference(final ClassLoader loader) {
|
public static Config defaultReference(final ClassLoader loader) {
|
||||||
return computeCachedConfig(loader, "defaultReference", new Callable<Config>() {
|
return computeCachedConfig(loader, "defaultReference", new Callable<Config>() {
|
||||||
@Override
|
@Override
|
||||||
@ -427,7 +419,6 @@ public class ConfigImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static boolean traceLoadsEnabled() {
|
public static boolean traceLoadsEnabled() {
|
||||||
try {
|
try {
|
||||||
return DebugHolder.traceLoadsEnabled();
|
return DebugHolder.traceLoadsEnabled();
|
||||||
@ -470,8 +461,7 @@ public class ConfigImpl {
|
|||||||
else
|
else
|
||||||
return new ConfigException.NotResolved(newMessage, original);
|
return new ConfigException.NotResolved(newMessage, original);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigOrigin newSimpleOrigin(String description) {
|
public static ConfigOrigin newSimpleOrigin(String description) {
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
return defaultValueOrigin;
|
return defaultValueOrigin;
|
||||||
@ -480,14 +470,11 @@ public class ConfigImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigOrigin newFileOrigin(String filename) {
|
public static ConfigOrigin newFileOrigin(String filename) {
|
||||||
return SimpleConfigOrigin.newFile(filename);
|
return SimpleConfigOrigin.newFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For use ONLY by library internals, DO NOT TOUCH not guaranteed ABI */
|
|
||||||
public static ConfigOrigin newURLOrigin(URL url) {
|
public static ConfigOrigin newURLOrigin(URL url) {
|
||||||
return SimpleConfigOrigin.newURL(url);
|
return SimpleConfigOrigin.newURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@ import java.util.List;
|
|||||||
import com.typesafe.config.ConfigException;
|
import com.typesafe.config.ConfigException;
|
||||||
import com.typesafe.config.ConfigOrigin;
|
import com.typesafe.config.ConfigOrigin;
|
||||||
|
|
||||||
|
/**
|
||||||
/** This is public just for the "config" package to use, don't touch it */
|
* Internal implementation detail, not ABI stable, do not touch.
|
||||||
|
* For use only by the {@link com.typesafe.config} package.
|
||||||
|
*/
|
||||||
final public class ConfigImplUtil {
|
final public class ConfigImplUtil {
|
||||||
static boolean equalsHandlingNull(Object a, Object b) {
|
static boolean equalsHandlingNull(Object a, Object b) {
|
||||||
if (a == null && b != null)
|
if (a == null && b != null)
|
||||||
@ -30,10 +32,6 @@ final public class ConfigImplUtil {
|
|||||||
return a.equals(b);
|
return a.equals(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
|
||||||
* may change.
|
|
||||||
*/
|
|
||||||
public static String renderJsonString(String s) {
|
public static String renderJsonString(String s) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append('"');
|
sb.append('"');
|
||||||
@ -117,7 +115,6 @@ final public class ConfigImplUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is public just for the "config" package to use, don't touch it! */
|
|
||||||
public static String unicodeTrim(String s) {
|
public static String unicodeTrim(String s) {
|
||||||
// this is dumb because it looks like there aren't any whitespace
|
// this is dumb because it looks like there aren't any whitespace
|
||||||
// characters that need surrogate encoding. But, points for
|
// characters that need surrogate encoding. But, points for
|
||||||
@ -166,7 +163,7 @@ final public class ConfigImplUtil {
|
|||||||
return s.substring(start, end);
|
return s.substring(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is public just for the "config" package to use, don't touch it! */
|
|
||||||
public static ConfigException extractInitializerError(ExceptionInInitializerError e) {
|
public static ConfigException extractInitializerError(ExceptionInInitializerError e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause != null && cause instanceof ConfigException) {
|
if (cause != null && cause instanceof ConfigException) {
|
||||||
@ -192,26 +189,14 @@ final public class ConfigImplUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
|
||||||
* may change. You can use the version in ConfigUtil instead.
|
|
||||||
*/
|
|
||||||
public static String joinPath(String... elements) {
|
public static String joinPath(String... elements) {
|
||||||
return (new Path(elements)).render();
|
return (new Path(elements)).render();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
|
||||||
* may change. You can use the version in ConfigUtil instead.
|
|
||||||
*/
|
|
||||||
public static String joinPath(List<String> elements) {
|
public static String joinPath(List<String> elements) {
|
||||||
return joinPath(elements.toArray(new String[0]));
|
return joinPath(elements.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This is public ONLY for use by the "config" package, DO NOT USE this ABI
|
|
||||||
* may change. You can use the version in ConfigUtil instead.
|
|
||||||
*/
|
|
||||||
public static List<String> splitPath(String path) {
|
public static List<String> splitPath(String path) {
|
||||||
Path p = Path.newPath(path);
|
Path p = Path.newPath(path);
|
||||||
List<String> elements = new ArrayList<String>();
|
List<String> elements = new ArrayList<String>();
|
||||||
|
@ -35,18 +35,22 @@ import com.typesafe.config.ConfigSyntax;
|
|||||||
import com.typesafe.config.ConfigValue;
|
import com.typesafe.config.ConfigValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is public but it's only for use by the config package; DO NOT TOUCH. The
|
* Internal implementation detail, not ABI stable, do not touch.
|
||||||
* point of this class is to avoid "propagating" each overload on
|
* For use only by the {@link com.typesafe.config} package.
|
||||||
* "thing which can be parsed" through multiple interfaces. Most interfaces can
|
* The point of this class is to avoid "propagating" each
|
||||||
* have just one overload that takes a Parseable. Also it's used as an abstract
|
* overload on "thing which can be parsed" through multiple
|
||||||
* "resource handle" in the ConfigIncluder interface.
|
* interfaces. Most interfaces can have just one overload that
|
||||||
|
* takes a Parseable. Also it's used as an abstract "resource
|
||||||
|
* handle" in the ConfigIncluder interface.
|
||||||
*/
|
*/
|
||||||
public abstract class Parseable implements ConfigParseable {
|
public abstract class Parseable implements ConfigParseable {
|
||||||
private ConfigIncludeContext includeContext;
|
private ConfigIncludeContext includeContext;
|
||||||
private ConfigParseOptions initialOptions;
|
private ConfigParseOptions initialOptions;
|
||||||
private ConfigOrigin initialOrigin;
|
private ConfigOrigin initialOrigin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal implementation detail, not ABI stable, do not touch.
|
||||||
|
*/
|
||||||
protected interface Relativizer {
|
protected interface Relativizer {
|
||||||
ConfigParseable relativeTo(String filename);
|
ConfigParseable relativeTo(String filename);
|
||||||
}
|
}
|
||||||
@ -383,10 +387,8 @@ public abstract class Parseable implements ConfigParseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// note that we will never close this reader; you have to do it when parsing
|
||||||
* note that we will never close this reader; you have to do it when parsing
|
// is complete.
|
||||||
* is complete.
|
|
||||||
*/
|
|
||||||
public static Parseable newReader(Reader reader, ConfigParseOptions options) {
|
public static Parseable newReader(Reader reader, ConfigParseOptions options) {
|
||||||
|
|
||||||
return new ParseableReader(doNotClose(reader), options);
|
return new ParseableReader(doNotClose(reader), options);
|
||||||
|
25
config/src/main/java/com/typesafe/config/impl/package.html
Normal file
25
config/src/main/java/com/typesafe/config/impl/package.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2011 Typesafe Inc. <http://typesafe.com>
|
||||||
|
-->
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Internal implementation details that can change ABI at any time.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Please check out the {@link com.typesafe.config.Config public API} instead, unless
|
||||||
|
you're interested in browsing implementation details. None of the ABI
|
||||||
|
under <code>impl</code> has any guarantees; it will change whenever someone
|
||||||
|
feels like changing it. If you feel you need access to something
|
||||||
|
in <code>impl</code>, <a href="https://github.com/typesafehub/config/issues">please
|
||||||
|
file a feature request</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
63
project/linksource.scala
Normal file
63
project/linksource.scala
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import sbt._
|
||||||
|
import Keys._
|
||||||
|
import plugins.JvmPlugin
|
||||||
|
|
||||||
|
object LinkSourcePlugin extends AutoPlugin {
|
||||||
|
|
||||||
|
object autoImport {
|
||||||
|
lazy val javadocSourceBaseUrl = settingKey[Option[String]]("base URL (no trailing slash) for source code")
|
||||||
|
}
|
||||||
|
|
||||||
|
import autoImport._
|
||||||
|
|
||||||
|
override def trigger = allRequirements
|
||||||
|
override def requires = JvmPlugin
|
||||||
|
override lazy val projectSettings = Seq(
|
||||||
|
javadocSourceBaseUrl := None,
|
||||||
|
javacOptions in (Compile, doc) := {
|
||||||
|
val old = (javacOptions in doc).value
|
||||||
|
if (old.contains("-linksource"))
|
||||||
|
old
|
||||||
|
else
|
||||||
|
"-linksource" +: old
|
||||||
|
},
|
||||||
|
(doc in Compile) := {
|
||||||
|
val result = (doc in Compile).value
|
||||||
|
|
||||||
|
val dir = (target in doc in Compile).value
|
||||||
|
|
||||||
|
javadocSourceBaseUrl.value.foreach { url =>
|
||||||
|
rewriteSourceLinks(dir, url, streams.value.log)
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
private def rewriteSourceLinks(dir: File, sourceBaseUrl: String, log: Logger): Unit = {
|
||||||
|
// Convert <a href="../../../src-html/com/typesafe/config/Config.html#line.165"> to
|
||||||
|
// "https://github.com/typesafehub/config/blob/v1.2.1/config/src/main/java/com/typesafe/config/Config.java#L165"
|
||||||
|
// in all .html files found underneath dir
|
||||||
|
val origRegex = "href=\".*src-html/([^\"]+)\"".r
|
||||||
|
def listFiles(d: File): Seq[File] = IO.listFiles(d).toSeq.flatMap { f =>
|
||||||
|
if (f.isDirectory)
|
||||||
|
listFiles(f)
|
||||||
|
else
|
||||||
|
Seq(f)
|
||||||
|
}
|
||||||
|
val htmlFiles = listFiles(dir).filter(_.getName.endsWith(".html"))
|
||||||
|
for (f <- htmlFiles) {
|
||||||
|
val content = IO.read(f)
|
||||||
|
val changed = origRegex.replaceAllIn(content, { m: scala.util.matching.Regex.Match =>
|
||||||
|
val oldFileLine = m.group(1)
|
||||||
|
val fileLine = oldFileLine.replace("line.", "L").replace(".html", ".java")
|
||||||
|
s""" href="$sourceBaseUrl/$fileLine" target="_blank" """
|
||||||
|
})
|
||||||
|
if (content != changed) {
|
||||||
|
log.info(s"Replacing source links in $f")
|
||||||
|
IO.write(f, changed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,8 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
|
|||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
|
||||||
|
|
||||||
|
addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "0.4.1")
|
||||||
|
|
||||||
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
|
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")
|
||||||
|
Loading…
Reference in New Issue
Block a user