Class PlistParser
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
ConstructorsModifierConstructorDescriptionprivateSuppresses default constructor, ensuring non-instantiability. -
Method Summary
Modifier and TypeMethodDescriptionstatic PlistParse the contents ofplist-file supplied as a String and return a Map with key and object associations.protected static voidparseArray(PlistReader reader, List<Object> array) Parses an array entry,<array>, in theplist-string provided byreaderand writes all elements to the listarray.protected static voidparseDict(PlistReader reader, Plist dict) Parses a dictionary entry,<dict>, in theplist-string provided byreaderand writes<key>andplistelement pairs to the lookup tabledict.
-
Constructor Details
-
PlistParser
private PlistParser()Suppresses default constructor, ensuring non-instantiability.
-
-
Method Details
-
parse
Parse the contents ofplist-file supplied as a String and return a Map with key and object associations. The parses processes the followingplistelements:- <key>
- Name of tag: any valid String.
- <dict>
- Dictionary: Alternating
<key>tags andplistelements (excluding<key>). Can be empty. - <array>
- Array: Can contain any number of identical child
plistelements (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
plistspecification. However, only bitwise encoding can guarantee faithful writing and restoring of floating point numbers. - cannot use
Double.valueOf(String)because not implemented by GWT.
- using long to encode floating point numbers is not part of the
- <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
trueandfalse.
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 ofplist-file- Returns:
- map with key and element associations
-
parseDict
Parses a dictionary entry,<dict>, in theplist-string provided byreaderand writes<key>andplistelement pairs to the lookup tabledict. 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 overplisttagsdict- map for storing all pairs of<key>andplistelement pairs.
-
parseArray
Parses an array entry,<array>, in theplist-string provided byreaderand writes all elements to the listarray.Note: Invalid or unknown tags trigger error message on standard out.
- Parameters:
reader- iterator overplisttagsarray- list for storing the array ofplistelements.
-