Groovy Documentation

groovy.util
[Groovy] Class ConfigObject

java.lang.Object
  java.util.AbstractMap
      java.util.HashMap
          java.util.LinkedHashMap
              groovy.util.ConfigObject
All Implemented Interfaces:
Writable

class ConfigObject
extends java.util.LinkedHashMap

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
Since:
1.5


Property Summary
static java.lang.Object KEYWORDS

static java.lang.Object TAB_CHARACTER

java.net.URL configFile

The config file that was used when parsing this ConfigObject

 
Constructor Summary
ConfigObject(java.net.URL file)

ConfigObject()

 
Method Summary
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 getProperty(java.lang.String name)

Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existent keys

java.util.Map merge(ConfigObject other)

Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject

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.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 java.util.LinkedHashMap
java.util.LinkedHashMap#get(java.lang.Object), java.util.LinkedHashMap#clear(), java.util.LinkedHashMap#containsValue(java.lang.Object), java.util.LinkedHashMap#put(java.lang.Object, java.lang.Object), java.util.LinkedHashMap#values(), java.util.LinkedHashMap#clone(), java.util.LinkedHashMap#size(), java.util.LinkedHashMap#isEmpty(), java.util.LinkedHashMap#remove(java.lang.Object), java.util.LinkedHashMap#entrySet(), java.util.LinkedHashMap#putAll(java.util.Map), java.util.LinkedHashMap#keySet(), java.util.LinkedHashMap#containsKey(java.lang.Object), java.util.LinkedHashMap#equals(java.lang.Object), java.util.LinkedHashMap#toString(), java.util.LinkedHashMap#hashCode(), java.util.LinkedHashMap#wait(long), java.util.LinkedHashMap#wait(long, int), java.util.LinkedHashMap#wait(), java.util.LinkedHashMap#getClass(), java.util.LinkedHashMap#notify(), java.util.LinkedHashMap#notifyAll()
 
Methods inherited from class java.util.HashMap
java.util.HashMap#get(java.lang.Object), java.util.HashMap#put(java.lang.Object, java.lang.Object), java.util.HashMap#values(), java.util.HashMap#clone(), java.util.HashMap#clear(), java.util.HashMap#size(), java.util.HashMap#isEmpty(), java.util.HashMap#remove(java.lang.Object), java.util.HashMap#entrySet(), java.util.HashMap#putAll(java.util.Map), java.util.HashMap#keySet(), java.util.HashMap#containsValue(java.lang.Object), java.util.HashMap#containsKey(java.lang.Object), java.util.HashMap#equals(java.lang.Object), java.util.HashMap#toString(), java.util.HashMap#hashCode(), java.util.HashMap#wait(long), java.util.HashMap#wait(long, int), java.util.HashMap#wait(), java.util.HashMap#getClass(), java.util.HashMap#notify(), java.util.HashMap#notifyAll()
 

Property Detail

KEYWORDS

static final java.lang.Object KEYWORDS


TAB_CHARACTER

static final java.lang.Object TAB_CHARACTER


configFile

java.net.URL configFile
The config file that was used when parsing this ConfigObject


 
Constructor Detail

ConfigObject

ConfigObject(java.net.URL file)


ConfigObject

ConfigObject()


 
Method Detail

flatten

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

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


getProperty

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


merge

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


toProperties

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

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


writeTo

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