Class XMLPropertyListConfiguration
java.lang.Object
org.apache.commons.configuration2.event.BaseEventSource
org.apache.commons.configuration2.AbstractConfiguration
org.apache.commons.configuration2.AbstractHierarchicalConfiguration<ImmutableNode>
org.apache.commons.configuration2.BaseHierarchicalConfiguration
org.apache.commons.configuration2.plist.XMLPropertyListConfiguration
- All Implemented Interfaces:
Cloneable,Configuration,EventSource,FileBasedConfiguration,HierarchicalConfiguration<ImmutableNode>,ImmutableConfiguration,ImmutableHierarchicalConfiguration,FileBased,FileLocatorAware,SynchronizerSupport,InMemoryNodeModelSupport,NodeKeyResolver<ImmutableNode>,NodeModelSupport<ImmutableNode>
public class XMLPropertyListConfiguration
extends BaseHierarchicalConfiguration
implements FileBasedConfiguration, FileLocatorAware
Property list file (plist) in XML FORMAT as used by macOS X (http://www.apple.com/DTDs/PropertyList-1.0.dtd). This
configuration doesn't support the binary FORMAT used in OS X 10.4.
Example:
<?xml version="1.0"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="1.0">
<dict>
<key>string</key>
<string>value1</string>
<key>integer</key>
<integer>12345</integer>
<key>real</key>
<real>-123.45E-1</real>
<key>boolean</key>
<true/>
<key>date</key>
<date>2005-01-01T12:00:00Z</date>
<key>data</key>
<data>RHJhY28gRG9ybWllbnMgTnVucXVhbSBUaXRpbGxhbmR1cw==</data>
<key>array</key>
<array>
<string>value1</string>
<string>value2</string>
<string>value3</string>
</array>
<key>dictionnary</key>
<dict>
<key>key1</key>
<string>value1</string>
<key>key2</key>
<string>value2</string>
<key>key3</key>
<string>value3</string>
</dict>
<key>nested</key>
<dict>
<key>node1</key>
<dict>
<key>node2</key>
<dict>
<key>node3</key>
<string>value</string>
</dict>
</dict>
</dict>
</dict>
</plist>
- Since:
- 1.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classContainer for array elements.private static classA specialized builder class with addXXX methods to parse the typed data passed by the SAX handler.private final classSAX Handler to build the configuration nodes while the document is being parsed.Nested classes/interfaces inherited from class org.apache.commons.configuration2.BaseHierarchicalConfiguration
BaseHierarchicalConfiguration.BuilderVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final CharsetConstant for the encoding for binary data.private static final intSize of the indentation for the generated file.private FileLocatorTemporarily stores the current file location. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty XMLPropertyListConfiguration object which can be used to synthesize a new plist file by adding values and then saving().XMLPropertyListConfiguration(HierarchicalConfiguration<ImmutableNode> configuration) Creates a new instance ofXMLPropertyListConfigurationand copies the content of the specified configuration into this object.Creates a new instance ofXMLPropertyConfigurationwith the given root node. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPropertyInternal(String key, Object value) Adds the property with the specified key.voidinitFileLocator(FileLocator locator) Stores the current file locator.private voidprintNode(PrintWriter out, int indentLevel, ImmutableNode node) Append a node to the writer, indented according to a specific level.private voidprintValue(PrintWriter out, int indentLevel, Object value) Append a value to the writer, indented according to a specific level.voidReads the content of this object from the given reader.private voidsetPropertyDirect(String key, Object value) protected voidsetPropertyInternal(String key, Object value) Sets the value of the specified property.transformMap(Map<?, ?> src) Transform a map of arbitrary types into a map with string keys and object values.voidWrites the content of this object to the given writer.Methods inherited from class org.apache.commons.configuration2.BaseHierarchicalConfiguration
childConfigurationsAt, childConfigurationsAt, cloneNodeModel, configurationAt, configurationAt, configurationsAt, configurationsAt, createSubConfigurationForTrackedNode, getNodeModel, getSubConfigurationNodeSelector, getSubConfigurationParentModel, immutableChildConfigurationsAt, immutableConfigurationAt, immutableConfigurationAt, immutableConfigurationsAt, initSubConfigurationForThisParent, interpolatedConfiguration, subnodeConfigurationChanged, subsetMethods inherited from class org.apache.commons.configuration2.AbstractHierarchicalConfiguration
addNodes, addNodesInternal, addPropertyDirect, clearInternal, clearPropertyDirect, clearTree, clearTreeInternal, clone, containsKeyInternal, containsValueInternal, fetchNodeList, getExpressionEngine, getKeysInternal, getKeysInternal, getMaxIndex, getMaxIndexInternal, getModel, getPropertyInternal, getRootElementName, getRootElementNameInternal, isEmptyInternal, nodeDefined, nodeKey, resolveAddKey, resolveKey, resolveNodeKey, resolveUpdateKey, setExpressionEngine, sizeInternal, toStringMethods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, append, beginRead, beginWrite, clear, clearProperty, cloneInterpolator, contains, containsKey, containsValue, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, getList, getList, getList, getList, getListDelimiterHandler, getLogger, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setSynchronizer, setThrowExceptionOnMissing, size, unlockMethods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEventsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.configuration2.Configuration
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty, subsetMethods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
containsKey, containsValue, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getEnum, getEnum, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, sizeMethods inherited from interface org.apache.commons.configuration2.sync.SynchronizerSupport
getSynchronizer, lock, setSynchronizer, unlock
-
Field Details
-
INDENT_SIZE
private static final int INDENT_SIZESize of the indentation for the generated file.- See Also:
-
DATA_ENCODING
Constant for the encoding for binary data. -
locator
Temporarily stores the current file location.
-
-
Constructor Details
-
XMLPropertyListConfiguration
public XMLPropertyListConfiguration()Creates an empty XMLPropertyListConfiguration object which can be used to synthesize a new plist file by adding values and then saving(). -
XMLPropertyListConfiguration
Creates a new instance ofXMLPropertyListConfigurationand copies the content of the specified configuration into this object.- Parameters:
configuration- the configuration to copy- Since:
- 1.4
-
XMLPropertyListConfiguration
XMLPropertyListConfiguration(ImmutableNode root) Creates a new instance ofXMLPropertyConfigurationwith the given root node.- Parameters:
root- the root node
-
-
Method Details
-
transformMap
Transform a map of arbitrary types into a map with string keys and object values. All keys of the source map which are not of type String are dropped.- Parameters:
src- the map to be converted- Returns:
- the resulting map
-
addPropertyInternal
Description copied from class:AbstractHierarchicalConfigurationAdds the property with the specified key. This task will be delegated to the associatedExpressionEngine, so the passed in key must match the requirements of this implementation.- Overrides:
addPropertyInternalin classAbstractHierarchicalConfiguration<ImmutableNode>- Parameters:
key- the key of the new propertyvalue- the value of the new property
-
initFileLocator
Stores the current file locator. This method is called before I/O operations.- Specified by:
initFileLocatorin interfaceFileLocatorAware- Parameters:
locator- the currentFileLocator
-
printNode
Append a node to the writer, indented according to a specific level. -
printValue
Append a value to the writer, indented according to a specific level. -
read
Description copied from interface:FileBasedReads the content of this object from the given reader. Client code should not call this method directly, but use aFileHandlerfor reading data.- Specified by:
readin interfaceFileBased- Parameters:
in- the reader- Throws:
ConfigurationException- if a non-I/O related problem occurs, e.g. the data read does not have the expected format
-
setPropertyDirect
-
setPropertyInternal
Description copied from class:AbstractHierarchicalConfigurationSets the value of the specified property.- Overrides:
setPropertyInternalin classAbstractHierarchicalConfiguration<ImmutableNode>- Parameters:
key- the key of the property to setvalue- the new value of this property
-
write
Description copied from interface:FileBasedWrites the content of this object to the given writer. Client code should not call this method directly, but use aFileHandlerfor writing data.- Specified by:
writein interfaceFileBased- Parameters:
out- the writer- Throws:
ConfigurationException- if a non-I/O related problem occurs, e.g. the data read does not have the expected format
-