groovy.util
Class ConfigObject

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 existance of "real" entries.

author:
Graeme Rocher
since:
1.1

Field Summary
 def KEYWORDS
           
 def TAB_CHARACTER
           
 URL configFile
           
 
Constructor Summary
ConfigObject(URL file)
            The config file that was used when parsing this ConfigObject
ConfigObject()
           
 
Method Summary
def convertValuesToString(def props)
          
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
def getProperty(String name)
           Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existant keys
Map merge(ConfigObject other)
           Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
def merge(Map config, Map other)
          
def populate(def suffix, def config, def map)
          
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
def writeConfig(String prefix, ConfigObject map, def out, Integer tab, boolean apply)
          
def writeNode(def key, def space, def tab, def value, def out)
          
Writer writeTo(Writer outArg)
           Writes this config object into a String serialized representation which can later be parsed back using the parse() method
def writeValue(def key, def space, def prefix, def value, def out)
          
 

Constructor Detail

ConfigObject

public ConfigObject(URL file)
The config file that was used when parsing this ConfigObject


ConfigObject

public ConfigObject()


Method Detail

convertValuesToString

def convertValuesToString(def props)


flatten

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

Map flatten(Map target)
Flattens this ConfigObject populating the results into the target Map
see:
ConfigObject#flatten()


getProperty

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


merge

Map merge(ConfigObject other)
Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
param:
other The ConfigObject to merge with
return:
The result of the merge


merge

def merge(Map config, Map other)


populate

def populate(def suffix, def config, def map)


toProperties

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


toProperties

Properties toProperties(String prefix)
Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix
param:
prefix The prefix to append before property entries
return:
A java.util.Properties instance


writeConfig

def writeConfig(String prefix, ConfigObject map, def out, Integer tab, boolean apply)


writeNode

def writeNode(def key, def space, def tab, def value, def out)


writeTo

Writer writeTo(Writer outArg)
Writes this config object into a String serialized representation which can later be parsed back using the parse() method
see:
Writable#writeTo
see:
#parse(URL)


writeValue

def writeValue(def key, def space, def prefix, def value, def out)