Class PropertyListConfiguration
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.PropertyListConfiguration
- All Implemented Interfaces:
Cloneable,Configuration,EventSource,FileBasedConfiguration,HierarchicalConfiguration<ImmutableNode>,ImmutableConfiguration,ImmutableHierarchicalConfiguration,FileBased,SynchronizerSupport,InMemoryNodeModelSupport,NodeKeyResolver<ImmutableNode>,NodeModelSupport<ImmutableNode>
public class PropertyListConfiguration
extends BaseHierarchicalConfiguration
implements FileBasedConfiguration
NeXT / OpenStep style configuration. This configuration can read and write ASCII plist files. It supports the GNUStep
extension to specify date objects.
References:
Example:
{
foo = "bar";
array = ( value1, value2, value3 );
data = <4f3e0145ab>;
date = <*D2007-05-05 20:05:00 +0100>;
nested =
{
key1 = value1;
key2 = value;
nested =
{
foo = bar
}
}
}
- Since:
- 1.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA helper class for parsing and formatting date literals.private static final classA specialized date component parser implementation that deals with numeric calendar fields.private static final classA specialized date component parser implementation that deals with separator characters.private static final classA specialized date component parser implementation that deals with the time zone part of a date component.Nested classes/interfaces inherited from class org.apache.commons.configuration2.BaseHierarchicalConfiguration
BaseHierarchicalConfiguration.BuilderVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PropertyListConfiguration.DateComponentParserConstant for the separator parser for blanks between the parts.private static final PropertyListConfiguration.DateComponentParser[]An array with the component parsers for dealing with dates.private static final PropertyListConfiguration.DateComponentParserConstant for the separator parser for the date part.private static final intSize of the indentation for the generated file.private static final intConstant for the milliseconds of a minute.private static final intConstant for the minutes per hour.private static final charConstant for the padding character in the date format.private static final PropertyListConfiguration.DateComponentParserConstant for the separator parser for the time part.private static final intConstant for the length of a time zone.private static final StringConstant for the ID prefix for GMT time zones. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty PropertyListConfiguration object which can be used to synthesize a new plist file by adding values and then saving().Creates a new instance ofPropertyListConfigurationand copies the content of the specified configuration into this object.Creates a new instance ofPropertyListConfigurationwith the given root node. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPropertyInternal(String key, Object value) Adds the property with the specified key.(package private) static StringformatDate(Calendar cal) Returns a string representation for the date specified by the given calendar.(package private) static StringformatDate(Date date) Returns a string representation for the specified date.(package private) static DateParses a date in a format like<*D2002-03-22 11:30:00 +0100>.private voidprintNode(PrintWriter out, int indentLevel, ImmutableNode node, NodeHandler<ImmutableNode> handler) 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.(package private) StringQuote the specified string if necessary, that's if the string contains: a space character (' ', '\t', '\r', '\n') a quote '"' special characters in plist files ('(', ')', '{', '}', '=', ';', ',') Quotes within the string are escaped.voidReads the content of this object from the given reader.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
-
DATE_SEPARATOR_PARSER
Constant for the separator parser for the date part. -
TIME_SEPARATOR_PARSER
Constant for the separator parser for the time part. -
BLANK_SEPARATOR_PARSER
Constant for the separator parser for blanks between the parts. -
DATE_PARSERS
An array with the component parsers for dealing with dates. -
TIME_ZONE_PREFIX
Constant for the ID prefix for GMT time zones.- See Also:
-
MILLIS_PER_MINUTE
private static final int MILLIS_PER_MINUTEConstant for the milliseconds of a minute.- See Also:
-
MINUTES_PER_HOUR
private static final int MINUTES_PER_HOURConstant for the minutes per hour.- See Also:
-
INDENT_SIZE
private static final int INDENT_SIZESize of the indentation for the generated file.- See Also:
-
TIME_ZONE_LENGTH
private static final int TIME_ZONE_LENGTHConstant for the length of a time zone.- See Also:
-
PAD_CHAR
private static final char PAD_CHARConstant for the padding character in the date format.- See Also:
-
-
Constructor Details
-
PropertyListConfiguration
public PropertyListConfiguration()Creates an empty PropertyListConfiguration object which can be used to synthesize a new plist file by adding values and then saving(). -
PropertyListConfiguration
Creates a new instance ofPropertyListConfigurationand copies the content of the specified configuration into this object.- Parameters:
c- the configuration to copy- Since:
- 1.4
-
PropertyListConfiguration
PropertyListConfiguration(ImmutableNode root) Creates a new instance ofPropertyListConfigurationwith the given root node.- Parameters:
root- the root node
-
-
Method Details
-
formatDate
Returns a string representation for the date specified by the given calendar.- Parameters:
cal- the calendar with the initialized date- Returns:
- a string for this date
-
formatDate
Returns a string representation for the specified date.- Parameters:
date- the date- Returns:
- a string for this date
-
parseDate
Parses a date in a format like<*D2002-03-22 11:30:00 +0100>.- Parameters:
s- the string with the date to be parsed- Returns:
- the parsed date
- Throws:
ParseException- if an error occurred while parsing the string
-
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
-
printNode
private void printNode(PrintWriter out, int indentLevel, ImmutableNode node, NodeHandler<ImmutableNode> handler) 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. -
quoteString
Quote the specified string if necessary, that's if the string contains:- a space character (' ', '\t', '\r', '\n')
- a quote '"'
- special characters in plist files ('(', ')', '{', '}', '=', ';', ',')
Examples:
- abcd -> abcd
- ab cd -> "ab cd"
- foo"bar -> "foo\"bar"
- foo;bar -> "foo;bar"
-
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
-
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
-