Groovy Documentation

groovy.util
[Java] Class ConfigObject

java.lang.Object
  groovy.lang.GroovyObjectSupport
      groovy.util.ConfigObject
All Implemented Interfaces:
Writable, java.util.Map, java.lang.Cloneable

public class ConfigObject
extends GroovyObjectSupport

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.

Authors:
Graeme Rocher
Guillaume Laforge (rewrite in Java related to security constraints on Google App Engine)
Since:
1.5


Constructor Summary
ConfigObject(java.net.URL file)

ConfigObject()

 
Method Summary
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.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.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.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

 
Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

ConfigObject

public ConfigObject(java.net.URL file)


ConfigObject

public ConfigObject()


 
Method Detail

clear

public void clear()


clone

public ConfigObject clone()
Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned.
Returns:
a shallow copy of this ConfigObject


containsKey

public boolean containsKey(java.lang.Object key)


containsValue

public boolean containsValue(java.lang.Object value)


entrySet

public java.util.Set entrySet()


flatten

public java.util.Map flatten()
A ConfigObject is a tree structure consisting of nested maps. This flattens the maps into a single level structure like a properties file


flatten

public java.util.Map flatten(java.util.Map target)
Flattens this ConfigObject populating the results into the target Map
See Also:
ConfigObject.flatten


get

public java.lang.Object get(java.lang.Object key)


getConfigFile

public java.net.URL getConfigFile()


getProperty

public java.lang.Object getProperty(java.lang.String name)
Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existent keys


isEmpty

public boolean isEmpty()


keySet

public java.util.Set keySet()


merge

public java.util.Map merge(ConfigObject other)
Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
Parameters:
other - The ConfigObject to merge with
Returns:
The result of the merge


put

public java.lang.Object put(java.lang.Object key, java.lang.Object value)


putAll

public void putAll(java.util.Map m)


remove

public java.lang.Object remove(java.lang.Object key)


setConfigFile

public void setConfigFile(java.net.URL configFile)


size

public int size()


toProperties

public java.util.Properties toProperties()
Converts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand
Returns:
A java.util.Properties instance


toProperties

public 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
Parameters:
prefix - The prefix to append before property entries
Returns:
A java.util.Properties instance


values

public java.util.Collection values()


writeTo

public 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
See Also:
Writable.writeTo


 

Groovy Documentation