Package javax.time.calendar.format
Class TextPrinterParser
java.lang.Object
javax.time.calendar.format.TextPrinterParser
- All Implemented Interfaces:
DateTimeParser
,DateTimePrinter
Prints or parses field text.
TextPrinterParser is immutable and thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NumberPrinterParser
The cached number printer parser.private final DateTimeFieldRule
<?> The rule to output, not null.private final DateTimeFormatterBuilder.TextStyle
The text style, not null. -
Constructor Summary
ConstructorsConstructorDescriptionTextPrinterParser
(DateTimeFieldRule<?> rule, DateTimeFormatterBuilder.TextStyle textStyle) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isPrintDataAvailable
(Calendrical calendrical) Checks if the calendrical contains the data necessary to be printed.private NumberPrinterParser
Create and cache a number printer parser.int
parse
(DateTimeParseContext context, String parseText, int position) Parses from the supplied text and position into the calendrical.void
print
(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) Prints the calendrical object to the appendable.toString()
-
Field Details
-
rule
The rule to output, not null. -
textStyle
The text style, not null. -
numberPrinterParser
The cached number printer parser. Immutable and volatile, so no synchronization needed.
-
-
Constructor Details
-
TextPrinterParser
TextPrinterParser(DateTimeFieldRule<?> rule, DateTimeFormatterBuilder.TextStyle textStyle) Constructor.- Parameters:
rule
- the rule to output, not nulltextStyle
- the text style, not null
-
-
Method Details
-
print
public void print(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) throws IOException Prints the calendrical object to the appendable.- Specified by:
print
in interfaceDateTimePrinter
- Parameters:
calendrical
- the calendrical to print, not nullappendable
- the appendable to add to, not nullsymbols
- the formatting symbols to use, not null- Throws:
IOException
- if the append throws an exception
-
isPrintDataAvailable
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:
isPrintDataAvailable
in interfaceDateTimePrinter
- Parameters:
calendrical
- the calendrical to check, not null- Returns:
- true if the calendrical can be printed, false if not
-
parse
Parses from the supplied text and position into the calendrical.- Specified by:
parse
in 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
-
numberPrinterParser
Create and cache a number printer parser.- Returns:
- the number printer parser for this field, never null
-
toString
-