Class PadPrinterParserDecorator
java.lang.Object
javax.time.calendar.format.PadPrinterParserDecorator
- All Implemented Interfaces:
DateTimeParser, DateTimePrinter
Pads the output to a fixed width.
PadPrinterParserDecorator is immutable and thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final charThe character to pad the next field with.private final intThe width to pad the next field to.private final DateTimeParserThe parser to decorate.private final DateTimePrinterThe printer to decorate. -
Constructor Summary
ConstructorsConstructorDescriptionPadPrinterParserDecorator(DateTimePrinter printer, DateTimeParser parser, int padWidth, char padChar) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisPrintDataAvailable(Calendrical calendrical) Checks if the calendrical contains the data necessary to be printed.intparse(DateTimeParseContext context, String parseText, int position) Parses from the supplied text and position into the calendrical.voidprint(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) Prints the calendrical object to the appendable.toString()
-
Field Details
-
printer
The printer to decorate. -
parser
The parser to decorate. -
padWidth
private final int padWidthThe width to pad the next field to. -
padChar
private final char padCharThe character to pad the next field with.
-
-
Constructor Details
-
PadPrinterParserDecorator
PadPrinterParserDecorator(DateTimePrinter printer, DateTimeParser parser, int padWidth, char padChar) Constructor.- Parameters:
printer- the printer, may be null in which case print() must not be calledparser- the parser, may be null in which case parse() must not be calledpadWidth- the width to pad to, 1 or greaterpadChar- the pad character
-
-
Method Details
-
print
public void print(Calendrical calendrical, Appendable appendable, DateTimeFormatSymbols symbols) throws 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:
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:
isPrintDataAvailablein 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:
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
-
toString
-