This class represents the current state of the parse. It has the ability to store and retrieve the parsed values and manage optional segments. It also provides key information to the parsing methods.
Once parsing is complete, the toUnresolved() is used to obtain the unresolved
result data. The toResolved() is used to obtain the resolved result.
Implementation Specification
This class is a mutable context intended for use from a single thread. Usage of the class is thread-safe within standard parsing as a new instance of this class is automatically created for each parse and parsing is single-threaded
| Modifier and Type | Field and Description |
|---|---|
| private boolean | caseSensitive
Whether to parse using case sensitively. |
| private ArrayList | chronoListeners
List of Consumers<Chronology> to be notified if the Chronology changes. |
| private DateTimeFormatter | formatter
The formatter, not null. |
| private final ArrayList | parsed
The list of parsed data. |
| private boolean | strict
Whether to parse using strict rules. |
| Access | Constructor and Description |
|---|---|
| pack-priv | DateTimeParseContext(DateTimeFormatter
the formatter controlling the parse, not null formatter)Creates a new instance of the context. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | addChronoChangedListener(Consumer<Chronology>
a Consumer<Chronology> to be called when Chronology changes listener)Adds a Consumer<Chronology> to the list of listeners to be notified if the Chronology changes. |
| pack-priv boolean | Returns: true if equalthe first character ch1, char the second character ch2)Helper to compare two |
| pack-priv static boolean | Returns: true if equalthe first c1, char the second c2)Compares two characters ignoring case. |
| pack-priv DateTimeParseContext | |
| private Parsed | Returns: the current temporal objects, not nullGets the currently active temporal objects. |
| pack-priv void | endOptional(boolean
whether the optional segment was successfully parsed successful)Ends the parsing of an optional segment of the input. |
| pack-priv DecimalStyle | |
| pack-priv Chronology | Returns: the effective parsing chronology, not nullGets the effective chronology during parsing. |
| pack-priv Locale | |
| pack-priv Long | Returns: the value mapped to the specified field, null if field was not parsedthe field to query from the map, null returns null field)Gets the first value that was parsed for the specified field. |
| pack-priv boolean | Returns: true if parsing is case sensitive, false if case insensitiveChecks if parsing is case sensitive. |
| pack-priv boolean | |
| pack-priv void | setCaseSensitive(boolean
changes the parsing to be case sensitive or not from now on caseSensitive)Sets whether the parsing is case sensitive or not. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | setParsedDayPeriod(DateTimeFormatterBuilder.
the parsed day period dayPeriodStores the parsed day period. |
| pack-priv int | Returns: the new positionthe field to set in the field-value map, not null field, long the value to set in the field-value map value, int the position of the field being parsed errorPos, int the position after the field being parsed successPos)Stores the parsed field. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | setStrict(boolean
changes the parsing to be strict or lenient from now on strict)Sets whether parsing is strict or lenient. |
| pack-priv void | |
| pack-priv boolean | Returns: true if equalthe first character sequence, not null cs1, int the offset into the first sequence, valid offset1, CharSequence the second character sequence, not null cs2, int the offset into the second sequence, valid offset2, int the length to check, valid length)Helper to compare two |
| pack-priv TemporalAccessor | Returns: the result of the parse, not nullGets the resolved result of the parse. |
| public String | Returns: a string representation of the context data, not nullOverrides java. Returns a string version of the context for debugging. |
| pack-priv Parsed |
| caseSensitive | back to summary |
|---|---|
| private boolean caseSensitive Whether to parse using case sensitively. | |
| chronoListeners | back to summary |
|---|---|
| private ArrayList<Consumer<Chronology>> chronoListeners List of Consumers<Chronology> to be notified if the Chronology changes. | |
| formatter | back to summary |
|---|---|
| private DateTimeFormatter formatter The formatter, not null. | |
| parsed | back to summary |
|---|---|
| private final ArrayList<Parsed> parsed The list of parsed data. | |
| strict | back to summary |
|---|---|
| private boolean strict Whether to parse using strict rules. | |
| DateTimeParseContext | back to summary |
|---|---|
| pack-priv DateTimeParseContext(DateTimeFormatter formatter) Creates a new instance of the context.
| |
| addChronoChangedListener | back to summary |
|---|---|
| pack-priv void addChronoChangedListener(Consumer<Chronology> listener) Adds a Consumer<Chronology> to the list of listeners to be notified if the Chronology changes.
| |
| charEquals | back to summary |
|---|---|
| pack-priv boolean charEquals(char ch1, char ch2) Helper to compare two
| |
| charEqualsIgnoreCase | back to summary |
|---|---|
| pack-priv static boolean charEqualsIgnoreCase(char c1, char c2) Compares two characters ignoring case.
| |
| copy | back to summary |
|---|---|
| pack-priv DateTimeParseContext copy() Creates a copy of this context. This retains the case sensitive and strict flags. | |
| currentParsed | back to summary |
|---|---|
| private Parsed currentParsed() Gets the currently active temporal objects.
| |
| endOptional | back to summary |
|---|---|
| pack-priv void endOptional(boolean successful) Ends the parsing of an optional segment of the input.
| |
| getDecimalStyle | back to summary |
|---|---|
| pack-priv DecimalStyle getDecimalStyle() Gets the DecimalStyle. The DecimalStyle controls the numeric parsing.
| |
| getEffectiveChronology | back to summary |
|---|---|
| pack-priv Chronology getEffectiveChronology() Gets the effective chronology during parsing.
| |
| getLocale | back to summary |
|---|---|
| pack-priv Locale getLocale() Gets the locale. This locale is used to control localization in the parse except where localization is controlled by the DecimalStyle.
| |
| getParsed | back to summary |
|---|---|
| pack-priv Long getParsed(TemporalField field) Gets the first value that was parsed for the specified field. This searches the results of the parse, returning the first value found for the specified field. No attempt is made to derive a value. The field may have an out of range value. For example, the day-of-month might be set to 50, or the hour to 1000.
| |
| isCaseSensitive | back to summary |
|---|---|
| pack-priv boolean isCaseSensitive() Checks if parsing is case sensitive.
| |
| isStrict | back to summary |
|---|---|
| pack-priv boolean isStrict() Checks if parsing is strict. Strict parsing requires exact matching of the text and sign styles.
| |
| setCaseSensitive | back to summary |
|---|---|
| pack-priv void setCaseSensitive(boolean caseSensitive) Sets whether the parsing is case sensitive or not.
| |
| setParsed | back to summary |
|---|---|
| pack-priv void setParsed(Chronology chrono) Stores the parsed chronology. This stores the chronology that has been parsed. No validation is performed other than ensuring it is not null. The list of listeners is copied and cleared so that each listener is called only once. A listener can add itself again if it needs to be notified of future changes.
| |
| setParsed | back to summary |
|---|---|
| pack-priv void setParsed(ZoneId zone) Stores the parsed zone. This stores the zone that has been parsed. No validation is performed other than ensuring it is not null.
| |
| setParsedDayPeriod | back to summary |
|---|---|
| pack-priv void setParsedDayPeriod(DateTimeFormatterBuilder. Stores the parsed day period.
| |
| setParsedField | back to summary |
|---|---|
| pack-priv int setParsedField(TemporalField field, long value, int errorPos, int successPos) Stores the parsed field. This stores a field-value pair that has been parsed. The value stored may be out of range for the field - no checks are performed.
| |
| setParsedLeapSecond | back to summary |
|---|---|
| pack-priv void setParsedLeapSecond() Stores the parsed leap second. | |
| setParsedZoneNameType | back to summary |
|---|---|
| pack-priv void setParsedZoneNameType(int type) Stores the parsed zone name type. This stores the zone name type that has been parsed. The parsed type should either be;
| |
| setStrict | back to summary |
|---|---|
| pack-priv void setStrict(boolean strict) Sets whether parsing is strict or lenient.
| |
| startOptional | back to summary |
|---|---|
| pack-priv void startOptional() Starts the parsing of an optional segment of the input. | |
| subSequenceEquals | back to summary |
|---|---|
| pack-priv boolean subSequenceEquals(CharSequence cs1, int offset1, CharSequence cs2, int offset2, int length) Helper to compare two
| |
| toResolved | back to summary |
|---|---|
| pack-priv TemporalAccessor toResolved(ResolverStyle resolverStyle, Set<TemporalField> resolverFields) Gets the resolved result of the parse.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string version of the context for debugging. | |
| toUnresolved | back to summary |
|---|---|
| pack-priv Parsed toUnresolved() Gets the unresolved result of the parse.
| |