public abstract class _Private_CurriedValueFactory extends java.lang.Object implements ValueFactory
Helper for implementing curried container insertion methods such as
IonStruct.put(String)
.
Modifier | Constructor and Description |
---|---|
protected |
_Private_CurriedValueFactory(ValueFactory factory) |
Modifier and Type | Method and Description |
---|---|
<T extends IonValue> |
clone(T value)
Creates a deep copy of an Ion value.
|
protected abstract void |
handle(IonValue newValue)
Subclasses override this to do something with each newly-constructed
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.
|
IonList |
newList(int[] values)
Constructs a new
list with given int children. |
IonList |
newList(IonSequence firstChild)
Constructs a new
list with the given child. |
IonList |
newList(IonValue... values)
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.
|
IonSexp |
newSexp(int[] values)
Constructs a new
sexp with given int child
values. |
IonSexp |
newSexp(IonSequence firstChild)
Constructs a new
sexp with the given child. |
IonSexp |
newSexp(IonValue... values)
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. |
protected _Private_CurriedValueFactory(ValueFactory factory)
factory
- must not be null.protected abstract void handle(IonValue newValue)
newValue
- was just constructed by myFactory
.public IonBlob newNullBlob()
ValueFactory
null.blob
instance.newNullBlob
in interface ValueFactory
public IonBlob newBlob(byte[] value)
ValueFactory
blob
instance, copying bytes from an array.newBlob
in interface ValueFactory
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.public IonBlob newBlob(byte[] value, int offset, int length)
ValueFactory
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.
newBlob
in interface ValueFactory
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
.public IonBool newNullBool()
ValueFactory
null.bool
instance.newNullBool
in interface ValueFactory
public IonBool newBool(boolean value)
ValueFactory
bool
instance with the given value.newBool
in interface ValueFactory
value
- the new bool
's value.IonBool.booleanValue()
== value
.public IonBool newBool(java.lang.Boolean value)
ValueFactory
bool
instance with the given value.newBool
in interface ValueFactory
value
- the new bool
's value.
may be null
to make null.bool
.public IonClob newNullClob()
ValueFactory
null.clob
instance.newNullClob
in interface ValueFactory
public IonClob newClob(byte[] value)
ValueFactory
clob
instance from a byte array.newClob
in interface ValueFactory
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.public IonClob newClob(byte[] value, int offset, int length)
ValueFactory
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.
newClob
in interface ValueFactory
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
.public IonDecimal newNullDecimal()
ValueFactory
null.decimal
instance.newNullDecimal
in interface ValueFactory
public IonDecimal newDecimal(long value)
ValueFactory
decimal
instance from a Java
long
.newDecimal
in interface ValueFactory
public IonDecimal newDecimal(double value)
ValueFactory
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
in interface ValueFactory
public IonDecimal newDecimal(java.math.BigInteger value)
ValueFactory
decimal
instance from a Java
BigInteger
.newDecimal
in interface ValueFactory
public IonDecimal newDecimal(java.math.BigDecimal value)
ValueFactory
decimal
instance from a Java
BigDecimal
.
To create negative zero values, pass a Decimal
.newDecimal
in interface ValueFactory
public IonFloat newNullFloat()
ValueFactory
null.float
instance.newNullFloat
in interface ValueFactory
public IonFloat newFloat(long value)
ValueFactory
float
instance from a Java
long
.newFloat
in interface ValueFactory
public IonFloat newFloat(double value)
ValueFactory
float
instance from a Java
double
.newFloat
in interface ValueFactory
public IonInt newNullInt()
ValueFactory
null.int
instance.newNullInt
in interface ValueFactory
public IonInt newInt(int value)
ValueFactory
int
instance with the given value.newInt
in interface ValueFactory
value
- the new int's value.public IonInt newInt(long value)
ValueFactory
int
instance with the given value.newInt
in interface ValueFactory
value
- the new int's value.public IonInt newInt(java.lang.Number value)
ValueFactory
int
instance with the given value.
The integer portion of the number is used, any fractional portion is
ignored.newInt
in interface ValueFactory
value
- the new int's value;
may be null
to make null.int
.public IonList newNullList()
ValueFactory
null.list
instance.newNullList
in interface ValueFactory
public IonList newEmptyList()
ValueFactory
list
instance.newEmptyList
in interface ValueFactory
@Deprecated public IonList newList(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
list
with given children.newList
in interface ValueFactory
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.public IonList newList(IonSequence firstChild) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
list
with the given child.
This method is temporary until ValueFactory.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
.
newList
in interface ValueFactory
firstChild
- the initial child of the new list.ContainedValueException
- if child
has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if child
is null.public IonList newList(IonValue... values) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
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
ValueFactory.newEmptyList()
and
ValueFactory.newNullList()
instead.newList
in interface ValueFactory
values
- the initial sequence of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.ContainedValueException
- if any child has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if any child is null.public IonList newList(int[] values)
ValueFactory
list
with given int
children.newList
in interface ValueFactory
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
.public IonList newList(long[] values)
ValueFactory
list
with given long
child
elements.newList
in interface ValueFactory
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
.public IonNull newNull()
ValueFactory
null.null
instance.newNull
in interface ValueFactory
public IonValue newNull(IonType type)
ValueFactory
newNull
in interface ValueFactory
type
- must not be Java null, but it may be IonType.NULL
.IonValue.isNullValue()
is
true
.public IonSexp newNullSexp()
ValueFactory
null.sexp
instance.newNullSexp
in interface ValueFactory
public IonSexp newEmptySexp()
ValueFactory
sexp
instance.newEmptySexp
in interface ValueFactory
@Deprecated public IonSexp newSexp(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
sexp
with given child elements.newSexp
in interface ValueFactory
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.public IonSexp newSexp(IonSequence firstChild) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
sexp
with the given child.
This method is temporary until ValueFactory.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
.
newSexp
in interface ValueFactory
firstChild
- the initial child of the new sexp.ContainedValueException
- if child
has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if child
is null.public IonSexp newSexp(IonValue... values) throws ContainedValueException, java.lang.NullPointerException
ValueFactory
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
ValueFactory.newEmptySexp()
and
ValueFactory.newNullSexp()
instead.newSexp
in interface ValueFactory
values
- the initial set of children. If null
, then the new
instance will have IonValue.isNullValue()
== true
.ContainedValueException
- if any child has IonValue.getContainer()
!= null
.java.lang.NullPointerException
- if any child is null.public IonSexp newSexp(int[] values)
ValueFactory
sexp
with given int
child
values.newSexp
in interface ValueFactory
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
.public IonSexp newSexp(long[] values)
ValueFactory
sexp
with given long
child
elements.newSexp
in interface ValueFactory
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
.public IonString newNullString()
ValueFactory
null.string
instance.newNullString
in interface ValueFactory
public IonString newString(java.lang.String value)
ValueFactory
newString
in interface ValueFactory
value
- the text of the new string;
may be null
to make null.string
.public IonStruct newNullStruct()
ValueFactory
null.struct
instance.newNullStruct
in interface ValueFactory
public IonStruct newEmptyStruct()
ValueFactory
struct
instance.newEmptyStruct
in interface ValueFactory
public IonSymbol newNullSymbol()
ValueFactory
null.symbol
instance.newNullSymbol
in interface ValueFactory
public IonSymbol newSymbol(java.lang.String value)
ValueFactory
newSymbol
in interface ValueFactory
value
- the text of the symbol;
may be null
to make null.symbol
.public IonSymbol newSymbol(SymbolToken value)
ValueFactory
This is an "expert method": correct use requires deep understanding of the Ion binary format. You almost certainly don't want to use it.
newSymbol
in interface ValueFactory
value
- the text and/or SID of the symbol;
may be null
to make null.symbol
.public IonTimestamp newNullTimestamp()
ValueFactory
null.timestamp
instance.newNullTimestamp
in interface ValueFactory
public IonTimestamp newTimestamp(Timestamp value)
ValueFactory
timestamp
instance with the given value.newTimestamp
in interface ValueFactory
value
- may be null
to make null.timestamp
.public <T extends IonValue> T clone(T value) throws IonException
ValueFactory
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.
clone
in interface ValueFactory
value
- the value to copy.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()