public class ConfigObject extends GroovyObjectSupport
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constructor and description |
---|
ConfigObject
(URL file) |
ConfigObject
() |
Type | Name and description |
---|---|
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() |
Boolean |
isSet(String option) Checks if a config option is set. |
Set |
keySet() |
Map |
merge(ConfigObject other) Merges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject |
String |
prettyPrint() |
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 |
String |
toString() |
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 | Name |
---|---|
class GroovyObjectSupport |
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Returns a shallow copy of this ConfigObject, keys and configuration entries are not cloned.
A ConfigObject is a tree structure consisting of nested maps. This flattens the maps into a single level structure like a properties file
Flattens this ConfigObject populating the results into the target Map
Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non-existent keys
Checks if a config option is set. Example usage:
def config = new ConfigSlurper().parse("foo { password='' }") assert config.foo.isSet('password') assert config.foo.isSet('username') == falseThe 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
otherwiseMerges the given map with this ConfigObject overriding any matching configuration entries in this ConfigObject
other
- The ConfigObject to merge withConverts this ConfigObject into a the java.util.Properties format, flattening the tree structure beforehand
Converts this ConfigObject ino the java.util.Properties format, flatten the tree and prefixing all entries with the given prefix
prefix
- The prefix to append before property entriesWrites this config object into a String serialized representation which can later be parsed back using the parse() method
Copyright © 2003-2015 The Apache Software Foundation. All rights reserved.