Class Plist
- All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringString constant for closing anarrayduring plist generation.(package private) static final StringString constant for opening anarrayduring plist generation.(package private) static final StringString constant for reporting differences in keys.(package private) booleanThe flag to indicate if the comparison should fail fast, i.e.(package private) static final StringString constant for closing anintegerentry during plist generation.(package private) static final StringString constant for opening anintegerentry during plist generation.(package private) static final StringString constant for closing ankeyentry during plist generation.(package private) static final StringString constant for opening anintegerentry during plist generation.(package private) static final intThe number of repeated messages to report before skipping further messages.private intThe number of issues found.private intThe number of numerical issues found.private intThe number of times a particular type of issue is reported before skipping any further ones.private static final intThe number of significant digits.private StringThe previous message.(package private) static final StringString constant for closing anrealentry during plist generation.(package private) static final StringString constant for opening anrealentry during plist generation.private intThe number of times the previous message was repeated.(package private) static final StringString constant for closing anstringentry during plist generation.(package private) static final StringString constant for opening anstringentry during plist generation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckRounding(Double ref, Double check) Check if the difference betweenrefandcheckis due to rounding errors.private voidcheckRounding(Double ref, Double check, Integer digits) Check if the difference betweenrefandcheckis due to rounding errors.intCompare this plist toplist.intdiff(Plist plist, Collection<String> skip) Compare this plist toplistbut ignore keys inclo.private StringHelper method for formatting output of differences in arrays.private voidHelper method to compare two plist-arrays.private voiddiffDict(Plist reference, Plist plist, Collection<String> skip) Helper method to compare two plist-dictionaries.private StringHelper method for formatting output of differences in plists.private StringdiffMeRefDelta(Double me, Double ref) Helper method for formatting output of differences in plists optimized forDoubleto also show the numerical difference.private static StringencodeArray(double[] array) Helper method to encodedoublearrayprivate static StringencodeArray(double[][] array) Helper method to encodedoublematrixprivate static StringencodeArray(double[] array, int len) Helper method to encode firstlenelements ofdoublearrayprivate static StringencodeArray(int[] array) Helper method to encodeintarrayprivate static StringencodeArray(int[] array, int len) Helper method to encode firstlenelements ofintarrayprivate static StringencodeArray(String[] array) Helper method to encodeStringarrayprivate static StringencodeArray(String[] array, int len) Helper method to encode firstlenelements ofStringarraystatic StringUtility method to encodebooleanwith tagkey.static StringUtility method to encodedoublewith tagkey.static StringUtility method to encodedoublearray with tagkey.static StringUtility method to encodedoublematrix with tagkey.static StringUtility method to encode firstlenentries ofdoublearray with tagkey.static StringUtility method to encodeintwith tagkey.static StringUtility method to encodeintarray with tagkey.static StringUtility method to encode firstlenentries ofintarray with tagkey.static StringUtility method to encodeStringwith tagkey.static StringUtility method to encodeStringarray with tagkey.static StringUtility method to encode firstlenentries ofStringarray with tagkey.booleanOverride equals for consistency with hashCode.booleanfailfast()Check if in fail-fast mode.voidfailfast(boolean failfast) Set the fail-fast mode to stop comparisons after the first issue encountered.intGet the number of issues found.intGet the number of major issues found.intGet the number of minor issues found (most likely numerical).inthashCode()Override hashCode to only use the actual plist content (HashMap entries).static double[]list2double(List<Double> list) Utility method to convert a list ofDouble's to an array ofdouble's.static int[]Utility method to convert a list ofInteger's to an array ofint's.private voidprocessDiff(String msg) Process a difference.voidquiet()Set quiet mode to suppress all differences.private voidreportDiff(String msg) Report a difference.voidverbose()Set verbose mode to report all differences.Methods inherited from class HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class AbstractMap
toString
-
Field Details
-
failFast
boolean failFastThe flag to indicate if the comparison should fail fast, i.e. after first issue encountered. -
N_REPEAT
static final int N_REPEATThe number of repeated messages to report before skipping further messages.- See Also:
-
ARRAY_OPEN
String constant for opening anarrayduring plist generation.- See Also:
-
ARRAY_CLOSE
String constant for closing anarrayduring plist generation.- See Also:
-
INTEGER_OPEN
String constant for opening anintegerentry during plist generation.- See Also:
-
INTEGER_CLOSE
String constant for closing anintegerentry during plist generation.- See Also:
-
KEY_OPEN
String constant for opening anintegerentry during plist generation.- See Also:
-
KEY_CLOSE
String constant for closing ankeyentry during plist generation.- See Also:
-
REAL_OPEN
String constant for opening anrealentry during plist generation.- See Also:
-
REAL_CLOSE
String constant for closing anrealentry during plist generation.- See Also:
-
STRING_OPEN
String constant for opening anstringentry during plist generation.- See Also:
-
STRING_CLOSE
String constant for closing anstringentry during plist generation.- See Also:
-
DIFF_KEY
-
PRECISION_DIGITS
private static final int PRECISION_DIGITSThe number of significant digits. This is used to distinguish between minor numerical issues and major differences.- See Also:
-
nIssues
private int nIssuesThe number of issues found. -
nNumerical
private int nNumericalThe number of numerical issues found. -
nRepeat
private int nRepeatThe number of times a particular type of issue is reported before skipping any further ones. -
prevmsg
The previous message. -
repeat
private int repeatThe number of times the previous message was repeated.
-
-
Constructor Details
-
Plist
public Plist()Construct a new plist.
-
-
Method Details
-
verbose
public void verbose()Set verbose mode to report all differences. -
quiet
public void quiet()Set quiet mode to suppress all differences. -
failfast
public boolean failfast()Check if in fail-fast mode.- Returns:
trueif fail-fast mode is set
-
failfast
public void failfast(boolean failfast) Set the fail-fast mode to stop comparisons after the first issue encountered.- Parameters:
failfast- the fail-fast-flag
-
getNIssues
public int getNIssues()Get the number of issues found.- Returns:
- the number of issues
-
getNMajor
public int getNMajor()Get the number of major issues found.- Returns:
- the number of issues
-
getNMinor
public int getNMinor()Get the number of minor issues found (most likely numerical).- Returns:
- the number of issues
-
diff
Compare this plist toplist.- Parameters:
plist- the plist to compare against- Returns:
- the number of differences
-
diff
Compare this plist toplistbut ignore keys inclo.- Parameters:
plist- the referencePlistto compare againstskip- the collection of keys to skip- Returns:
- the number of differences
-
hashCode
-
equals
-
diffDict
Helper method to compare two plist-dictionaries.- Parameters:
reference- the referencePlistplist- thePlistto checkskip- the collection of keys to skip
-
diffArray
-
checkRounding
-
checkRounding
-
processDiff
-
reportDiff
Report a difference. Nothing is reported if the message is a repetition of the previous message andnRepeathas been reached. If messages have been skipped a summary is reported before continuing with the next issue.- Parameters:
msg- the message to report
-
encodeKey
-
encodeKey
-
encodeKey
Utility method to encodedoublewith tagkey.Notes:
- floating point values are saved as
long's (bit strings) to avoid rounding errors when saving/restoring the state of the model. - cannot use
Double.toHexString(real)because GWT does not implement it.
- Parameters:
key- tag namereal-doublevalue- Returns:
- encoded String
- floating point values are saved as
-
encodeKey
-
encodeKey
-
encodeKey
-
encodeKey
Utility method to encodedoublearray with tagkey.Note: floating point values are saved as bit strings to avoid rounding errors when saving/restoring the state of the model.
- Parameters:
key- tag namearray-double[]value- Returns:
- encoded String
-
encodeKey
Utility method to encode firstlenentries ofdoublearray with tagkey.Note: floating point values are saved as bit strings to avoid rounding errors when saving/restoring the state of the model.
- Parameters:
key- tag namearray-double[]valuelen- number elements to encode- Returns:
- encoded String
-
encodeKey
Utility method to encodedoublematrix with tagkey.Note: floating point values are saved as bit strings to avoid rounding errors when saving/restoring the state of the model.
- Parameters:
key- tag namematrix-double[][]value- Returns:
- encoded String
-
encodeKey
-
encodeKey
-
encodeArray
Helper method to encodeintarray- Parameters:
array-int[]value- Returns:
- encoded String
-
encodeArray
Helper method to encode firstlenelements ofintarray- Parameters:
array-int[]valuelen- number elements to encode- Returns:
- encoded String
-
encodeArray
Helper method to encodedoublearrayNote: floating point values are saved as bit strings to avoid rounding errors when saving/restoring the state of the model.
- Parameters:
array-double[]value- Returns:
- encoded String
-
encodeArray
Helper method to encode firstlenelements ofdoublearrayNote: floating point values are saved as bit strings to avoid rounding errors when saving/restoring the state of the model.
- Parameters:
array-double[]valuelen- number elements to encode- Returns:
- encoded String
-
encodeArray
Helper method to encodedoublematrix- Parameters:
array-double[][]value- Returns:
- encoded String
-
encodeArray
-
encodeArray
-
diffMeRef
-
diffMeRefDelta
-
diffArray
-
list2int
-
list2double
-