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
ConstructorsModifierConstructorDescriptionprivate
Suppresses default constructor, ensuring non-instantiability. -
Method Summary
Modifier and TypeMethodDescriptionstatic Plist
Parse the contents ofplist
-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 theplist
-string provided byreader
and writes all elements to the listarray
.protected static void
parseDict
(PlistReader reader, Plist dict) Parses a dictionary entry,<dict>
, in theplist
-string provided byreader
and writes<key>
andplist
element 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 followingplist
elements:- <key>
- Name of tag: any valid String.
- <dict>
- Dictionary: Alternating
<key>
tags andplist
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.
- 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
true
andfalse
.
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 byreader
and writes<key>
andplist
element 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 overplist
tagsdict
- map for storing all pairs of<key>
andplist
element pairs.
-
parseArray
Parses an array entry,<array>
, in theplist
-string provided byreader
and writes all elements to the listarray
.Note: Invalid or unknown tags trigger error message on standard out.
- Parameters:
reader
- iterator overplist
tagsarray
- list for storing the array ofplist
elements.
-