public interface ValueFactory
IonValue
s.
WARNING: This interface should not be implemented or extended by code outside of this library.
Modifier and Type | Method and Description |
---|---|
<T extends IonValue> |
clone(T value)
Creates a deep copy of an Ion value.
|
IonBlob |
newBlob(byte[] value)
Constructs a new Ion
blob instance, copying bytes from an array. |
IonBlob |
newBlob(byte[] value,
int offset,
int length)
Constructs a new Ion
blob , copying bytes from part of an array. |
IonBool |
newBool(boolean value)
Constructs a new
bool instance with the given value. |
IonBool |
newBool(java.lang.Boolean value)
Constructs a new
bool instance with the given value. |
IonClob |
newClob(byte[] value)
Constructs a new Ion
clob instance from a byte array. |
IonClob |
newClob(byte[] value,
int offset,
int length)
Constructs a new Ion
clob , copying bytes from part of an array. |
IonDecimal |
newDecimal(java.math.BigDecimal value)
Constructs a new Ion
decimal instance from a Java
BigDecimal . |
IonDecimal |
newDecimal(java.math.BigInteger value)
Constructs a new Ion
decimal instance from a Java
BigInteger . |
IonDecimal |
newDecimal(double value)
Constructs a new Ion
decimal instance from a Java
double . |
IonDecimal |
newDecimal(long value)
Constructs a new Ion
decimal instance from a Java
long . |
IonList |
newEmptyList()
Constructs a new empty (not null)
list instance. |
IonSexp |
newEmptySexp()
Constructs a new empty (not null)
sexp instance. |
IonStruct |
newEmptyStruct()
Constructs a new empty (not null)
struct instance. |
IonFloat |
newFloat(double value)
Constructs a new Ion
float instance from a Java
double . |
IonFloat |
newFloat(long value)
Constructs a new Ion
float instance from a Java
long . |
IonInt |
newInt(int value)
Constructs a new
int instance with the given value. |
IonInt |
newInt(long value)
Constructs a new
int instance with the given value. |
IonInt |
newInt(java.lang.Number value)
Constructs a new
int instance with the given value. |
IonList |
newList(java.util.Collection<? extends IonValue> values)
Deprecated.
This method can be invoked
(accidentally and incorrectly) with an
IonSequence !
Use either newList(IonValue...)
or newList() .addAll(Collection) . |
IonList |
newList(int[] values)
Constructs a new
list with given int children. |
IonList |
newList(IonSequence child)
Constructs a new
list with the given child. |
IonList |
newList(IonValue... children)
Constructs a new
list with the given children. |
IonList |
newList(long[] values)
Constructs a new
list with given long child
elements. |
IonNull |
newNull()
Constructs a new
null.null instance. |
IonValue |
newNull(IonType type)
Constructs a new Ion null value with the given type.
|
IonBlob |
newNullBlob()
Constructs a new
null.blob instance. |
IonBool |
newNullBool()
Constructs a new
null.bool instance. |
IonClob |
newNullClob()
Constructs a new
null.clob instance. |
IonDecimal |
newNullDecimal()
Constructs a new
null.decimal instance. |
IonFloat |
newNullFloat()
Constructs a new
null.float instance. |
IonInt |
newNullInt()
Constructs a new
null.int instance. |
IonList |
newNullList()
Constructs a new
null.list instance. |
IonSexp |
newNullSexp()
Constructs a new
null.sexp instance. |
IonString |
newNullString()
Constructs a new
null.string instance. |
IonStruct |
newNullStruct()
Constructs a new
null.struct instance. |
IonSymbol |
newNullSymbol()
Constructs a new
null.symbol instance. |
IonTimestamp |
newNullTimestamp()
Constructs a new
null.timestamp instance. |
IonSexp |
newSexp(java.util.Collection<? extends IonValue> values)
Deprecated.
This method can be invoked
(accidentally and incorrectly) with an
IonSequence !
Use either newSexp(IonValue...)
or newSexp() .addAll(Collection) . |
IonSexp |
newSexp(int[] values)
Constructs a new
sexp with given int child
values. |
IonSexp |
newSexp(IonSequence child)
Constructs a new
sexp with the given child. |
IonSexp |
newSexp(IonValue... children)
Constructs a new
sexp with given child elements. |
IonSexp |
newSexp(long[] values)
Constructs a new
sexp with given long child
elements. |
IonString |
newString(java.lang.String value)
Constructs a new Ion string with the given value.
|
IonSymbol |
newSymbol(java.lang.String value)
Constructs a new Ion symbol with the given value.
|
IonSymbol |
newSymbol(SymbolToken value)
Constructs a new Ion symbol with the given symbol token.
|
IonTimestamp |
newTimestamp(Timestamp value)
Constructs a new
timestamp instance with the given value. |
IonBlob newNullBlob()
null.blob
instance.IonBlob newBlob(byte[] value)
blob
instance, copying bytes from an array.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.IonBlob newBlob(byte[] value, int offset, int length)
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.
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
.java.lang.IndexOutOfBoundsException
- if the preconditions on the offset
and length
parameters
are not met.IonBool newNullBool()
null.bool
instance.IonBool newBool(boolean value)
bool
instance with the given value.value
- the new bool
's value.IonBool.booleanValue()
== value
.IonBool newBool(java.lang.Boolean value)
bool
instance with the given value.value
- the new bool
's value.
may be null
to make null.bool
.IonClob newNullClob()
null.clob
instance.IonClob newClob(byte[] value)
clob
instance from a byte array.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.IonClob newClob(byte[] value, int offset, int length)
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.
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
.java.lang.IndexOutOfBoundsException
- if the preconditions on the offset
and length
parameters
are not met.IonDecimal newNullDecimal()
null.decimal
instance.IonDecimal newDecimal(long value)
decimal
instance from a Java
long
.IonDecimal newDecimal(double value)
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)
.
IonDecimal newDecimal(java.math.BigInteger value)
decimal
instance from a Java
BigInteger
.IonDecimal newDecimal(java.math.BigDecimal value)
decimal
instance from a Java
BigDecimal
.
To create negative zero values, pass a Decimal
.IonFloat newNullFloat()
null.float
instance.IonFloat newFloat(long value)
float
instance from a Java
long
.IonFloat newFloat(double value)
float
instance from a Java
double
.IonInt newNullInt()
null.int
instance.IonInt newInt(int value)
int
instance with the given value.value
- the new int's value.IonInt newInt(long value)
int
instance with the given value.value
- the new int's value.IonInt newInt(java.lang.Number value)
int
instance with the given value.
The integer portion of the number is used, any fractional portion is
ignored.value
- the new int's value;
may be null
to make null.int
.IonList newNullList()
null.list
instance.IonList newEmptyList()
list
instance.@Deprecated IonList newList(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
IonSequence
!
Use either newList(IonValue...)
or newList()
.addAll(Collection)
.list
with given children.values
- the initial set of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.ContainedValueException
- if any value in values
has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if any value in values
is null.java.lang.IllegalArgumentException
- if any value in values
is an IonDatagram
.IonList newList(IonSequence child) throws ContainedValueException, java.lang.NullPointerException
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
.
child
- the initial child of the new list.java.lang.NullPointerException
- if child
is null.java.lang.IllegalArgumentException
- if child
is an IonDatagram
.ContainedValueException
- if child
has IonValue.getContainer()
!= null
.IonList newList(IonValue... children) throws ContainedValueException, java.lang.NullPointerException
list
with the given children.
Some edge cases are worth examples:
factory.newList(); // returns [] factory.newList((IonValue[]) null); // returns null.listFor clarity, applications should prefer
newEmptyList()
and
newNullList()
instead.children
- the initial sequence of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.java.lang.NullPointerException
- if any child is null.java.lang.IllegalArgumentException
- if any child is an IonDatagram
.ContainedValueException
- if any child has IonValue.getContainer()
!= null
.IonList newList(int[] values)
list
with given int
children.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 IonInt
s with
the given values.IonInt
.IonList newList(long[] values)
list
with given long
child
elements.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 IonInt
s with
the given values.IonInt
.IonNull newNull()
null.null
instance.IonValue newNull(IonType type)
type
- must not be Java null, but it may be IonType.NULL
.IonValue.isNullValue()
is
true
.IonSexp newNullSexp()
null.sexp
instance.IonSexp newEmptySexp()
sexp
instance.@Deprecated IonSexp newSexp(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
IonSequence
!
Use either newSexp(IonValue...)
or newSexp()
.addAll(Collection)
.sexp
with given child elements.values
- the initial set of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.ContainedValueException
- if any value in values
has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if any value in values
is null.java.lang.IllegalArgumentException
- if any value in values
is an IonDatagram
.IonSexp newSexp(IonSequence child) throws ContainedValueException, java.lang.NullPointerException
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
.
child
- the initial child of the new sexp.java.lang.NullPointerException
- if child
is null.java.lang.IllegalArgumentException
- if child
is an IonDatagram
.ContainedValueException
- if child
has IonValue.getContainer()
!= null
.IonSexp newSexp(IonValue... children) throws ContainedValueException, java.lang.NullPointerException
sexp
with given child elements.
Some edge cases are worth examples:
factory.newSexp(); // returns () factory.newSexp((IonValue[]) null); // returns null.sexpFor clarity, applications should prefer
newEmptySexp()
and
newNullSexp()
instead.children
- the initial set of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.java.lang.NullPointerException
- if any child is null.java.lang.IllegalArgumentException
- if any child is an IonDatagram
.ContainedValueException
- if any child has IonValue.getContainer()
!= null
.IonSexp newSexp(int[] values)
sexp
with given int
child
values.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 IonInt
s with
the given values.IonInt
.IonSexp newSexp(long[] values)
sexp
with given long
child
elements.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 IonInt
s with
the given values.IonInt
.IonString newNullString()
null.string
instance.IonString newString(java.lang.String value)
value
- the text of the new string;
may be null
to make null.string
.IonStruct newNullStruct()
null.struct
instance.IonStruct newEmptyStruct()
struct
instance.IonSymbol newNullSymbol()
null.symbol
instance.IonSymbol newSymbol(java.lang.String value)
value
- the text of the symbol;
may be null
to make null.symbol
.IonSymbol newSymbol(SymbolToken value)
This is an "expert method": correct use requires deep understanding of the Ion binary format. You almost certainly don't want to use it.
value
- the text and/or SID of the symbol;
may be null
to make null.symbol
.IonTimestamp newNullTimestamp()
null.timestamp
instance.IonTimestamp newTimestamp(Timestamp value)
timestamp
instance with the given value.value
- may be null
to make null.timestamp
.<T extends IonValue> T clone(T value) throws IonException
IonDatagram
s.
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.
value
- the value to copy.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.IonValue.clone()