Class PlistParser

Object
PlistParser

public class PlistParser extends Object
Basic parser for plist-files.

The primary purpose and motivation for PlistParser is to allow EvoLudo to save and restore the exact states of numerical or individual based models. The faithful storage of all information (including the state of the random number generator) allows to resume calculations without any information loss. For example, the state of some calculations is saved after some time. Then the restored calculations produce time series that are identical to the ones produced when continuing the original calculation. Naturally, this strong criterion no longer holds after any modifications of numerical schemes or the use of random numbers.

Author:
Christoph Hauert
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Suppresses default constructor, ensuring non-instantiability.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Plist
    parse(String string)
    Parse the contents of plist-file supplied as a String and return a Map with key and object associations.
    protected static void
    parseArray(PlistReader reader, List<Object> array)
    Parses an array entry, <array>, in the plist-string provided by reader and writes all elements to the list array.
    protected static void
    parseDict(PlistReader reader, Plist dict)
    Parses a dictionary entry, <dict>, in the plist-string provided by reader and writes <key> and plist element pairs to the lookup table dict.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlistParser

      private PlistParser()
      Suppresses default constructor, ensuring non-instantiability.
  • Method Details

    • parse

      public static Plist parse(String string)
      Parse the contents of plist-file supplied as a String and return a Map with key and object associations. The parses processes the following plist elements:
      <key>
      Name of tag: any valid String.
      <dict>
      Dictionary: Alternating <key> tags and plist elements (excluding <key>). Can be empty.
      <array>
      Array: Can contain any number of identical child plist elements (excluding <key>). Can be empty.
      <string>
      UTF-8 encoded string.
      <real>
      Floating point number: if the string ends with 'L' it is assumed to be a double encoded as a long.
      Important:
      • using long to encode floating point numbers is not part of the plist specification. However, only bitwise encoding can guarantee faithful writing and restoring of floating point numbers.
      • cannot use Double.valueOf(String) because not implemented by GWT.
      <integer>
      Integer number: any string that Integer.parseInt(String) can process, i.e. limited to 32bits.
      <true/>, <false/>
      Boolean numbers: tag represents the boolean values true and false.

      Not implemented are currently:

      <data>
      Base64 encoded data.
      <date>
      ISO 8601 formatted string.

      Note: Invalid or unknown tags trigger error message on standard out.

      Parameters:
      string - contents of plist-file
      Returns:
      map with key and element associations
    • parseDict

      protected static void parseDict(PlistReader reader, Plist dict)
      Parses a dictionary entry, <dict>, in the plist-string provided by reader and writes <key> and plist element pairs to the lookup table dict. Note, dictionaries may contain <dict> elements, which results in recursive calls to this method.

      Note: Invalid or unknown tags trigger error message on standard out.

      Parameters:
      reader - iterator over plist tags
      dict - map for storing all pairs of <key> and plist element pairs.
    • parseArray

      protected static void parseArray(PlistReader reader, List<Object> array)
      Parses an array entry, <array>, in the plist-string provided by reader and writes all elements to the list array.

      Note: Invalid or unknown tags trigger error message on standard out.

      Parameters:
      reader - iterator over plist tags
      array - list for storing the array of plist elements.