Class ConfigMap
java.lang.Object
org.apache.juneau.config.internal.ConfigMap
- All Implemented Interfaces:
- ConfigStoreListener
Represents the parsed contents of a configuration.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionasMap()Returns the values in this config map as a map of maps.commit()Persist any changes made to this map and signal all listeners.Reads an entry from this map.Returns the keys of the entries in the specified section.Returns the listeners currently associated with this config map.getPreLines(String section) Returns the pre-lines on the specified section.Returns the keys of the entries in the specified section.booleanhasSection(String section) Returnstrue if this config has the specified section.Overwrites the contents of the config file.voidCalled when the physical contents of a config file have changed.register(ConfigEventListener listener) Registers an event listener on this map.removeEntry(String section, String key) Removes an entry.removeImport(String section, String importName) Not implemented.removeSection(String section) Removes a section.rollback()Does a rollback of any changes on this map currently in memory.setEntry(String section, String key, String value, String modifiers, String comment, List<String> preLines) Adds or overwrites an existing entry.Not implemented.setSection(String section, List<String> preLines) Adds a new section or replaces the pre-lines on an existing section.toString()unregister(ConfigEventListener listener) Unregisters an event listener from this map.Serializes this map to the specified writer.
- 
Constructor Details- 
ConfigMapConstructor.- Parameters:
- store- The config store.
- name- The config name.
- Throws:
- IOException- Thrown by underlying stream.
 
 
- 
- 
Method Details- 
getEntryReads an entry from this map.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- key- The entry key.
 Must not be- null .
- Returns:
- The entry, or null if the entry doesn't exist.
 
- 
getPreLinesReturns the pre-lines on the specified section.The pre-lines are all lines such as blank lines and comments that preceed a section. - Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- Returns:
- An unmodifiable list of lines, or null if the section doesn't exist.
 
- 
getSectionsReturns the keys of the entries in the specified section.- Returns:
- An unmodifiable set of keys.
 
- 
getKeysReturns the keys of the entries in the specified section.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- Returns:
- An unmodifiable set of keys, or an empty set if the section doesn't exist.
 
- 
hasSectionReturnstrue if this config has the specified section.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- Returns:
- true if this config has the specified section.
 
- 
setSectionAdds a new section or replaces the pre-lines on an existing section.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- preLines- The pre-lines on the section.
 If- null , the previous value will not be overwritten.
- Returns:
- This object.
 
- 
setEntrypublic ConfigMap setEntry(String section, String key, String value, String modifiers, String comment, List<String> preLines) Adds or overwrites an existing entry.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- key- The entry key.
 Must not be- null .
- value- The entry value.
 If- null , the previous value will not be overwritten.
- modifiers- Optional modifiers.
 If- null , the previous value will not be overwritten.
- comment- Optional comment.
 If- null , the previous value will not be overwritten.
- preLines- Optional pre-lines.
 If- null , the previous value will not be overwritten.
- Returns:
- This object.
 
- 
setImportNot implemented.- Parameters:
- section- The section name where to place the import statement.
 Must not be- null .
 Use blank for the default section.
- importName- The import name.
 Must not be- null .
- preLines- Optional comment and blank lines to add immediately before the import statement.
 If- null , previous pre-lines will not be replaced.
- Returns:
- This object.
 
- 
removeSectionRemoves a section.This eliminates all entries in the section as well. - Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- Returns:
- This object.
 
- 
removeEntryRemoves an entry.- Parameters:
- section- The section name.
 Must not be- null .
 Use blank to refer to the default section.
- key- The entry key.
 Must not be- null .
- Returns:
- This object.
 
- 
removeImportNot implemented.- Parameters:
- section- The section name where to place the import statement.
 Must not be- null .
 Use blank for the default section.
- importName- The import name.
 Must not be- null .
- Returns:
- This object.
 
- 
loadpublic ConfigMap load(String contents, boolean synchronous) throws IOException, InterruptedException Overwrites the contents of the config file.- Parameters:
- contents- The new contents of the config file.
- synchronous- Wait until the change has been persisted before returning this map.
- Returns:
- This object.
- Throws:
- IOException- Thrown by underlying stream.
- InterruptedException- Thread was interrupted.
 
- 
commitPersist any changes made to this map and signal all listeners.If the underlying contents of the file have changed, this will reload it and apply the changes on top of the modified file. Subsequent changes made to the underlying file will also be signaled to all listeners. We try saving the file up to 10 times. 
 If the file keeps changing on the file system, we throw an exception.- Returns:
- This object.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
registerRegisters an event listener on this map.- Parameters:
- listener- The new listener.
- Returns:
- This object.
 
- 
unregisterUnregisters an event listener from this map.- Parameters:
- listener- The listener to remove.
- Returns:
- This object.
 
- 
getListenersReturns the listeners currently associated with this config map.- Returns:
- The listeners currently associated with this config map.
 
- 
onChangeDescription copied from interface:ConfigStoreListenerCalled when the physical contents of a config file have changed.- Specified by:
- onChangein interface- ConfigStoreListener
- Parameters:
- newContents- The new config contents;
 
- 
toString
- 
asMapReturns the values in this config map as a map of maps.This is considered a snapshot copy of the config map. The returned map is modifiable, but modifications to the returned map are not reflected in the config map. - Returns:
- A copy of this config as a map of maps.
 
- 
writeToSerializes this map to the specified writer.- Parameters:
- w- The writer to serialize to.
- Returns:
- The same writer passed in.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
rollbackDoes a rollback of any changes on this map currently in memory.- Returns:
- This object.
 
 
-