Groovy 2.2.1

groovy.util
[Java] Class ConfigObject

java.lang.Object
  groovy.lang.GroovyObjectSupport
      groovy.util.ConfigObject
All Implemented Interfaces:
Writable, Map, 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(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(Object key)

boolean containsValue(Object value)

Set entrySet()

Map flatten()

A ConfigObject is a tree structure consisting of nested maps.

Map flatten(Map target)

Flattens this ConfigObject populating the results into the target Map

Object get(Object key)

URL getConfigFile()

Object getProperty(String name)

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

boolean isEmpty()

Set keySet()

Map merge(ConfigObject other)

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

Object put(Object key, Object value)

void putAll(Map m)

Object remove(Object key)

void setConfigFile(URL configFile)

int size()

Properties toProperties()

Converts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand

Properties toProperties(String prefix)

Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix

Collection values()

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 GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

ConfigObject

public ConfigObject(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(Object key)


containsValue

public boolean containsValue(Object value)


entrySet

public Set entrySet()


flatten

public 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 Map flatten(Map target)
Flattens this ConfigObject populating the results into the target Map
See Also:
ConfigObject.flatten


get

public Object get(Object key)


getConfigFile

public URL getConfigFile()


getProperty

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


isEmpty

public boolean isEmpty()


keySet

public Set keySet()


merge

public 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 Object put(Object key, Object value)


putAll

public void putAll(Map m)


remove

public Object remove(Object key)


setConfigFile

public void setConfigFile(URL configFile)


size

public int size()


toProperties

public 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 Properties toProperties(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 Collection values()


writeTo

public Writer writeTo(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


 

Copyright © 2003-2013 The Codehaus. All rights reserved.