Package org.threeten.bp.format
Class DateTimeFormatterBuilder.ZoneIdPrinterParser
- java.lang.Object
-
- org.threeten.bp.format.DateTimeFormatterBuilder.ZoneIdPrinterParser
-
- All Implemented Interfaces:
DateTimeFormatterBuilder.DateTimePrinterParser
- Enclosing class:
- DateTimeFormatterBuilder
static final class DateTimeFormatterBuilder.ZoneIdPrinterParser extends java.lang.Object implements DateTimeFormatterBuilder.DateTimePrinterParser
Prints or parses a zone ID.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDateTimeFormatterBuilder.ZoneIdPrinterParser.SubstringTreeModel a tree of substrings to make the parsing easier.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map.Entry<java.lang.Integer,DateTimeFormatterBuilder.ZoneIdPrinterParser.SubstringTree>cachedSubstringTreeThe cached tree to speed up parsing.private java.lang.Stringdescriptionprivate TemporalQuery<ZoneId>query
-
Constructor Summary
Constructors Constructor Description ZoneIdPrinterParser(TemporalQuery<ZoneId> query, java.lang.String description)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ZoneIdconvertToZone(java.util.Set<java.lang.String> regionIds, java.lang.String parsedZoneId, boolean caseSensitive)intparse(DateTimeParseContext context, java.lang.CharSequence text, int position)This implementation looks for the longest matching string.private intparsePrefixedOffset(DateTimeParseContext context, java.lang.CharSequence text, int prefixPos, int position)private static DateTimeFormatterBuilder.ZoneIdPrinterParser.SubstringTreeprepareParser(java.util.Set<java.lang.String> availableIDs)Builds an optimized parsing tree.booleanprint(DateTimePrintContext context, java.lang.StringBuilder buf)Prints the date-time object to the buffer.java.lang.StringtoString()
-
-
-
Field Detail
-
query
private final TemporalQuery<ZoneId> query
-
description
private final java.lang.String description
-
cachedSubstringTree
private static volatile java.util.Map.Entry<java.lang.Integer,DateTimeFormatterBuilder.ZoneIdPrinterParser.SubstringTree> cachedSubstringTree
The cached tree to speed up parsing.
-
-
Constructor Detail
-
ZoneIdPrinterParser
ZoneIdPrinterParser(TemporalQuery<ZoneId> query, java.lang.String description)
-
-
Method Detail
-
print
public boolean print(DateTimePrintContext context, java.lang.StringBuilder buf)
Description copied from interface:DateTimeFormatterBuilder.DateTimePrinterParserPrints the date-time object to the buffer.The context holds information to use during the print. It also contains the date-time information to be printed.
The buffer must not be mutated beyond the content controlled by the implementation.
- Specified by:
printin interfaceDateTimeFormatterBuilder.DateTimePrinterParser- Parameters:
context- the context to print using, not nullbuf- the buffer to append to, not null- Returns:
- false if unable to query the value from the date-time, true otherwise
-
parse
public int parse(DateTimeParseContext context, java.lang.CharSequence text, 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 interfaceDateTimeFormatterBuilder.DateTimePrinterParser- Parameters:
context- the context to use and parse into, not nulltext- 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
-
convertToZone
private ZoneId convertToZone(java.util.Set<java.lang.String> regionIds, java.lang.String parsedZoneId, boolean caseSensitive)
-
parsePrefixedOffset
private int parsePrefixedOffset(DateTimeParseContext context, java.lang.CharSequence text, int prefixPos, int position)
-
prepareParser
private static DateTimeFormatterBuilder.ZoneIdPrinterParser.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, not null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-