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()
ValueFactorynull.blob instance.newNullBlob in interface ValueFactorypublic IonBlob newBlob(byte[] value)
ValueFactoryblob instance, copying bytes from an array.newBlob in interface ValueFactoryvalue - 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)
ValueFactoryblob, 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 ValueFactoryvalue - 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()
ValueFactorynull.bool instance.newNullBool in interface ValueFactorypublic IonBool newBool(boolean value)
ValueFactorybool instance with the given value.newBool in interface ValueFactoryvalue - the new bool's value.IonBool.booleanValue() == value.public IonBool newBool(java.lang.Boolean value)
ValueFactorybool instance with the given value.newBool in interface ValueFactoryvalue - the new bool's value.
may be null to make null.bool.public IonClob newNullClob()
ValueFactorynull.clob instance.newNullClob in interface ValueFactorypublic IonClob newClob(byte[] value)
ValueFactoryclob instance from a byte array.newClob in interface ValueFactoryvalue - 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)
ValueFactoryclob, 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 ValueFactoryvalue - 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()
ValueFactorynull.decimal instance.newNullDecimal in interface ValueFactorypublic IonDecimal newDecimal(long value)
ValueFactorydecimal instance from a Java
long.newDecimal in interface ValueFactorypublic IonDecimal newDecimal(double value)
ValueFactorydecimal 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 ValueFactorypublic IonDecimal newDecimal(java.math.BigInteger value)
ValueFactorydecimal instance from a Java
BigInteger.newDecimal in interface ValueFactorypublic IonDecimal newDecimal(java.math.BigDecimal value)
ValueFactorydecimal instance from a Java
BigDecimal.
To create negative zero values, pass a Decimal.newDecimal in interface ValueFactorypublic IonFloat newNullFloat()
ValueFactorynull.float instance.newNullFloat in interface ValueFactorypublic IonFloat newFloat(long value)
ValueFactoryfloat instance from a Java
long.newFloat in interface ValueFactorypublic IonFloat newFloat(double value)
ValueFactoryfloat instance from a Java
double.newFloat in interface ValueFactorypublic IonInt newNullInt()
ValueFactorynull.int instance.newNullInt in interface ValueFactorypublic IonInt newInt(int value)
ValueFactoryint instance with the given value.newInt in interface ValueFactoryvalue - the new int's value.public IonInt newInt(long value)
ValueFactoryint instance with the given value.newInt in interface ValueFactoryvalue - the new int's value.public IonInt newInt(java.lang.Number value)
ValueFactoryint instance with the given value.
The integer portion of the number is used, any fractional portion is
ignored.newInt in interface ValueFactoryvalue - the new int's value;
may be null to make null.int.public IonList newNullList()
ValueFactorynull.list instance.newNullList in interface ValueFactorypublic IonList newEmptyList()
ValueFactorylist instance.newEmptyList in interface ValueFactory@Deprecated public IonList newList(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
ValueFactorylist with given children.newList in interface ValueFactoryvalues - 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
ValueFactorylist 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 ValueFactoryfirstChild - 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
ValueFactorylist 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 ValueFactory.newEmptyList() and
ValueFactory.newNullList() instead.newList in interface ValueFactoryvalues - 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)
ValueFactorylist with given int children.newList in interface ValueFactoryvalues - 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.IonInt.public IonList newList(long[] values)
ValueFactorylist with given long child
elements.newList in interface ValueFactoryvalues - 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.IonInt.public IonNull newNull()
ValueFactorynull.null instance.newNull in interface ValueFactorypublic IonValue newNull(IonType type)
ValueFactorynewNull in interface ValueFactorytype - must not be Java null, but it may be IonType.NULL.IonValue.isNullValue() is
true.public IonSexp newNullSexp()
ValueFactorynull.sexp instance.newNullSexp in interface ValueFactorypublic IonSexp newEmptySexp()
ValueFactorysexp instance.newEmptySexp in interface ValueFactory@Deprecated public IonSexp newSexp(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
ValueFactorysexp with given child elements.newSexp in interface ValueFactoryvalues - 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
ValueFactorysexp 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 ValueFactoryfirstChild - 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
ValueFactorysexp 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 ValueFactory.newEmptySexp() and
ValueFactory.newNullSexp() instead.newSexp in interface ValueFactoryvalues - 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)
ValueFactorysexp with given int child
values.newSexp in interface ValueFactoryvalues - 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.IonInt.public IonSexp newSexp(long[] values)
ValueFactorysexp with given long child
elements.newSexp in interface ValueFactoryvalues - 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.IonInt.public IonString newNullString()
ValueFactorynull.string instance.newNullString in interface ValueFactorypublic IonString newString(java.lang.String value)
ValueFactorynewString in interface ValueFactoryvalue - the text of the new string;
may be null to make null.string.public IonStruct newNullStruct()
ValueFactorynull.struct instance.newNullStruct in interface ValueFactorypublic IonStruct newEmptyStruct()
ValueFactorystruct instance.newEmptyStruct in interface ValueFactorypublic IonSymbol newNullSymbol()
ValueFactorynull.symbol instance.newNullSymbol in interface ValueFactorypublic IonSymbol newSymbol(java.lang.String value)
ValueFactorynewSymbol in interface ValueFactoryvalue - the text of the symbol;
may be null to make null.symbol.public IonSymbol newSymbol(SymbolToken value)
ValueFactoryThis 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 ValueFactoryvalue - the text and/or SID of the symbol;
may be null to make null.symbol.public IonTimestamp newNullTimestamp()
ValueFactorynull.timestamp instance.newNullTimestamp in interface ValueFactorypublic IonTimestamp newTimestamp(Timestamp value)
ValueFactorytimestamp instance with the given value.newTimestamp in interface ValueFactoryvalue - may be null to make null.timestamp.public <T extends IonValue> T clone(T value) throws IonException
ValueFactoryIonDatagrams.
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 ValueFactoryvalue - 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()