Package javax.time.calendar.format
Class ZonePrinterParser
- java.lang.Object
-
- javax.time.calendar.format.ZonePrinterParser
-
- All Implemented Interfaces:
DateTimeParser,DateTimePrinter
final class ZonePrinterParser extends java.lang.Object implements DateTimePrinter, DateTimeParser
Prints or parses a zone offset.ZonePrinterParser is immutable and thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classZonePrinterParser.SubstringTreeModel a tree of substrings to make the parsing easier.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Set<java.lang.String>preparedIDsThe cached IDs.private static ZonePrinterParser.SubstringTreepreparedTreeThe cached tree to speed up parsing.private DateTimeFormatterBuilder.TextStyletextStyleThe text style to output, null means the id.
-
Constructor Summary
Constructors Constructor Description ZonePrinterParser()Constructor.ZonePrinterParser(DateTimeFormatterBuilder.TextStyle textStyle)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisPrintDataAvailable(Calendrical calendrical)Checks if the calendrical contains the data necessary to be printed.intparse(DateTimeParseContext context, java.lang.String parseText, int position)This implementation looks for the longest matching string.private static ZonePrinterParser.SubstringTreeprepareParser(java.util.Set<java.lang.String> availableIDs)Builds an optimized parsing tree.voidprint(Calendrical calendrical, java.lang.Appendable appendable, DateTimeFormatSymbols symbols)Prints the calendrical object to the appendable.java.lang.StringtoString()
-
-
-
Field Detail
-
textStyle
private final DateTimeFormatterBuilder.TextStyle textStyle
The text style to output, null means the id.
-
preparedTree
private static ZonePrinterParser.SubstringTree preparedTree
The cached tree to speed up parsing.
-
preparedIDs
private static java.util.Set<java.lang.String> preparedIDs
The cached IDs.
-
-
Constructor Detail
-
ZonePrinterParser
ZonePrinterParser()
Constructor.
-
ZonePrinterParser
ZonePrinterParser(DateTimeFormatterBuilder.TextStyle textStyle)
Constructor.- Parameters:
textStyle- the test style to output, not null
-
-
Method Detail
-
print
public void print(Calendrical calendrical, java.lang.Appendable appendable, DateTimeFormatSymbols symbols) throws java.io.IOException
Prints the calendrical object to the appendable.- Specified by:
printin interfaceDateTimePrinter- Parameters:
calendrical- the calendrical to print, not nullappendable- the appendable to add to, not nullsymbols- the formatting symbols to use, not null- Throws:
java.io.IOException- if the append throws an exception
-
isPrintDataAvailable
public boolean isPrintDataAvailable(Calendrical calendrical)
Checks if the calendrical contains the data necessary to be printed.The implementation should not check the validity of the data, just whether there is sufficient data to attempt a print.
- Specified by:
isPrintDataAvailablein interfaceDateTimePrinter- Parameters:
calendrical- the calendrical to check, not null- Returns:
- true if the calendrical can be printed, false if not
-
parse
public int parse(DateTimeParseContext context, java.lang.String parseText, int position)
This implementation looks for the longest matching string. For example, parsing Etc/GMT-2 will return Etc/GMC-2 rather than just Etc/GMC although both are valid.This implementation uses a tree to search for valid time-zone names in the parseText. The top level node of the tree has a length equal to the length of the shortest time-zone as well as the beginning characters of all other time-zones.
- Specified by:
parsein interfaceDateTimeParser- Parameters:
context- the context to use and parse into, not nullparseText- the input text to parse, not nullposition- the position to start parsing at, from 0 to the text length- Returns:
- the new parse position, where negative means an error with the error position encoded using the complement ~ operator
-
prepareParser
private static ZonePrinterParser.SubstringTree prepareParser(java.util.Set<java.lang.String> availableIDs)
Builds an optimized parsing tree.- Parameters:
availableIDs- the available IDs, not null, not empty- Returns:
- the tree, never null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-