public final class Attributes extends java.lang.Object implements AttributeQuery
A collection of format attributes for controlling the formatting and parsing.
| Modifier and Type | Class and Description |
|---|---|
static class |
Attributes.Builder
Builds a collection of format attributes.
|
| Modifier and Type | Field and Description |
|---|---|
static AttributeKey<java.lang.String> |
CALENDAR_TYPE
Attribute for the calendar type.
|
static AttributeKey<java.lang.String> |
CALENDAR_VARIANT
Defines an attribute key which can be used in queries for the calendar variant.
|
static AttributeKey<java.lang.Character> |
DECIMAL_SEPARATOR
Determines the unicode char for the decimal separator.
|
static AttributeKey<java.util.Locale> |
LANGUAGE
Attribute controlling the language output and parsing of
chronological texts (for example month names).
|
static AttributeKey<Leniency> |
LENIENCY
Attribute which controls the leniency in parsing.
|
static AttributeKey<OutputContext> |
OUTPUT_CONTEXT
Determines the output context to be used in formatting and
parsing.
|
static AttributeKey<java.lang.Character> |
PAD_CHAR
Determines the pad char to be used if a formatted representation is
shorter than specified.
|
static AttributeKey<java.lang.Boolean> |
PARSE_CASE_INSENSITIVE
This attribute controls if the case of text is irrelevant
in parsing or not.
|
static AttributeKey<java.lang.Boolean> |
PARSE_PARTIAL_COMPARE
This attribute controls if the parser will only check the
start of a chronological text.
|
static AttributeKey<java.lang.Integer> |
PIVOT_YEAR
Determines the pivot year for the representation of
two-digit-years.
|
static AttributeKey<java.lang.Integer> |
PROTECTED_CHARACTERS
Determines how many remaining chars in a given text are reserved
and cannot be consumed by the current format step.
|
static AttributeKey<StartOfDay> |
START_OF_DAY
Defines an attribute key which can be used in queries for the start of day during formatting or parsing.
|
static AttributeKey<TextWidth> |
TEXT_WIDTH
Determines the text width to be used in formatting and parsing.
|
static AttributeKey<TZID> |
TIMEZONE_ID
Attribute denoting the timezone identifier for display purposes.
|
static AttributeKey<java.lang.Boolean> |
TRAILING_CHARACTERS
Controls if any trailing unparsed characters will be
tolerated or not.
|
static AttributeKey<TransitionStrategy> |
TRANSITION_STRATEGY
Attribute for the conflict strategy to be used in resolving
ambivalent or invalid local timestamps.
|
static AttributeKey<java.lang.Character> |
ZERO_DIGIT
Determines the unicode char for the zero digit..
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(AttributeKey<?> key)
Queries if a format attribute exists for given key.
|
static AttributeQuery |
empty()
Represents an empty collection of format attributes.
|
boolean |
equals(java.lang.Object obj)
Compares all internal format attributes.
|
<A> A |
get(AttributeKey<A> key)
Yields a format attribute for given key.
|
<A> A |
get(AttributeKey<A> key,
A defaultValue)
Yields a format attribute for given key.
|
int |
hashCode() |
java.lang.String |
toString()
Supports mainly debugging.
|
public static final AttributeKey<java.lang.String> CALENDAR_TYPE
Attribute for the calendar type.
This attribute is effectively read-only and usually derived
from the corresponding annotation value of any given chronology.
Default value: CalendarText.ISO_CALENDAR_TYPE
CalendarTypepublic static final AttributeKey<java.util.Locale> LANGUAGE
Attribute controlling the language output and parsing of chronological texts (for example month names).
Default value: Locale.ROOT.
public static final AttributeKey<TZID> TIMEZONE_ID
Attribute denoting the timezone identifier for display purposes.
When printing a global type this attribute controls the zonal representation. If this attribute is missing then Time4J will throw an exception because the internal timezone reference UTC+00:00 of global types is not intended to be used for display purposes.
When parsing a global type this attribute serves as replacement timezone if the parsing has not recognized any timezone or offset information in the text to be parsed. If the attribute is also missing then Time4J will throw an exception.
Note that before version v2.0 the behaviour of Time4J was
different. When printing, the default ZonalOffset.UTC was used.
When parsing, the system default timezone was used as default in case
of missing attribute and lax mode.
public static final AttributeKey<TransitionStrategy> TRANSITION_STRATEGY
Attribute for the conflict strategy to be used in resolving ambivalent or invalid local timestamps.
If this attribute is missing then Time4J will assume the default conflict strategy.
Timezone.DEFAULT_CONFLICT_STRATEGYpublic static final AttributeKey<Leniency> LENIENCY
Attribute which controls the leniency in parsing.
Setting of this attribute also changes other attributes:
| LENIENCY | PARSE_CASE_INSENSITIVE | PARSE_PARTIAL_COMPARE | TRAILING_CHARACTERS |
|---|---|---|---|
| STRICT | false | false | false |
| SMART | true | false | false |
| LAX | true | true | true |
Default value: Leniency.SMART
public static final AttributeKey<TextWidth> TEXT_WIDTH
Determines the text width to be used in formatting and parsing.
Default value: TextWidth.WIDE
public static final AttributeKey<OutputContext> OUTPUT_CONTEXT
Determines the output context to be used in formatting and parsing.
Default value: OutputContext.FORMAT
public static final AttributeKey<java.lang.Boolean> PARSE_CASE_INSENSITIVE
This attribute controls if the case of text is irrelevant in parsing or not.
Default value: true
public static final AttributeKey<java.lang.Boolean> PARSE_PARTIAL_COMPARE
This attribute controls if the parser will only check the start of a chronological text.
Abbreviations can be parsed by help of this attribute, too.
Default value: false
public static final AttributeKey<java.lang.Character> ZERO_DIGIT
Determines the unicode char for the zero digit..
In case of changing the language setting this attribute will
automatically be adjusted. Default value is the arab digit
0 in ISO-8601 (corresponding to the ASCII-value 48).
public static final AttributeKey<java.lang.Character> DECIMAL_SEPARATOR
Determines the unicode char for the decimal separator.
In case of changing the language setting this attribute will automatically be adjusted. In ISO-8601 (for the root locale), the comma is the default value is the comma corresponding to the ASCII-value 44. With help of the boolean system property "net.time4j.format.iso.decimal.dot", the dot can be defined as alternative default value.
public static final AttributeKey<java.lang.Character> PAD_CHAR
Determines the pad char to be used if a formatted representation is shorter than specified.
Default value is the space. Numerical elements are not affected by this attribute because they always use the zero digit as pad char.
public static final AttributeKey<java.lang.Integer> PIVOT_YEAR
Determines the pivot year for the representation of two-digit-years.
Default value is the year which is 20 years after the current
year. Example: If the pivot year has the value 2034 then
a two-digit-year will be mapped to the range 1934-2033 such that
the last two digits are equal. This attribute must have at least
three digits an be positive else an exception will be thrown.
public static final AttributeKey<java.lang.Boolean> TRAILING_CHARACTERS
Controls if any trailing unparsed characters will be tolerated or not.
Example:
ChronoFormatter formatter =
ChronoFormatter.setUp(PlainTime.class, Locale.US)
.addInteger(PlainTime.CLOCK_HOUR_OF_AMPM, 1, 2)
.addLiteral(' ')
.addText(PlainTime.AM_PM_OF_DAY)
.padPrevious(3)
.addFixedInteger(PlainTime.MINUTE_OF_HOUR, 2)
.build()
.with(Attributes.TRAILING_CHARACTERS, true);
System.out.println(formatter.parse("5 PM 45xyz"));
// Output: T17:45
Default value: false
public static final AttributeKey<java.lang.Integer> PROTECTED_CHARACTERS
Determines how many remaining chars in a given text are reserved and cannot be consumed by the current format step.
Default value is 0. This attribute can be used as sectional
attribute if an integer element is numerically processed. Such a
protected element will not consume any following chars and possibly
use the default value setting of the current formatter instead.
Note: This attribute overrides any reserved area due to adjacent digit parsing.
public static final AttributeKey<java.lang.String> CALENDAR_VARIANT
Defines an attribute key which can be used in queries for the calendar variant.
public static final AttributeKey<StartOfDay> START_OF_DAY
Defines an attribute key which can be used in queries for the start of day during formatting or parsing.
The default value is StartOfDay.MIDNIGHT.
public static AttributeQuery empty()
Represents an empty collection of format attributes.
public boolean contains(AttributeKey<?> key)
AttributeQueryQueries if a format attribute exists for given key.
contains in interface AttributeQuerykey - attribute keytrue if attribute exists else falsepublic <A> A get(AttributeKey<A> key)
AttributeQueryYields a format attribute for given key.
get in interface AttributeQueryA - generic type of attribute valuekey - attribute keypublic <A> A get(AttributeKey<A> key, A defaultValue)
AttributeQueryYields a format attribute for given key.
get in interface AttributeQueryA - generic type of attribute valuekey - attribute keydefaultValue - replacement value to be used if attribute does
not existpublic boolean equals(java.lang.Object obj)
Compares all internal format attributes.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
Supports mainly debugging.
toString in class java.lang.Object