Updating to HOCON as of 2012-02-21
This commit is contained in:
parent
1ea4dd210f
commit
8b10cd97d5
53 changed files with 172 additions and 2 deletions
21
akka-actor/src/main/java/com/typesafe/config/Config.java
Normal file → Executable file
21
akka-actor/src/main/java/com/typesafe/config/Config.java
Normal file → Executable file
|
|
@ -418,7 +418,7 @@ public interface Config extends ConfigMergeable {
|
||||||
* units suffixes like "10m" or "5ns" as documented in the <a
|
* units suffixes like "10m" or "5ns" as documented in the <a
|
||||||
* href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
|
* href="https://github.com/typesafehub/config/blob/master/HOCON.md">the
|
||||||
* spec</a>.
|
* spec</a>.
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* path expression
|
* path expression
|
||||||
* @return the duration value at the requested path, in milliseconds
|
* @return the duration value at the requested path, in milliseconds
|
||||||
|
|
@ -487,4 +487,23 @@ public interface Config extends ConfigMergeable {
|
||||||
List<Long> getMillisecondsList(String path);
|
List<Long> getMillisecondsList(String path);
|
||||||
|
|
||||||
List<Long> getNanosecondsList(String path);
|
List<Long> getNanosecondsList(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone the config with only the given path (and its children) retained;
|
||||||
|
* all sibling paths are removed.
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* path to keep
|
||||||
|
* @return a copy of the config minus all paths except the one specified
|
||||||
|
*/
|
||||||
|
Config withOnlyPath(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone the config with the given path removed.
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* path to remove
|
||||||
|
* @return a copy of the config minus the specified path
|
||||||
|
*/
|
||||||
|
Config withoutPath(String path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
0
akka-actor/src/main/java/com/typesafe/config/ConfigException.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigException.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigFactory.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigFactory.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigIncludeContext.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigIncludeContext.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigIncluder.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigIncluder.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigList.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigList.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigMergeable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigMergeable.java
Normal file → Executable file
19
akka-actor/src/main/java/com/typesafe/config/ConfigObject.java
Normal file → Executable file
19
akka-actor/src/main/java/com/typesafe/config/ConfigObject.java
Normal file → Executable file
|
|
@ -91,4 +91,23 @@ public interface ConfigObject extends ConfigValue, Map<String, ConfigValue> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
ConfigValue get(Object key);
|
ConfigValue get(Object key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone the object with only the given key (and its children) retained; all
|
||||||
|
* sibling keys are removed.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* key to keep
|
||||||
|
* @return a copy of the object minus all keys except the one specified
|
||||||
|
*/
|
||||||
|
ConfigObject withOnlyKey(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone the object with the given key removed.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* key to remove
|
||||||
|
* @return a copy of the object minus the specified key
|
||||||
|
*/
|
||||||
|
ConfigObject withoutKey(String key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
0
akka-actor/src/main/java/com/typesafe/config/ConfigOrigin.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigOrigin.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigParseOptions.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigParseOptions.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigParseable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigParseable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigResolveOptions.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigResolveOptions.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigSyntax.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigSyntax.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigUtil.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigUtil.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValueFactory.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValueFactory.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValueType.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/ConfigValueType.java
Normal file → Executable file
12
akka-actor/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java
Normal file → Executable file
12
akka-actor/src/main/java/com/typesafe/config/impl/AbstractConfigObject.java
Normal file → Executable file
|
|
@ -43,6 +43,18 @@ abstract class AbstractConfigObject extends AbstractConfigValue implements
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
abstract public AbstractConfigObject withOnlyKey(String key);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
abstract public AbstractConfigObject withoutKey(String key);
|
||||||
|
|
||||||
|
abstract protected AbstractConfigObject withOnlyPathOrNull(Path path);
|
||||||
|
|
||||||
|
abstract AbstractConfigObject withOnlyPath(Path path);
|
||||||
|
|
||||||
|
abstract AbstractConfigObject withoutPath(Path path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This looks up the key with no transformation or type conversion of any
|
* This looks up the key with no transformation or type conversion of any
|
||||||
* kind, and returns null if the key is not present.
|
* kind, and returns null if the key is not present.
|
||||||
|
|
|
||||||
0
akka-actor/src/main/java/com/typesafe/config/impl/AbstractConfigValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/AbstractConfigValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigBoolean.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigBoolean.java
Normal file → Executable file
2
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java
Normal file → Executable file
2
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java
Normal file → Executable file
|
|
@ -25,6 +25,8 @@ import com.typesafe.config.ConfigValueType;
|
||||||
final class ConfigDelayedMerge extends AbstractConfigValue implements
|
final class ConfigDelayedMerge extends AbstractConfigValue implements
|
||||||
Unmergeable {
|
Unmergeable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// earlier items in the stack win
|
// earlier items in the stack win
|
||||||
final private List<AbstractConfigValue> stack;
|
final private List<AbstractConfigValue> stack;
|
||||||
final private boolean ignoresFallbacks;
|
final private boolean ignoresFallbacks;
|
||||||
|
|
|
||||||
29
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java
Normal file → Executable file
29
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java
Normal file → Executable file
|
|
@ -18,9 +18,11 @@ import com.typesafe.config.ConfigValue;
|
||||||
|
|
||||||
// This is just like ConfigDelayedMerge except we know statically
|
// This is just like ConfigDelayedMerge except we know statically
|
||||||
// that it will turn out to be an object.
|
// that it will turn out to be an object.
|
||||||
class ConfigDelayedMergeObject extends AbstractConfigObject implements
|
final class ConfigDelayedMergeObject extends AbstractConfigObject implements
|
||||||
Unmergeable {
|
Unmergeable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
final private List<AbstractConfigValue> stack;
|
final private List<AbstractConfigValue> stack;
|
||||||
final private boolean ignoresFallbacks;
|
final private boolean ignoresFallbacks;
|
||||||
|
|
||||||
|
|
@ -111,6 +113,31 @@ class ConfigDelayedMergeObject extends AbstractConfigObject implements
|
||||||
return (ConfigDelayedMergeObject) super.withFallback(mergeable);
|
return (ConfigDelayedMergeObject) super.withFallback(mergeable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigDelayedMergeObject withOnlyKey(String key) {
|
||||||
|
throw notResolved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigDelayedMergeObject withoutKey(String key) {
|
||||||
|
throw notResolved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractConfigObject withOnlyPathOrNull(Path path) {
|
||||||
|
throw notResolved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
AbstractConfigObject withOnlyPath(Path path) {
|
||||||
|
throw notResolved();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
AbstractConfigObject withoutPath(Path path) {
|
||||||
|
throw notResolved();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<AbstractConfigValue> unmergedValues() {
|
public Collection<AbstractConfigValue> unmergedValues() {
|
||||||
return stack;
|
return stack;
|
||||||
|
|
|
||||||
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDouble.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigDouble.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigImpl.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigImpl.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigInt.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigInt.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigLong.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigLong.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigNull.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigNull.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigNumber.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigNumber.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigString.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigString.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ConfigSubstitution.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/DefaultTransformer.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/DefaultTransformer.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/FromMapMode.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/FromMapMode.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/MergeableValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/MergeableValue.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/OriginType.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/OriginType.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Parseable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Parseable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Parser.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Parser.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Path.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Path.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/PathBuilder.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/PathBuilder.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/PropertiesParser.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/PropertiesParser.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ResolveStatus.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/ResolveStatus.java
Normal file → Executable file
12
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfig.java
Normal file → Executable file
12
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfig.java
Normal file → Executable file
|
|
@ -826,4 +826,16 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
|
||||||
throw new ConfigException.ValidationFailed(problems);
|
throw new ConfigException.ValidationFailed(problems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleConfig withOnlyPath(String pathExpression) {
|
||||||
|
Path path = Path.newPath(pathExpression);
|
||||||
|
return new SimpleConfig(root().withOnlyPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleConfig withoutPath(String pathExpression) {
|
||||||
|
Path path = Path.newPath(pathExpression);
|
||||||
|
return new SimpleConfig(root().withoutPath(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigList.java
Normal file → Executable file
2
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigList.java
Normal file → Executable file
|
|
@ -18,6 +18,8 @@ import com.typesafe.config.ConfigValueType;
|
||||||
|
|
||||||
final class SimpleConfigList extends AbstractConfigValue implements ConfigList {
|
final class SimpleConfigList extends AbstractConfigValue implements ConfigList {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
final private List<AbstractConfigValue> value;
|
final private List<AbstractConfigValue> value;
|
||||||
final private boolean resolved;
|
final private boolean resolved;
|
||||||
|
|
||||||
|
|
|
||||||
77
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java
Normal file → Executable file
77
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigObject.java
Normal file → Executable file
|
|
@ -41,6 +41,83 @@ final class SimpleConfigObject extends AbstractConfigObject {
|
||||||
this(origin, value, ResolveStatus.fromValues(value.values()), false /* ignoresFallbacks */);
|
this(origin, value, ResolveStatus.fromValues(value.values()), false /* ignoresFallbacks */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleConfigObject withOnlyKey(String key) {
|
||||||
|
return withOnlyPath(Path.newKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleConfigObject withoutKey(String key) {
|
||||||
|
return withoutPath(Path.newKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
// gets the object with only the path if the path
|
||||||
|
// exists, otherwise null if it doesn't. this ensures
|
||||||
|
// that if we have { a : { b : 42 } } and do
|
||||||
|
// withOnlyPath("a.b.c") that we don't keep an empty
|
||||||
|
// "a" object.
|
||||||
|
@Override
|
||||||
|
protected SimpleConfigObject withOnlyPathOrNull(Path path) {
|
||||||
|
String key = path.first();
|
||||||
|
Path next = path.remainder();
|
||||||
|
AbstractConfigValue v = value.get(key);
|
||||||
|
|
||||||
|
if (next != null) {
|
||||||
|
if (v != null && (v instanceof AbstractConfigObject)) {
|
||||||
|
v = ((AbstractConfigObject) v).withOnlyPathOrNull(next);
|
||||||
|
} else {
|
||||||
|
// if the path has more elements but we don't have an object,
|
||||||
|
// then the rest of the path does not exist.
|
||||||
|
v = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new SimpleConfigObject(origin(), Collections.singletonMap(key, v),
|
||||||
|
resolveStatus(), ignoresFallbacks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
SimpleConfigObject withOnlyPath(Path path) {
|
||||||
|
SimpleConfigObject o = withOnlyPathOrNull(path);
|
||||||
|
if (o == null) {
|
||||||
|
return new SimpleConfigObject(origin(),
|
||||||
|
Collections.<String, AbstractConfigValue> emptyMap(), resolveStatus(),
|
||||||
|
ignoresFallbacks);
|
||||||
|
} else {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
SimpleConfigObject withoutPath(Path path) {
|
||||||
|
String key = path.first();
|
||||||
|
Path next = path.remainder();
|
||||||
|
AbstractConfigValue v = value.get(key);
|
||||||
|
|
||||||
|
if (v != null && next != null && v instanceof AbstractConfigObject) {
|
||||||
|
v = ((AbstractConfigObject) v).withoutPath(next);
|
||||||
|
Map<String, AbstractConfigValue> updated = new HashMap<String, AbstractConfigValue>(
|
||||||
|
value);
|
||||||
|
updated.put(key, v);
|
||||||
|
return new SimpleConfigObject(origin(), updated, resolveStatus(), ignoresFallbacks);
|
||||||
|
} else if (next != null || v == null) {
|
||||||
|
// can't descend, nothing to remove
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
Map<String, AbstractConfigValue> smaller = new HashMap<String, AbstractConfigValue>(
|
||||||
|
value.size() - 1);
|
||||||
|
for (Map.Entry<String, AbstractConfigValue> old : value.entrySet()) {
|
||||||
|
if (!old.getKey().equals(key))
|
||||||
|
smaller.put(old.getKey(), old.getValue());
|
||||||
|
}
|
||||||
|
return new SimpleConfigObject(origin(), smaller, resolveStatus(), ignoresFallbacks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractConfigValue peek(String key) {
|
protected AbstractConfigValue peek(String key) {
|
||||||
return value.get(key);
|
return value.get(key);
|
||||||
|
|
|
||||||
0
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigOrigin.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/SimpleConfigOrigin.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/SubstitutionExpression.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/SubstitutionExpression.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/SubstitutionResolver.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/SubstitutionResolver.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Token.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Token.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/TokenType.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/TokenType.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Tokenizer.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Tokenizer.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Tokens.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Tokens.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Unmergeable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/impl/Unmergeable.java
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/package.html
Normal file → Executable file
0
akka-actor/src/main/java/com/typesafe/config/package.html
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue