Interface ValueFactory

    • Method Detail

      • newNullBlob

        IonBlob newNullBlob()
        Constructs a new null.blob instance.
      • newBlob

        IonBlob newBlob​(byte[] value)
        Constructs a new Ion blob instance, copying bytes from an array.
        Parameters:
        value - the data for the new blob, to be copied from the given array into the new instance. May be null to create a null.blob value.
      • newBlob

        IonBlob newBlob​(byte[] value,
                        int offset,
                        int length)
        Constructs a new Ion blob, copying bytes from part of an array.

        This method copies length bytes from the given array into the new value, starting at the given offset in the array.

        Parameters:
        value - the data for the new blob, to be copied from the given array into the new instance. May be null to create a null.blob value.
        offset - the offset within the array of the first byte to copy; must be non-negative and no larger than bytes.length.
        length - the number of bytes to be copied from the given array; must be non-negative and no larger than bytes.length - offset.
        Throws:
        java.lang.IndexOutOfBoundsException - if the preconditions on the offset and length parameters are not met.
      • newNullBool

        IonBool newNullBool()
        Constructs a new null.bool instance.
      • newBool

        IonBool newBool​(boolean value)
        Constructs a new bool instance with the given value.
        Parameters:
        value - the new bool's value.
        Returns:
        a bool with IonBool.booleanValue() == value.
      • newBool

        IonBool newBool​(java.lang.Boolean value)
        Constructs a new bool instance with the given value.
        Parameters:
        value - the new bool's value. may be null to make null.bool.
      • newNullClob

        IonClob newNullClob()
        Constructs a new null.clob instance.
      • newClob

        IonClob newClob​(byte[] value)
        Constructs a new Ion clob instance from a byte array.
        Parameters:
        value - the data for the new clob, to be copied from the given array into the new instance. May be null to create a null.clob value.
      • newClob

        IonClob newClob​(byte[] value,
                        int offset,
                        int length)
        Constructs a new Ion clob, copying bytes from part of an array.

        This method copies length bytes from the given array into the new value, starting at the given offset in the array.

        Parameters:
        value - the data for the new blob, to be copied from the given array into the new instance. May be null to create a null.clob value.
        offset - the offset within the array of the first byte to copy; must be non-negative an no larger than bytes.length.
        length - the number of bytes to be copied from the given array; must be non-negative an no larger than bytes.length - offset.
        Throws:
        java.lang.IndexOutOfBoundsException - if the preconditions on the offset and length parameters are not met.
      • newNullDecimal

        IonDecimal newNullDecimal()
        Constructs a new null.decimal instance.
      • newDecimal

        IonDecimal newDecimal​(long value)
        Constructs a new Ion decimal instance from a Java long.
      • newDecimal

        IonDecimal newDecimal​(double value)
        Constructs a new Ion decimal instance from a Java double.

        Note that this does not generate the exact decimal representation of the double's binary floating-point value as via BigDecimal(double), but instead uses the more predictable behavior of matching the double's string representation as via BigDecimal.valueOf(double).

      • newDecimal

        IonDecimal newDecimal​(java.math.BigInteger value)
        Constructs a new Ion decimal instance from a Java BigInteger.
      • newDecimal

        IonDecimal newDecimal​(java.math.BigDecimal value)
        Constructs a new Ion decimal instance from a Java BigDecimal. To create negative zero values, pass a Decimal.
      • newNullFloat

        IonFloat newNullFloat()
        Constructs a new null.float instance.
      • newFloat

        IonFloat newFloat​(long value)
        Constructs a new Ion float instance from a Java long.
      • newFloat

        IonFloat newFloat​(double value)
        Constructs a new Ion float instance from a Java double.
      • newNullInt

        IonInt newNullInt()
        Constructs a new null.int instance.
      • newInt

        IonInt newInt​(int value)
        Constructs a new int instance with the given value.
        Parameters:
        value - the new int's value.
      • newInt

        IonInt newInt​(long value)
        Constructs a new int instance with the given value.
        Parameters:
        value - the new int's value.
      • newInt

        IonInt newInt​(java.lang.Number value)
        Constructs a new int instance with the given value. The integer portion of the number is used, any fractional portion is ignored.
        Parameters:
        value - the new int's value; may be null to make null.int.
      • newNullList

        IonList newNullList()
        Constructs a new null.list instance.
      • newEmptyList

        IonList newEmptyList()
        Constructs a new empty (not null) list instance.
      • newList

        IonList newList​(int[] values)
        Constructs a new list with given int children.
        Parameters:
        values - the initial set of child values. If null, then the new instance will have IonValue.isNullValue() == true. Otherwise, the resulting sequence will contain new IonInts with the given values.
        Returns:
        a new list where each element is an IonInt.
      • newList

        IonList newList​(long[] values)
        Constructs a new list with given long child elements.
        Parameters:
        values - the initial set of child values. If null, then the new instance will have IonValue.isNullValue() == true. Otherwise, the resulting sequence will contain new IonInts with the given values.
        Returns:
        a new list where each element is an IonInt.
      • newNull

        IonNull newNull()
        Constructs a new null.null instance.
      • newNullSexp

        IonSexp newNullSexp()
        Constructs a new null.sexp instance.
      • newEmptySexp

        IonSexp newEmptySexp()
        Constructs a new empty (not null) sexp instance.
      • newSexp

        IonSexp newSexp​(int[] values)
        Constructs a new sexp with given int child values.
        Parameters:
        values - the initial set of child values. If null, then the new instance will have IonValue.isNullValue() == true. Otherwise, the resulting sequence will contain new IonInts with the given values.
        Returns:
        a new sexp where each element is an IonInt.
      • newSexp

        IonSexp newSexp​(long[] values)
        Constructs a new sexp with given long child elements.
        Parameters:
        values - the initial set of child values. If null, then the new instance will have IonValue.isNullValue() == true. Otherwise, the resulting sequence will contain new IonInts with the given values.
        Returns:
        a new sexp where each element is an IonInt.
      • newNullString

        IonString newNullString()
        Constructs a new null.string instance.
      • newString

        IonString newString​(java.lang.String value)
        Constructs a new Ion string with the given value.
        Parameters:
        value - the text of the new string; may be null to make null.string.
      • newNullStruct

        IonStruct newNullStruct()
        Constructs a new null.struct instance.
      • newEmptyStruct

        IonStruct newEmptyStruct()
        Constructs a new empty (not null) struct instance.
      • newNullSymbol

        IonSymbol newNullSymbol()
        Constructs a new null.symbol instance.
      • newSymbol

        IonSymbol newSymbol​(java.lang.String value)
        Constructs a new Ion symbol with the given value.
        Parameters:
        value - the text of the symbol; may be null to make null.symbol.
      • newSymbol

        IonSymbol newSymbol​(SymbolToken value)
        Constructs a new Ion symbol with the given symbol token.

        This is an "expert method": correct use requires deep understanding of the Ion binary format. You almost certainly don't want to use it.

        Parameters:
        value - the text and/or SID of the symbol; may be null to make null.symbol.
      • newNullTimestamp

        IonTimestamp newNullTimestamp()
        Constructs a new null.timestamp instance.
      • newTimestamp

        IonTimestamp newTimestamp​(Timestamp value)
        Constructs a new timestamp instance with the given value.
        Parameters:
        value - may be null to make null.timestamp.
      • clone

        <T extends IonValue> T clone​(T value)
                              throws IonException
        Creates a deep copy of an Ion value. This method can properly clone IonDatagrams.

        The given value can be in the context of any ValueFactory, and the result will be in the context of this one. This allows you to shift data from one factory instance to another.

        Parameters:
        value - the value to copy.
        Returns:
        a deep copy of value, with no container.
        Throws:
        java.lang.NullPointerException - if value is null.
        IonException - if there's a problem creating the clone.
        UnknownSymbolException - if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
        See Also:
        IonValue.clone()