public class ConfigObject extends GroovyObjectSupport implements Writable, Map, Cloneable
A ConfigObject at a simple level is a Map that creates configuration entries (other ConfigObjects) when referencing them. This means that navigating to foo.bar.stuff will not return null but nested ConfigObjects which are of course empty maps The Groovy truth can be used to check for the existence of "real" entries.
Constructor and description |
---|
ConfigObject(URL file) |
ConfigObject() |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
clear() |
|
public ConfigObject |
clone() Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned. |
|
public boolean |
containsKey(Object key) |
|
public boolean |
containsValue(Object value) |
|
public Set |
entrySet() |
|
public Map |
flatten() A ConfigObject is a tree structure consisting of nested maps. |
|
public Map |
flatten(Map target) Flattens this ConfigObject populating the results into the target Map |
|
public Object |
get(Object key) |
|
public URL |
getConfigFile() |
|
public Object |
getProperty(String name) Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existent keys |
|
public boolean |
isEmpty() |
|
public Boolean |
isSet(String option) Checks if a config option is set. |
|
public Set |
keySet() |
|
public Map |
merge(ConfigObject other) Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject |
|
public String |
prettyPrint() |
|
public Object |
put(Object key, Object value) |
|
public void |
putAll(Map m) |
|
public Object |
remove(Object key) |
|
public void |
setConfigFile(URL configFile) |
|
public int |
size() |
|
public Properties |
toProperties() Converts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand |
|
public Properties |
toProperties(String prefix) Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix |
|
public String |
toString() |
|
public Collection |
values() |
|
public Writer |
writeTo(Writer outArg) Writes this config object into a String serialized representation which can later be parsed back using the parse() method |
Methods inherited from class | Name |
---|---|
class GroovyObjectSupport |
getMetaClass, setMetaClass |
Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned.
A ConfigObject is a tree structure consisting of nested maps. This flattens the maps into a single level structure like a properties file
Flattens this ConfigObject populating the results into the target Map
Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existent keys
Checks if a config option is set. Example usage:
def config = new ConfigSlurper().parse("foo { password='' }") assert config.foo.isSet('password') assert config.foo.isSet('username') == falseThe check works only for options one block below the current block. E.g.
config.isSet('foo.password')
will always return false.
option
- The name of the optiontrue
if the option is set false
otherwiseMerges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
other
- The ConfigObject to merge withConverts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand
Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix
prefix
- The prefix to append before property entriesWrites this config object into a String serialized representation which can later be parsed back using the parse() method
Copyright © 2003-2022 The Apache Software Foundation. All rights reserved.