Top Description Methods
com.amazon.ion

public Interface ValueFactory

Known Direct Subinterfaces
com.amazon.ion.impl._Private_ValueFactory, com.amazon.ion.IonSystem
Known Direct Implementers
com.amazon.ion.impl._Private_CurriedValueFactory
Imports
java.math.BigDecimal, .BigInteger, java.util.Collection

The factory for all IonValues.

Warning

This interface should not be implemented or extended by code outside of this library.

Method Summary

Modifier and TypeMethod and Description
public <T extends IonValue> T

Returns:

a deep copy of value, with no container.
clone
(T
the value to copy.
value
)

Creates a deep copy of an Ion value.

public IonBlob
newBlob(byte[]
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.
value
)

Constructs a new Ion blob instance, copying bytes from an array.

public IonBlob
newBlob(byte[]
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.
value
,
int
the offset within the array of the first byte to copy; must be non-negative and no larger than bytes.length.
offset
,
int
the number of bytes to be copied from the given array; must be non-negative and no larger than bytes.length - offset.
length
)

Constructs a new Ion blob, copying bytes from part of an array.

public IonBool

Returns:

a bool with IonBool#booleanValue() == value.
newBool
(boolean
the new bool's value.
value
)

Constructs a new bool instance with the given value.

public IonBool
newBool(Boolean
the new bool's value. may be null to make null.bool.
value
)

Constructs a new bool instance with the given value.

public IonClob
newClob(byte[]
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.
value
)

Constructs a new Ion clob instance from a byte array.

public IonClob
newClob(byte[]
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.
value
,
int
the offset within the array of the first byte to copy; must be non-negative an no larger than bytes.length.
offset
,
int
the number of bytes to be copied from the given array; must be non-negative an no larger than bytes.length - offset.
length
)

Constructs a new Ion clob, copying bytes from part of an array.

public IonDecimal
newDecimal(long value)

Constructs a new Ion decimal instance from a Java long.

public IonDecimal
newDecimal(double value)

Constructs a new Ion decimal instance from a Java double.

public IonDecimal
newDecimal(BigInteger value)

Constructs a new Ion decimal instance from a Java BigInteger.

public IonDecimal
newDecimal(BigDecimal value)

Constructs a new Ion decimal instance from a Java BigDecimal.

public IonList
newEmptyList()

Constructs a new empty (not null) list instance.

public IonSexp
newEmptySexp()

Constructs a new empty (not null) sexp instance.

public IonStruct
newEmptyStruct()

Constructs a new empty (not null) struct instance.

public IonFloat
newFloat(long value)

Constructs a new Ion float instance from a Java long.

public IonFloat
newFloat(double value)

Constructs a new Ion float instance from a Java double.

public IonInt
newInt(int
the new int's value.
value
)

Constructs a new int instance with the given value.

public IonInt
newInt(long
the new int's value.
value
)

Constructs a new int instance with the given value.

public IonInt
newInt(Number
the new int's value; may be null to make null.int.
value
)

Constructs a new int instance with the given value.

public IonList
newList(Collection<? extends IonValue>
the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.
values
)
Deprecated This method can be invoked (accidentally and incorrectly) with an IonSequence!

Constructs a new list with given children.

public IonList
newList(IonSequence
the initial child of the new list.
child
)

Constructs a new list with the given child.

public IonList
newList(IonValue...
the initial sequence of children. If null, then the new instance will have IonValue#isNullValue() == true.
children
)

Constructs a new list with the given children.

public IonList

Returns:

a new list where each element is an IonInt.
newList
(int[]
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.
values
)

Constructs a new list with given int children.

public IonList

Returns:

a new list where each element is an IonInt.
newList
(long[]
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.
values
)

Constructs a new list with given long child elements.

public IonNull
newNull()

Constructs a new null.null instance.

public IonValue

Returns:

a new value such that IonValue#isNullValue() is true.
newNull
(IonType
must not be Java null, but it may be IonType#NULL.
type
)

Constructs a new Ion null value with the given type.

public IonBlob
newNullBlob()

Constructs a new null.blob instance.

public IonBool
newNullBool()

Constructs a new null.bool instance.

public IonClob
newNullClob()

Constructs a new null.clob instance.

public IonDecimal
newNullDecimal()

Constructs a new null.decimal instance.

public IonFloat
newNullFloat()

Constructs a new null.float instance.

public IonInt
newNullInt()

Constructs a new null.int instance.

public IonList
newNullList()

Constructs a new null.list instance.

public IonSexp
newNullSexp()

Constructs a new null.sexp instance.

public IonString
newNullString()

Constructs a new null.string instance.

public IonStruct
newNullStruct()

Constructs a new null.struct instance.

public IonSymbol
newNullSymbol()

Constructs a new null.symbol instance.

public IonTimestamp
newNullTimestamp()

Constructs a new null.timestamp instance.

public IonSexp
newSexp(Collection<? extends IonValue>
the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.
values
)
Deprecated This method can be invoked (accidentally and incorrectly) with an IonSequence!

Constructs a new sexp with given child elements.

public IonSexp
newSexp(IonSequence
the initial child of the new sexp.
child
)

Constructs a new sexp with the given child.

public IonSexp
newSexp(IonValue...
the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.
children
)

Constructs a new sexp with given child elements.

public IonSexp

Returns:

a new sexp where each element is an IonInt.
newSexp
(int[]
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.
values
)

Constructs a new sexp with given int child values.

public IonSexp

Returns:

a new sexp where each element is an IonInt.
newSexp
(long[]
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.
values
)

Constructs a new sexp with given long child elements.

public IonString
newString(String
the text of the new string; may be null to make null.string.
value
)

Constructs a new Ion string with the given value.

public IonSymbol
newSymbol(String
the text of the symbol; may be null to make null.symbol.
value
)

Constructs a new Ion symbol with the given value.

public IonSymbol
newSymbol(SymbolToken
the text and/or SID of the symbol; may be null to make null.symbol.
value
)

Constructs a new Ion symbol with the given symbol token.

public IonTimestamp
newTimestamp(Timestamp
may be null to make null.timestamp.
value
)

Constructs a new timestamp instance with the given value.

Method Detail

cloneback to summary
public <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:T

the value to copy.

Returns:T

a deep copy of value, with no container.

Exceptions
IonException:
if there's a problem creating the clone.
NullPointerException:
if value is null.
UnknownSymbolException:
if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
See Also
IonValue#clone()
newBlobback to summary
public IonBlob newBlob(byte[] value)

Constructs a new Ion blob instance, copying bytes from an array.

Parameters
value:byte[]

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.

newBlobback to summary
public 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:byte[]

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:int

the offset within the array of the first byte to copy; must be non-negative and no larger than bytes.length.

length:int

the number of bytes to be copied from the given array; must be non-negative and no larger than bytes.length - offset.

Exceptions
IndexOutOfBoundsException:
if the preconditions on the offset and length parameters are not met.
newBoolback to summary
public IonBool newBool(boolean value)

Constructs a new bool instance with the given value.

Parameters
value:boolean

the new bool's value.

Returns:IonBool

a bool with IonBool#booleanValue() == value.

newBoolback to summary
public IonBool newBool(Boolean value)

Constructs a new bool instance with the given value.

Parameters
value:Boolean

the new bool's value. may be null to make null.bool.

newClobback to summary
public IonClob newClob(byte[] value)

Constructs a new Ion clob instance from a byte array.

Parameters
value:byte[]

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.

newClobback to summary
public 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:byte[]

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:int

the offset within the array of the first byte to copy; must be non-negative an no larger than bytes.length.

length:int

the number of bytes to be copied from the given array; must be non-negative an no larger than bytes.length - offset.

Exceptions
IndexOutOfBoundsException:
if the preconditions on the offset and length parameters are not met.
newDecimalback to summary
public IonDecimal newDecimal(long value)

Constructs a new Ion decimal instance from a Java long.

newDecimalback to summary
public 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#BigDecimal(double), but instead uses the more predictable behavior of matching the double's string representation as via BigDecimal#valueOf(double).

newDecimalback to summary
public IonDecimal newDecimal(BigInteger value)

Constructs a new Ion decimal instance from a Java BigInteger.

newDecimalback to summary
public IonDecimal newDecimal(BigDecimal value)

Constructs a new Ion decimal instance from a Java BigDecimal. To create negative zero values, pass a Decimal.

newEmptyListback to summary
public IonList newEmptyList()

Constructs a new empty (not null) list instance.

newEmptySexpback to summary
public IonSexp newEmptySexp()

Constructs a new empty (not null) sexp instance.

newEmptyStructback to summary
public IonStruct newEmptyStruct()

Constructs a new empty (not null) struct instance.

newFloatback to summary
public IonFloat newFloat(long value)

Constructs a new Ion float instance from a Java long.

newFloatback to summary
public IonFloat newFloat(double value)

Constructs a new Ion float instance from a Java double.

newIntback to summary
public IonInt newInt(int value)

Constructs a new int instance with the given value.

Parameters
value:int

the new int's value.

newIntback to summary
public IonInt newInt(long value)

Constructs a new int instance with the given value.

Parameters
value:long

the new int's value.

newIntback to summary
public IonInt newInt(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:Number

the new int's value; may be null to make null.int.

newListback to summary
public IonList newList(Collection<? extends IonValue> values) throws ContainedValueException, NullPointerException

Deprecated

This method can be invoked (accidentally and incorrectly) with an IonSequence! Use either newList(IonValue...) or newList().addAll(Collection).

Constructs a new list with given children.

Parameters
values:Collection<? extends IonValue>

the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.

Annotations
@Deprecated
Exceptions
ContainedValueException:
if any value in values has IonValue#getContainer() != null.
NullPointerException:
if any value in values is null.
IllegalArgumentException:
if any value in values is an IonDatagram.
newListback to summary
public IonList newList(IonSequence child) throws ContainedValueException, NullPointerException

Constructs a new list with the given child.

This method is temporary until newList(Collection) is removed. It's sole purpose is to avoid the doomed attempt to add all of the parameter's children to the new list; that will always throw ContainedValueException.

Parameters
child:IonSequence

the initial child of the new list.

Exceptions
ContainedValueException:
if child has IonValue#getContainer() != null.
NullPointerException:
if child is null.
IllegalArgumentException:
if child is an IonDatagram.
newListback to summary
public IonList newList(IonValue... children) throws ContainedValueException, NullPointerException

Constructs a new list with the given children.

Some edge cases are worth examples:

    factory.newList();                     // returns []
    factory.newList((IonValue[]) null);    // returns null.list
For clarity, applications should prefer newEmptyList() and newNullList() instead.
Parameters
children:IonValue[]

the initial sequence of children. If null, then the new instance will have IonValue#isNullValue() == true.

Exceptions
ContainedValueException:
if any child has IonValue#getContainer() != null.
NullPointerException:
if any child is null.
IllegalArgumentException:
if any child is an IonDatagram.
newListback to summary
public IonList newList(int[] values)

Constructs a new list with given int children.

Parameters
values:int[]

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:IonList

a new list where each element is an IonInt.

newListback to summary
public IonList newList(long[] values)

Constructs a new list with given long child elements.

Parameters
values:long[]

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:IonList

a new list where each element is an IonInt.

newNullback to summary
public IonNull newNull()

Constructs a new null.null instance.

newNullback to summary
public IonValue newNull(IonType type)

Constructs a new Ion null value with the given type.

Parameters
type:IonType

must not be Java null, but it may be IonType#NULL.

Returns:IonValue

a new value such that IonValue#isNullValue() is true.

newNullBlobback to summary
public IonBlob newNullBlob()

Constructs a new null.blob instance.

newNullBoolback to summary
public IonBool newNullBool()

Constructs a new null.bool instance.

newNullClobback to summary
public IonClob newNullClob()

Constructs a new null.clob instance.

newNullDecimalback to summary
public IonDecimal newNullDecimal()

Constructs a new null.decimal instance.

newNullFloatback to summary
public IonFloat newNullFloat()

Constructs a new null.float instance.

newNullIntback to summary
public IonInt newNullInt()

Constructs a new null.int instance.

newNullListback to summary
public IonList newNullList()

Constructs a new null.list instance.

newNullSexpback to summary
public IonSexp newNullSexp()

Constructs a new null.sexp instance.

newNullStringback to summary
public IonString newNullString()

Constructs a new null.string instance.

newNullStructback to summary
public IonStruct newNullStruct()

Constructs a new null.struct instance.

newNullSymbolback to summary
public IonSymbol newNullSymbol()

Constructs a new null.symbol instance.

newNullTimestampback to summary
public IonTimestamp newNullTimestamp()

Constructs a new null.timestamp instance.

newSexpback to summary
public IonSexp newSexp(Collection<? extends IonValue> values) throws ContainedValueException, NullPointerException

Deprecated

This method can be invoked (accidentally and incorrectly) with an IonSequence! Use either newSexp(IonValue...) or newSexp().addAll(Collection).

Constructs a new sexp with given child elements.

Parameters
values:Collection<? extends IonValue>

the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.

Annotations
@Deprecated
Exceptions
ContainedValueException:
if any value in values has IonValue#getContainer() != null.
NullPointerException:
if any value in values is null.
IllegalArgumentException:
if any value in values is an IonDatagram.
newSexpback to summary
public IonSexp newSexp(IonSequence child) throws ContainedValueException, NullPointerException

Constructs a new sexp with the given child.

This method is temporary until newSexp(Collection) is removed. It's sole purpose is to avoid the doomed attempt to add all of the parameter's children to the new sequence; that will always throw ContainedValueException.

Parameters
child:IonSequence

the initial child of the new sexp.

Exceptions
ContainedValueException:
if child has IonValue#getContainer() != null.
NullPointerException:
if child is null.
IllegalArgumentException:
if child is an IonDatagram.
newSexpback to summary
public IonSexp newSexp(IonValue... children) throws ContainedValueException, NullPointerException

Constructs a new sexp with given child elements.

Some edge cases are worth examples:

    factory.newSexp();                     // returns ()
    factory.newSexp((IonValue[]) null);    // returns null.sexp
For clarity, applications should prefer newEmptySexp() and newNullSexp() instead.
Parameters
children:IonValue[]

the initial set of children. If null, then the new instance will have IonValue#isNullValue() == true.

Exceptions
ContainedValueException:
if any child has IonValue#getContainer() != null.
NullPointerException:
if any child is null.
IllegalArgumentException:
if any child is an IonDatagram.
newSexpback to summary
public IonSexp newSexp(int[] values)

Constructs a new sexp with given int child values.

Parameters
values:int[]

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:IonSexp

a new sexp where each element is an IonInt.

newSexpback to summary
public IonSexp newSexp(long[] values)

Constructs a new sexp with given long child elements.

Parameters
values:long[]

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:IonSexp

a new sexp where each element is an IonInt.

newStringback to summary
public IonString newString(String value)

Constructs a new Ion string with the given value.

Parameters
value:String

the text of the new string; may be null to make null.string.

newSymbolback to summary
public IonSymbol newSymbol(String value)

Constructs a new Ion symbol with the given value.

Parameters
value:String

the text of the symbol; may be null to make null.symbol.

newSymbolback to summary
public 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:SymbolToken

the text and/or SID of the symbol; may be null to make null.symbol.

newTimestampback to summary
public IonTimestamp newTimestamp(Timestamp value)

Constructs a new timestamp instance with the given value.

Parameters
value:Timestamp

may be null to make null.timestamp.