Class ZonePrinterParser.SubstringTree
- Enclosing class:
- ZonePrinterParser
For example, to parse America/Denver we can look at the first two character "Am". We then notice that the shortest time-zone that starts with Am is America/Nome which is 12 characters long. Checking the first 12 characters of America/Denver giver America/Denv which is a substring of only 1 time-zone: America/Denver. Thus, with just 3 comparisons that match can be found.
This structure maps substrings to substrings of a longer length. Each node of the tree contains a length and a map of valid substrings to sub-nodes. The parser gets the length from the root node. It then extracts a substring of that length from the parseText. If the map contains the substring, it is set as the possible time-zone and the sub-node for that substring is retrieved. The process continues until the substring is no longer found, at which point the matched text is checked against the real time-zones.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final int
The length of the substring this node of the tree contains.private final Map<String,
ZonePrinterParser.SubstringTree> Map of a substring to a set of substrings that contain the key. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Values must be added from shortest to longest.private ZonePrinterParser.SubstringTree
-
Field Details
-
length
final int lengthThe length of the substring this node of the tree contains. Subtrees will have a longer length. -
substringMap
Map of a substring to a set of substrings that contain the key.
-
-
Constructor Details
-
SubstringTree
private SubstringTree(int length) Constructor.- Parameters:
length
- the length of this tree
-
-
Method Details
-
get
-
add
Values must be added from shortest to longest.- Parameters:
newSubstring
- the substring to add, not null
-