Class FrequencyValidator
java.lang.Object
TwoColumnValidator
FrequencyValidator
- All Implemented Interfaces:
- Validator
public class FrequencyValidator
- extends TwoColumnValidator
Validator for parsing symbol-frequency pairs.
If valid, produces ValidatorResult having result type LinkedHashMap<String,Integer>.
Entries should be given one per line using format as:
a 25
b 76
e 135
Blank lines are ignored. Lines with only a frequency are presumed
to have string " " as the symbol.
FreqValidator ensures that symbols are unique and frequencies are positive integers.
Note that symbols can be any distinct strings (not just characters).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FrequencyValidator
public FrequencyValidator()
parse
public LinkedHashMap<String,Integer> parse(String original)
throws ValidatorException
- Parses symbol-frequency data.
Assumes format described in class overview.
- Specified by:
parse
in interface Validator
- Overrides:
parse
in class TwoColumnValidator
- Parameters:
original
- String
- Returns:
- LinkedHashMap<String,Integer> describing frequency values
- Throws:
ValidatorException
- if frequencies are not positive integers, or if
any error conditions detected through TwoColumnValidator.parse(String)