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

public interface IValueObject<TYPE>
Interface to create a value object for the data type, or to convert to it.

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 Details

    • PATTERN_SHORT

      static final String PATTERN_SHORT
      The pattern "short" for date/time.
      See Also:
    • PATTERN_MEDIUM

      static final String PATTERN_MEDIUM
      The pattern "medium" for date/time.
      See Also:
    • PATTERN_LONG

      static final String PATTERN_LONG
      The pattern "long" for date/time.
      See Also:
    • PATTERN_FULL

      static final String PATTERN_FULL
      The pattern "full" for date/time.
      See Also:
    • PATTERN_BASIC_ISO_DATE

      static final String PATTERN_BASIC_ISO_DATE
      The pattern: Basic ISO date '20111203'.
      See Also:
    • PATTERN_ISO_LOCAL_DATE

      static final String PATTERN_ISO_LOCAL_DATE
      The pattern: ISO Local Date '2011-12-03'.
      See Also:
    • PATTERN_ISO_OFFSET_DATE

      static final String PATTERN_ISO_OFFSET_DATE
      The pattern: ISO Date with offset '2011-12-03+01:00'.
      See Also:
    • PATTERN_ISO_DATE

      static final String 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

      static final String PATTERN_ISO_LOCAL_TIME
      The pattern: Time without offset '10:15:30'.
      See Also:
    • PATTERN_ISO_OFFSET_TIME

      static final String PATTERN_ISO_OFFSET_TIME
      The pattern: Time with offset '10:15:30+01:00'.
      See Also:
    • PATTERN_ISO_TIME

      static final String 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

      static final String PATTERN_ISO_LOCAL_DATE_TIME
      The pattern: ISO Local Date and Time '2011-12-03T10:15:30'.
      See Also:
    • PATTERN_ISO_OFFSET_DATE_TIME

      static final String 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

      static final String 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

      static final String 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

      static final String PATTERN_ISO_ORDINAL_DATE
      The pattern: Year and day of year '2012-337'.
      See Also:
    • PATTERN_ISO_WEEK_DATE

      static final String PATTERN_ISO_WEEK_DATE
      The pattern: Year and Week 2012-W48-6'.
      See Also:
    • PATTERN_ISO_INSTANT

      static final String PATTERN_ISO_INSTANT
      The pattern: Date and Time of an Instant '2011-12-03T10:15:30Z'.
      See Also:
    • PATTERN_RFC_1123_DATE_TIME

      static final String PATTERN_RFC_1123_DATE_TIME
      The pattern: RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'.
      See Also:
    • PATTERN_INTEGER

      static final String PATTERN_INTEGER
      The pattern "integer" for numeric values.
      See Also:
    • PATTERN_PERCENT

      static final String PATTERN_PERCENT
      The pattern "percent" for numeric values.
      See Also:
    • PATTERN_CURRENCY

      static final String PATTERN_CURRENCY
      The pattern "currency" for numeric values.
      See Also:
    • RESOLVER_STRICT

      static final String 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

      static final String RESOLVER_STRICT_NO_BRACKETS
      See Also:
    • RESOLVER_SMART

      static final String 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

      static final String RESOLVER_SMART_NO_BRACKETS
      See Also:
    • RESOLVER_LENIENT

      static final String 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

      static final String RESOLVER_LENIENT_NO_BRACKETS
      See Also:
  • Method Details

    • getValueType

      Value.Type getValueType()
      Gets the value type.
    • getValueClass

      Class<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

      Format getFormatter(String pattern, LocaleInfo localeInfo) throws IllegalArgumentException
      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

      String toString(TYPE value)
      The default "toString" representation.
      Parameters:
      value - The value could be null.
      Returns:
      The String representation.
    • toStringForced

      default String toStringForced(Object value)
      Calls the "toString" method with any object, casting it. IF casting fails, which should not be, then String.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

      TYPE load(String value, Element element) throws Exception
      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

      String save(TYPE value, Element element) throws Exception
      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

      default String saveCast(Object value, Element element) throws Exception
      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

      TYPE convert(Object value, Value.Type oldType, LocaleInfo localeInfo) throws Exception
      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

      long asLong(TYPE value, LocaleInfo localeInfo)
      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

      default long asLongCast(Object value, LocaleInfo localeInfo)
      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.