Class 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
  • Field Details

  • 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

      public PropertyListConfiguration(HierarchicalConfiguration<ImmutableNode> c)
      Creates a new instance of PropertyListConfiguration and 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 of PropertyListConfiguration with the given root node.
      Parameters:
      root - the root node
  • Method Details

    • formatDate

      static String formatDate(Calendar cal)
      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

      static String formatDate(Date date)
      Returns a string representation for the specified date.
      Parameters:
      date - the date
      Returns:
      a string for this date
    • parseDate

      static Date parseDate(String s) throws ParseException
      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

      private static Map<String,Object> transformMap(Map<?,?> src)
      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

      protected void addPropertyInternal(String key, Object value)
      Description copied from class: AbstractHierarchicalConfiguration
      Adds the property with the specified key. This task will be delegated to the associated ExpressionEngine, so the passed in key must match the requirements of this implementation.
      Overrides:
      addPropertyInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
      Parameters:
      key - the key of the new property
      value - 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

      private void printValue(PrintWriter out, int indentLevel, Object value)
      Append a value to the writer, indented according to a specific level.
    • quoteString

      String quoteString(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.

      Examples:

      • abcd -> abcd
      • ab cd -> "ab cd"
      • foo"bar -> "foo\"bar"
      • foo;bar -> "foo;bar"
    • read

      public void read(Reader in) throws ConfigurationException
      Description copied from interface: FileBased
      Reads the content of this object from the given reader. Client code should not call this method directly, but use a FileHandler for reading data.
      Specified by:
      read in interface FileBased
      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

      protected void setPropertyInternal(String key, Object value)
      Description copied from class: AbstractHierarchicalConfiguration
      Sets the value of the specified property.
      Overrides:
      setPropertyInternal in class AbstractHierarchicalConfiguration<ImmutableNode>
      Parameters:
      key - the key of the property to set
      value - the new value of this property
    • write

      public void write(Writer out) throws ConfigurationException
      Description copied from interface: FileBased
      Writes the content of this object to the given writer. Client code should not call this method directly, but use a FileHandler for writing data.
      Specified by:
      write in interface FileBased
      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