Interface IValueObject<TYPE>
- All Known Implementing Classes:
BigDecimalValue
,BigIntegerValue
,BinaryValue
,BooleanValue
,ByteValue
,DoubleValue
,DurationValue
,FloatValue
,IntegerValue
,KStringValue
,LocalDateTimeValue
,LocalDateValue
,LocalTimeValue
,LongValue
,MonthDayValue
,NumberValue
,OffsetDateTimeValue
,OffsetTimeValue
,PeriodValue
,ShortValue
,StringValue
,TermporalAccessorValue
,TermporalAmountValue
,XMLDurationValue
,XMLGregorianCalendarValue
,YearMonthValue
,YearValue
,ZonedDateTimeValue
Pattern is defined to be able to select formatters of different types, before passing in the rest of the pattern. If this is the case, the pattern string must begin with [type], where "type" is one of:
- "short" (for date/time)
- "medium" (for date/time)
- "long" (for date/time)
- "full" (for date/time)
- integer (for numeric values)
- currency (for numeric values)
- percent (for numeric values)
In addition, the resolver style for how a value is parsed from a String can be specified in the start of the pattern as:
- [strict],
- [smart], or
- [lenient].
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The pattern: Basic ISO date '20111203'.static final String
The pattern "currency" for numeric values.static final String
The pattern "full" for date/time.static final String
The pattern "integer" for numeric values.static final String
The pattern: ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03'.static final String
The pattern: Date and time with ZoneId '2011-12-03T10:15:30+01:00[Europe/Paris]'.static final String
The pattern: Date and Time of an Instant '2011-12-03T10:15:30Z'.static final String
The pattern: ISO Local Date '2011-12-03'.static final String
The pattern: ISO Local Date and Time '2011-12-03T10:15:30'.static final String
The pattern: Time without offset '10:15:30'.static final String
The pattern: ISO Date with offset '2011-12-03+01:00'.static final String
The pattern: Date Time with Offset 2011-12-03T10:15:30+01:00'.static final String
The pattern: Time with offset '10:15:30+01:00'.static final String
The pattern: Year and day of year '2012-337'.static final String
The pattern: Time with or without offset '10:15:30+01:00'; '10:15:30'.static final String
The pattern: Year and Week 2012-W48-6'.static final String
The pattern: Zoned Date Time '2011-12-03T10:15:30+01:00[Europe/Paris]'.static final String
The pattern "long" for date/time.static final String
The pattern "medium" for date/time.static final String
The pattern "percent" for numeric values.static final String
The pattern: RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'.static final String
The pattern "short" for date/time.static final String
Resolver style for parsing date/time, should precede the pattern string.static final String
static final String
Resolver style for parsing date/time, should precede the pattern string.static final String
static final String
Resolver style for parsing date/time, should precede the pattern string.static final String
Method Summary
Modifier and TypeMethodDescriptionlong
asLong
(TYPE value, LocaleInfo localeInfo) Returns a long value if possible.default long
asLongCast
(Object value, LocaleInfo localeInfo) Returns a long value if possible.convert
(Object value, Value.Type oldType, LocaleInfo localeInfo) Converts a value from another type.Creates the default value object for the data type.Gets the description of the type, used for the Designer.getFormatter
(String pattern, LocaleInfo localeInfo) Returns the Formatter for a pattern.Gets the class of the value.Gets the value type.default boolean
Checks if this type is right-aligned in table columns.Loads the value from an Element.Creates a Value object from a String using a specified pattern and locale.parse
(String value, String pattern, LocaleInfo localeInfo) Creates a Value object from a String using a specified pattern and locale.Saves the value to an Element.default String
Saves the value to an Element.The default "toString" representation.toString
(TYPE value, String pattern, LocaleInfo localeInfo) Formats the value to a String.default String
toStringCast
(Object value, String pattern, LocaleInfo localeInfo) Formats the value to a String.default String
toStringForced
(Object value) Calls the "toString" method with any object, casting it.
Field Details
PATTERN_SHORT
The pattern "short" for date/time.- See Also:
PATTERN_MEDIUM
The pattern "medium" for date/time.- See Also:
PATTERN_LONG
The pattern "long" for date/time.- See Also:
PATTERN_FULL
The pattern "full" for date/time.- See Also:
PATTERN_BASIC_ISO_DATE
The pattern: Basic ISO date '20111203'.- See Also:
PATTERN_ISO_LOCAL_DATE
The pattern: ISO Local Date '2011-12-03'.- See Also:
PATTERN_ISO_OFFSET_DATE
The pattern: ISO Date with offset '2011-12-03+01:00'.- See Also:
PATTERN_ISO_DATE
The pattern: ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03'.- See Also:
PATTERN_ISO_LOCAL_TIME
The pattern: Time without offset '10:15:30'.- See Also:
PATTERN_ISO_OFFSET_TIME
The pattern: Time with offset '10:15:30+01:00'.- See Also:
PATTERN_ISO_TIME
The pattern: Time with or without offset '10:15:30+01:00'; '10:15:30'.- See Also:
PATTERN_ISO_LOCAL_DATE_TIME
The pattern: ISO Local Date and Time '2011-12-03T10:15:30'.- See Also:
PATTERN_ISO_OFFSET_DATE_TIME
The pattern: Date Time with Offset 2011-12-03T10:15:30+01:00'.- See Also:
PATTERN_ISO_ZONED_DATE_TIME
The pattern: Zoned Date Time '2011-12-03T10:15:30+01:00[Europe/Paris]'.- See Also:
PATTERN_ISO_DATE_TIME
The pattern: Date and time with ZoneId '2011-12-03T10:15:30+01:00[Europe/Paris]'.- See Also:
PATTERN_ISO_ORDINAL_DATE
The pattern: Year and day of year '2012-337'.- See Also:
PATTERN_ISO_WEEK_DATE
The pattern: Year and Week 2012-W48-6'.- See Also:
PATTERN_ISO_INSTANT
The pattern: Date and Time of an Instant '2011-12-03T10:15:30Z'.- See Also:
PATTERN_RFC_1123_DATE_TIME
The pattern: RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'.- See Also:
PATTERN_INTEGER
The pattern "integer" for numeric values.- See Also:
PATTERN_PERCENT
The pattern "percent" for numeric values.- See Also:
PATTERN_CURRENCY
The pattern "currency" for numeric values.- See Also:
RESOLVER_STRICT
Resolver style for parsing date/time, should precede the pattern string.Style to resolve dates and times strictly.
Using strict resolution will ensure that all parsed values are within the outer range of valid values for the field. Individual fields may be further processed for strictness.
For example, resolving year-month and day-of-month in the ISO calendar system using strict mode will ensure that the day-of-month is valid for the year-month, rejecting invalid values.
- See Also:
RESOLVER_STRICT_NO_BRACKETS
- See Also:
RESOLVER_SMART
Resolver style for parsing date/time, should precede the pattern string.Style to resolve dates and times in a smart, or intelligent, manner.
Using smart resolution will perform the sensible default for each field, which may be the same as strict, the same as lenient, or a third behavior. Individual fields will interpret this differently.
For example, resolving year-month and day-of-month in the ISO calendar system using smart mode will ensure that the day-of-month is from 1 to 31, converting any value beyond the last valid day-of-month to be the last valid day-of-month.
- See Also:
RESOLVER_SMART_NO_BRACKETS
- See Also:
RESOLVER_LENIENT
Resolver style for parsing date/time, should precede the pattern string.Style to resolve dates and times leniently.
Using lenient resolution will resolve the values in an appropriate lenient manner. Individual fields will interpret this differently.
For example, lenient mode allows the month in the ISO calendar system to be outside the range 1 to 12. For example, month 15 is treated as being 3 months after month 12.
- See Also:
RESOLVER_LENIENT_NO_BRACKETS
- See Also:
Method Details
getValueType
Value.Type getValueType()Gets the value type.getValueClass
Gets the class of the value.getDescription
String getDescription()Gets the description of the type, used for the Designer.createDefault
TYPE createDefault()Creates the default value object for the data type.- Returns:
- The default value.
isRightAligned
default boolean isRightAligned()Checks if this type is right-aligned in table columns.- Returns:
- true for right-aligned values, default is false: left-aligned.
getFormatter
Returns the Formatter for a pattern.- Parameters:
pattern
- The pattern to use, null for none.localeInfo
- The locale information instance, or null for none.- Returns:
- The formatter to use, or null for none.
- Throws:
IllegalArgumentException
- For formatter errors.
toString
The default "toString" representation.- Parameters:
value
- The value could be null.- Returns:
- The String representation.
toStringForced
Calls the "toString" method with any object, casting it. IF casting fails, which should not be, thenString.valueOf(value)
is called.- Parameters:
value
- The value could be null.- Returns:
- The String representation.
toString
String toString(TYPE value, String pattern, LocaleInfo localeInfo) throws IllegalArgumentException, Exception Formats the value to a String.- Parameters:
value
- The value is never null.pattern
- Pattern to use, null for none.localeInfo
- The locale information instance, or null for none.- Returns:
- The String representation using specified pattern and locale information.
- Throws:
IllegalArgumentException
- For formatter errors.Exception
- For other errors.
toStringCast
default String toStringCast(Object value, String pattern, LocaleInfo localeInfo) throws IllegalArgumentException, Exception Formats the value to a String.- Parameters:
value
- The value is never null.pattern
- Pattern to use, null for none.localeInfo
- The locale information instance, or null for none.- Returns:
- The String representation using specified pattern and locale information.
- Throws:
IllegalArgumentException
- For formatter errors.Exception
- For other errors.
parse
Creates a Value object from a String using a specified pattern and locale.- Parameters:
value
- The value, never null.- Returns:
- The value object, never null.
- Throws:
ParseException
- If the value could not be parsed.IllegalArgumentException
- For pattern errors.Exception
- For other errors.
parse
TYPE parse(String value, String pattern, LocaleInfo localeInfo) throws ParseException, IllegalArgumentException, Exception Creates a Value object from a String using a specified pattern and locale.- Parameters:
value
- The value, never null.pattern
- The pattern, null for none.localeInfo
- The locale info, null for default.- Returns:
- The value object, never null.
- Throws:
ParseException
- If the value could not be parsed.IllegalArgumentException
- For pattern errors.Exception
- For other errors.
load
Loads the value from an Element.- Parameters:
value
- The String value in the element.element
- The element holding the information for advanced processing using JAXB.- Throws:
Exception
- An exception due to parsing, bean unmarshalling, etc.
save
Saves the value to an Element.- Parameters:
value
- The value to save.element
- The element to save information into for advanced processing using JAXB.- Returns:
- The String value to set in the Element, or null if advanced processing is used.
- Throws:
Exception
saveCast
Saves the value to an Element.- Parameters:
value
- The value to save.element
- The element to save information into for advanced processing using JAXB.- Returns:
- The String value to set in the Element, or null if advanced processing is used.
- Throws:
Exception
convert
Converts a value from another type. If the type is not defined, check the object instance for possible conversions.- Parameters:
value
- The value to convert.oldType
- The old type, null for not defined or unknown.localeInfo
- The locale information, null to look-up from current thread or if not found, for system default.- Returns:
- The value object.
- Throws:
Exception
- For other errors.ParseException
- If this conversion fails.
asLong
Returns a long value if possible.- Parameters:
value
- The Value object.localeInfo
- The locale information, null to look-up from current thread or if not found, for system default.- Returns:
- The long value, e.g. in milliseconds, or Long.MIN_VALUE for not possible.
asLongCast
Returns a long value if possible.- Parameters:
value
- The Value object.localeInfo
- The locale information, null to look-up from current thread or if not found, for system default.- Returns:
- The long value, e.g. in milliseconds, or Long.MIN_VALUE for not possible.