|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.HierarchicalConfiguration
org.apache.commons.configuration.AbstractHierarchicalFileConfiguration
org.apache.commons.configuration.plist.PropertyListConfiguration
public class PropertyListConfiguration
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 } } }
Nested Class Summary | |
---|---|
private static class |
PropertyListConfiguration.DateComponentParser
A helper class for parsing and formatting date literals. |
private static class |
PropertyListConfiguration.DateFieldParser
A specialized date component parser implementation that deals with numeric calendar fields. |
private static class |
PropertyListConfiguration.DateSeparatorParser
A specialized date component parser implementation that deals with separator characters. |
private static class |
PropertyListConfiguration.DateTimeZoneParser
A 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.configuration.AbstractHierarchicalFileConfiguration |
---|
AbstractHierarchicalFileConfiguration.FileConfigurationDelegate |
Nested classes/interfaces inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
---|
HierarchicalConfiguration.BuilderVisitor, HierarchicalConfiguration.Node, HierarchicalConfiguration.NodeVisitor |
Field Summary | |
---|---|
private static PropertyListConfiguration.DateComponentParser |
BLANK_SEPARATOR_PARSER
Constant for the separator parser for blanks between the parts. |
private static PropertyListConfiguration.DateComponentParser[] |
DATE_PARSERS
An array with the component parsers for dealing with dates. |
private static PropertyListConfiguration.DateComponentParser |
DATE_SEPARATOR_PARSER
Constant for the separator parser for the date part. |
private static int |
INDENT_SIZE
Size of the indentation for the generated file. |
private static int |
MILLIS_PER_MINUTE
Constant for the milliseconds of a minute. |
private static int |
MINUTES_PER_HOUR
Constant for the minutes per hour. |
private static char |
PAD_CHAR
Constant for the padding character in the date format. |
private static long |
serialVersionUID
The serial version UID. |
private static PropertyListConfiguration.DateComponentParser |
TIME_SEPARATOR_PARSER
Constant for the separator parser for the time part. |
private static int |
TIME_ZONE_LENGTH
Constant for the length of a time zone. |
private static java.lang.String |
TIME_ZONE_PREFIX
Constant for the ID prefix for GMT time zones. |
Fields inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
---|
EVENT_ADD_NODES, EVENT_CLEAR_TREE, EVENT_SUBNODE_CHANGED |
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration |
---|
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN |
Constructor Summary | |
---|---|
PropertyListConfiguration()
Creates an empty PropertyListConfiguration object which can be used to synthesize a new plist file by adding values and then saving(). |
|
PropertyListConfiguration(java.io.File file)
Creates and loads the property list from the specified file. |
|
PropertyListConfiguration(HierarchicalConfiguration c)
Creates a new instance of PropertyListConfiguration and
copies the content of the specified configuration into this object. |
|
PropertyListConfiguration(java.lang.String fileName)
Creates and loads the property list from the specified file. |
|
PropertyListConfiguration(java.net.URL url)
Creates and loads the property list from the specified URL. |
Method Summary | |
---|---|
void |
addProperty(java.lang.String key,
java.lang.Object value)
Add a property to the configuration. |
(package private) static java.lang.String |
formatDate(java.util.Calendar cal)
Returns a string representation for the date specified by the given calendar. |
(package private) static java.lang.String |
formatDate(java.util.Date date)
Returns a string representation for the specified date. |
void |
load(java.io.Reader in)
Load the configuration from the specified reader. |
(package private) static java.util.Date |
parseDate(java.lang.String s)
Parses a date in a format like <*D2002-03-22 11:30:00 +0100> . |
private void |
printNode(java.io.PrintWriter out,
int indentLevel,
HierarchicalConfiguration.Node node)
Append a node to the writer, indented according to a specific level. |
private void |
printValue(java.io.PrintWriter out,
int indentLevel,
java.lang.Object value)
Append a value to the writer, indented according to a specific level. |
(package private) java.lang.String |
quoteString(java.lang.String s)
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 ('(', ')', '{', '}', '=', ';', ',') Quotes within the string are escaped. |
void |
save(java.io.Writer out)
Save the configuration to the specified writer. |
void |
setProperty(java.lang.String key,
java.lang.Object value)
Sets the value of the specified property. |
Methods inherited from class org.apache.commons.configuration.AbstractHierarchicalFileConfiguration |
---|
addNodes, addPropertyDirect, clearProperty, clearTree, configurationChanged, containsKey, createDelegate, fetchNodeList, getBasePath, getDelegate, getEncoding, getFile, getFileName, getKeys, getKeys, getProperty, getReloadingStrategy, getURL, isAutoSave, isEmpty, load, load, load, load, load, load, reload, save, save, save, save, save, save, setAutoSave, setBasePath, setDelegate, setEncoding, setFile, setFileName, setReloadingStrategy, setURL, subnodeConfigurationChanged |
Methods inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
---|
clearNode, clearNode, clearReferences, clone, configurationAt, configurationAt, configurationsAt, createAddPath, createNode, createSubnodeConfiguration, createSubnodeConfiguration, fetchAddNode, findLastPathNode, findPropertyNodes, getDefaultExpressionEngine, getExpressionEngine, getMaxIndex, getRoot, getRootNode, interpolatedConfiguration, nodeDefined, nodeDefined, removeNode, removeNode, setDefaultExpressionEngine, setExpressionEngine, setRoot, setRootNode, subset |
Methods inherited from class org.apache.commons.configuration.event.EventSource |
---|
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.configuration.Configuration |
---|
clear, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getList, getLong, getLong, getLong, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, subset |
Field Detail |
---|
private static final PropertyListConfiguration.DateComponentParser DATE_SEPARATOR_PARSER
private static final PropertyListConfiguration.DateComponentParser TIME_SEPARATOR_PARSER
private static final PropertyListConfiguration.DateComponentParser BLANK_SEPARATOR_PARSER
private static final PropertyListConfiguration.DateComponentParser[] DATE_PARSERS
private static final java.lang.String TIME_ZONE_PREFIX
private static final long serialVersionUID
private static final int MILLIS_PER_MINUTE
private static final int MINUTES_PER_HOUR
private static final int INDENT_SIZE
private static final int TIME_ZONE_LENGTH
private static final char PAD_CHAR
Constructor Detail |
---|
public PropertyListConfiguration()
public PropertyListConfiguration(HierarchicalConfiguration c)
PropertyListConfiguration
and
copies the content of the specified configuration into this object.
c
- the configuration to copypublic PropertyListConfiguration(java.lang.String fileName) throws ConfigurationException
fileName
- The name of the plist file to load.
ConfigurationException
- Error while loading the plist filepublic PropertyListConfiguration(java.io.File file) throws ConfigurationException
file
- The plist file to load.
ConfigurationException
- Error while loading the plist filepublic PropertyListConfiguration(java.net.URL url) throws ConfigurationException
url
- The location of the plist file to load.
ConfigurationException
- Error while loading the plist fileMethod Detail |
---|
public void setProperty(java.lang.String key, java.lang.Object value)
HierarchicalConfiguration
setProperty
in interface Configuration
setProperty
in class AbstractHierarchicalFileConfiguration
key
- the key of the property to setvalue
- the new value of this propertypublic void addProperty(java.lang.String key, java.lang.Object value)
Configuration
resource.loader = fileis already present in the configuration and you call
addProperty("resource.loader", "classpath")Then you will end up with a List like the following:
["file", "classpath"]
addProperty
in interface Configuration
addProperty
in class AbstractConfiguration
key
- The key to add the property to.value
- The value to add.public void load(java.io.Reader in) throws ConfigurationException
FileConfiguration
in
- the reader
ConfigurationException
- if an error occurs during the load operationpublic void save(java.io.Writer out) throws ConfigurationException
FileConfiguration
out
- the writer
ConfigurationException
- if an error occurs during the save operationprivate void printNode(java.io.PrintWriter out, int indentLevel, HierarchicalConfiguration.Node node)
private void printValue(java.io.PrintWriter out, int indentLevel, java.lang.Object value)
java.lang.String quoteString(java.lang.String s)
Examples:
static java.util.Date parseDate(java.lang.String s) throws ParseException
<*D2002-03-22 11:30:00 +0100>
.
s
- the string with the date to be parsed
ParseException
- if an error occurred while parsing the stringstatic java.lang.String formatDate(java.util.Calendar cal)
cal
- the calendar with the initialized date
static java.lang.String formatDate(java.util.Date date)
date
- the date
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |