Class StructuredFieldBareItem


  • @Contract(threading=IMMUTABLE)
    public final class StructuredFieldBareItem
    extends java.lang.Object
    Immutable Structured Field bare Item.
    Since:
    5.5
    • Method Detail

      • ofInteger

        public static StructuredFieldBareItem ofInteger​(long value)
        Creates an Integer bare Item.
        Parameters:
        value - the integer value.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the value is outside the Structured Field range.
      • ofDecimal

        public static StructuredFieldBareItem ofDecimal​(java.math.BigDecimal value)
        Creates a Decimal bare Item, applying the Structured Field rounding algorithm.
        Parameters:
        value - the decimal value.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the rounded value has more than 12 integer digits.
      • ofString

        public static StructuredFieldBareItem ofString​(java.lang.String value)
        Creates an ASCII String bare Item.
        Parameters:
        value - the printable ASCII value.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the value contains a character outside SP through ~.
      • ofToken

        public static StructuredFieldBareItem ofToken​(java.lang.String value)
        Creates a Token bare Item.
        Parameters:
        value - the token value.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the value is not an Structured Field token.
      • ofByteSequence

        public static StructuredFieldBareItem ofByteSequence​(byte[] value)
        Creates a Byte Sequence bare Item using a defensive copy.
        Parameters:
        value - the byte sequence.
        Returns:
        the bare Item.
      • ofBoolean

        public static StructuredFieldBareItem ofBoolean​(boolean value)
        Creates a Boolean bare Item.
        Parameters:
        value - the boolean value.
        Returns:
        the bare Item.
      • ofDate

        public static StructuredFieldBareItem ofDate​(long epochSeconds)
        Creates a Date bare Item expressed as seconds since the Unix epoch.
        Parameters:
        epochSeconds - seconds since the Unix epoch.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the value is outside the Structured Field Integer range.
      • ofDisplayString

        public static StructuredFieldBareItem ofDisplayString​(java.lang.String value)
        Creates a Unicode Display String bare Item.
        Parameters:
        value - the Unicode value.
        Returns:
        the bare Item.
        Throws:
        java.lang.IllegalArgumentException - if the value contains an unpaired surrogate.
      • getValue

        public java.lang.Object getValue()
        Returns the value using its Java representation. Byte sequences are defensively copied.
        Returns:
        the value.
      • getLongValue

        public long getLongValue()
        Returns:
        the Integer or Date value.
        Throws:
        java.lang.IllegalStateException - if this Item is not an Integer or Date.
      • getDecimalValue

        public java.math.BigDecimal getDecimalValue()
        Returns:
        the Decimal value.
        Throws:
        java.lang.IllegalStateException - if this Item is not a Decimal.
      • getTextValue

        public java.lang.String getTextValue()
        Returns:
        the String, Token, or Display String value.
        Throws:
        java.lang.IllegalStateException - if this Item is not one of those textual types.
      • getByteSequenceValue

        public byte[] getByteSequenceValue()
        Returns:
        a defensive copy of the Byte Sequence value.
        Throws:
        java.lang.IllegalStateException - if this Item is not a Byte Sequence.
      • getBooleanValue

        public boolean getBooleanValue()
        Returns:
        the Boolean value.
        Throws:
        java.lang.IllegalStateException - if this Item is not a Boolean.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object