public class ConfigObject extends GroovyObjectSupport implements Writable, java.util.Map, java.lang.Cloneable
| Constructor and Description |
|---|
ConfigObject() |
ConfigObject(java.net.URL file) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
ConfigObject |
clone()
Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned.
|
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set |
entrySet() |
java.util.Map |
flatten()
A ConfigObject is a tree structure consisting of nested maps.
|
java.util.Map |
flatten(java.util.Map target)
Flattens this ConfigObject populating the results into the target Map
|
java.lang.Object |
get(java.lang.Object key) |
java.net.URL |
getConfigFile() |
java.lang.Object |
getProperty(java.lang.String name)
Overrides the default getProperty implementation to create nested ConfigObject instances on demand
for non-existent keys
|
boolean |
isEmpty() |
java.lang.Boolean |
isSet(java.lang.String option)
Checks if a config option is set.
|
java.util.Set |
keySet() |
java.util.Map |
merge(ConfigObject other)
Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
|
java.lang.String |
prettyPrint() |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value) |
void |
putAll(java.util.Map m) |
java.lang.Object |
remove(java.lang.Object key) |
void |
setConfigFile(java.net.URL configFile) |
int |
size() |
java.util.Properties |
toProperties()
Converts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand
|
java.util.Properties |
toProperties(java.lang.String prefix)
Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix
|
java.lang.String |
toString() |
java.util.Collection |
values() |
java.io.Writer |
writeTo(java.io.Writer outArg)
Writes this config object into a String serialized representation which can later be parsed back using the parse()
method
|
getMetaClass, invokeMethod, setMetaClass, setPropertypublic ConfigObject(java.net.URL file)
public ConfigObject()
public java.net.URL getConfigFile()
public void setConfigFile(java.net.URL configFile)
public java.io.Writer writeTo(java.io.Writer outArg)
throws java.io.IOException
writeTo in interface WritableoutArg - the Writer to which this Writable should output its data.java.io.IOException - if an error occurred while outputting data to the writerWritable.writeTo(java.io.Writer)public java.lang.Object getProperty(java.lang.String name)
getProperty in interface GroovyObjectgetProperty in class GroovyObjectSupportname - the name of the property of interestpublic java.util.Map flatten()
public java.util.Map flatten(java.util.Map target)
flatten()public java.util.Map merge(ConfigObject other)
other - The ConfigObject to merge withpublic java.util.Properties toProperties()
public java.util.Properties toProperties(java.lang.String prefix)
prefix - The prefix to append before property entriespublic int size()
size in interface java.util.Mappublic boolean isEmpty()
isEmpty in interface java.util.Mappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Mappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Mappublic java.lang.Object get(java.lang.Object key)
get in interface java.util.Mappublic java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mappublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mappublic void putAll(java.util.Map m)
putAll in interface java.util.Mappublic void clear()
clear in interface java.util.Mappublic java.util.Set keySet()
keySet in interface java.util.Mappublic java.util.Collection values()
values in interface java.util.Mappublic java.util.Set entrySet()
entrySet in interface java.util.Mappublic ConfigObject clone()
clone in class java.lang.Objectpublic java.lang.Boolean isSet(java.lang.String option)
def config = new ConfigSlurper().parse("foo { password='' }")
assert config.foo.isSet('password')
assert config.foo.isSet('username') == false
The 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 otherwisepublic java.lang.String prettyPrint()
public java.lang.String toString()
toString in class java.lang.Object