static class PeriodFormatterBuilder.FieldFormatter extends java.lang.Object implements PeriodPrinter, PeriodParser
Modifier and Type | Field and Description |
---|---|
private PeriodFormatterBuilder.FieldFormatter[] |
iFieldFormatters
The array of the latest formatter added for each type.
|
private int |
iFieldType
The index of the field type, 0=year, etc.
|
private int |
iMaxParsedDigits |
private int |
iMinPrintedDigits |
private PeriodFormatterBuilder.PeriodFieldAffix |
iPrefix |
private int |
iPrintZeroSetting |
private boolean |
iRejectSignedValues |
private PeriodFormatterBuilder.PeriodFieldAffix |
iSuffix |
Constructor and Description |
---|
FieldFormatter(int minPrintedDigits,
int printZeroSetting,
int maxParsedDigits,
boolean rejectSignedValues,
int fieldType,
PeriodFormatterBuilder.FieldFormatter[] fieldFormatters,
PeriodFormatterBuilder.PeriodFieldAffix prefix,
PeriodFormatterBuilder.PeriodFieldAffix suffix) |
FieldFormatter(PeriodFormatterBuilder.FieldFormatter field,
PeriodFormatterBuilder.PeriodFieldAffix suffix) |
Modifier and Type | Method and Description |
---|---|
int |
calculatePrintedLength(ReadablePeriod period,
java.util.Locale locale)
Returns the exact number of characters produced for the given period.
|
int |
countFieldsToPrint(ReadablePeriod period,
int stopAt,
java.util.Locale locale)
Returns the amount of fields from the given period that this printer
will print.
|
void |
finish(PeriodFormatterBuilder.FieldFormatter[] fieldFormatters) |
(package private) int |
getFieldType() |
(package private) long |
getFieldValue(ReadablePeriod period) |
(package private) boolean |
isSupported(PeriodType type,
int field) |
(package private) boolean |
isZero(ReadablePeriod period) |
private int |
parseInt(java.lang.String text,
int position,
int length) |
int |
parseInto(ReadWritablePeriod period,
java.lang.String text,
int position,
java.util.Locale locale)
Parses a period from the given text, at the given position, saving the
result into the fields of the given ReadWritablePeriod.
|
void |
printTo(java.lang.StringBuffer buf,
ReadablePeriod period,
java.util.Locale locale)
Prints a ReadablePeriod to a StringBuffer.
|
void |
printTo(java.io.Writer out,
ReadablePeriod period,
java.util.Locale locale)
Prints a ReadablePeriod to a Writer.
|
(package private) void |
setFieldValue(ReadWritablePeriod period,
int field,
int value) |
private final int iMinPrintedDigits
private final int iPrintZeroSetting
private final int iMaxParsedDigits
private final boolean iRejectSignedValues
private final int iFieldType
private final PeriodFormatterBuilder.FieldFormatter[] iFieldFormatters
private final PeriodFormatterBuilder.PeriodFieldAffix iPrefix
private final PeriodFormatterBuilder.PeriodFieldAffix iSuffix
FieldFormatter(int minPrintedDigits, int printZeroSetting, int maxParsedDigits, boolean rejectSignedValues, int fieldType, PeriodFormatterBuilder.FieldFormatter[] fieldFormatters, PeriodFormatterBuilder.PeriodFieldAffix prefix, PeriodFormatterBuilder.PeriodFieldAffix suffix)
FieldFormatter(PeriodFormatterBuilder.FieldFormatter field, PeriodFormatterBuilder.PeriodFieldAffix suffix)
public void finish(PeriodFormatterBuilder.FieldFormatter[] fieldFormatters)
public int countFieldsToPrint(ReadablePeriod period, int stopAt, java.util.Locale locale)
PeriodPrinter
countFieldsToPrint
in interface PeriodPrinter
period
- the period to usestopAt
- stop counting at this value, enter a number ≥ 256 to count alllocale
- the locale to usepublic int calculatePrintedLength(ReadablePeriod period, java.util.Locale locale)
PeriodPrinter
calculatePrintedLength
in interface PeriodPrinter
period
- the period to uselocale
- the locale to usepublic void printTo(java.lang.StringBuffer buf, ReadablePeriod period, java.util.Locale locale)
PeriodPrinter
printTo
in interface PeriodPrinter
buf
- the formatted period is appended to this bufferperiod
- the period to formatlocale
- the locale to usepublic void printTo(java.io.Writer out, ReadablePeriod period, java.util.Locale locale) throws java.io.IOException
PeriodPrinter
printTo
in interface PeriodPrinter
out
- the formatted period is written outperiod
- the period to formatlocale
- the locale to usejava.io.IOException
public int parseInto(ReadWritablePeriod period, java.lang.String text, int position, java.util.Locale locale)
PeriodParser
If it fails, the return value is negative, but the period may still be modified. To determine the position where the parse failed, apply the one's complement operator (~) on the return value.
parseInto
in interface PeriodParser
period
- a period that will be modifiedtext
- text to parseposition
- position to start parsing fromlocale
- the locale to use for parsingprivate int parseInt(java.lang.String text, int position, int length)
text
- text to parseposition
- position in textlength
- exact count of characters to parselong getFieldValue(ReadablePeriod period)
boolean isZero(ReadablePeriod period)
boolean isSupported(PeriodType type, int field)
void setFieldValue(ReadWritablePeriod period, int field, int value)
int getFieldType()