Interface ValueFactory
-
- All Known Subinterfaces:
_Private_IonSystem,_Private_ValueFactory,IonSystem
- All Known Implementing Classes:
_Private_CurriedValueFactory
public interface ValueFactoryThe factory for allIonValues.WARNING: This interface should not be implemented or extended by code outside of this library.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description <T extends IonValue>
Tclone(T value)Creates a deep copy of an Ion value.IonBlobnewBlob(byte[] value)Constructs a new Ionblobinstance, copying bytes from an array.IonBlobnewBlob(byte[] value, int offset, int length)Constructs a new Ionblob, copying bytes from part of an array.IonBoolnewBool(boolean value)Constructs a newboolinstance with the given value.IonBoolnewBool(java.lang.Boolean value)Constructs a newboolinstance with the given value.IonClobnewClob(byte[] value)Constructs a new Ionclobinstance from a byte array.IonClobnewClob(byte[] value, int offset, int length)Constructs a new Ionclob, copying bytes from part of an array.IonDecimalnewDecimal(double value)Constructs a new Iondecimalinstance from a Javadouble.IonDecimalnewDecimal(long value)Constructs a new Iondecimalinstance from a Javalong.IonDecimalnewDecimal(java.math.BigDecimal value)Constructs a new Iondecimalinstance from a JavaBigDecimal.IonDecimalnewDecimal(java.math.BigInteger value)Constructs a new Iondecimalinstance from a JavaBigInteger.IonListnewEmptyList()Constructs a new empty (not null)listinstance.IonSexpnewEmptySexp()Constructs a new empty (not null)sexpinstance.IonStructnewEmptyStruct()Constructs a new empty (not null)structinstance.IonFloatnewFloat(double value)Constructs a new Ionfloatinstance from a Javadouble.IonFloatnewFloat(long value)Constructs a new Ionfloatinstance from a Javalong.IonIntnewInt(int value)Constructs a newintinstance with the given value.IonIntnewInt(long value)Constructs a newintinstance with the given value.IonIntnewInt(java.lang.Number value)Constructs a newintinstance with the given value.IonListnewList(int[] values)Constructs a newlistwith givenintchildren.IonListnewList(long[] values)Constructs a newlistwith givenlongchild elements.IonListnewList(IonSequence child)Constructs a newlistwith the given child.IonListnewList(IonValue... children)Constructs a newlistwith the given children.IonListnewList(java.util.Collection<? extends IonValue> values)Deprecated.This method can be invoked (accidentally and incorrectly) with anIonSequence! Use eithernewList(IonValue...)ornewList().addAll(Collection).IonNullnewNull()Constructs a newnull.nullinstance.IonValuenewNull(IonType type)Constructs a new Ion null value with the given type.IonBlobnewNullBlob()Constructs a newnull.blobinstance.IonBoolnewNullBool()Constructs a newnull.boolinstance.IonClobnewNullClob()Constructs a newnull.clobinstance.IonDecimalnewNullDecimal()Constructs a newnull.decimalinstance.IonFloatnewNullFloat()Constructs a newnull.floatinstance.IonIntnewNullInt()Constructs a newnull.intinstance.IonListnewNullList()Constructs a newnull.listinstance.IonSexpnewNullSexp()Constructs a newnull.sexpinstance.IonStringnewNullString()Constructs a newnull.stringinstance.IonStructnewNullStruct()Constructs a newnull.structinstance.IonSymbolnewNullSymbol()Constructs a newnull.symbolinstance.IonTimestampnewNullTimestamp()Constructs a newnull.timestampinstance.IonSexpnewSexp(int[] values)Constructs a newsexpwith givenintchild values.IonSexpnewSexp(long[] values)Constructs a newsexpwith givenlongchild elements.IonSexpnewSexp(IonSequence child)Constructs a newsexpwith the given child.IonSexpnewSexp(IonValue... children)Constructs a newsexpwith given child elements.IonSexpnewSexp(java.util.Collection<? extends IonValue> values)Deprecated.This method can be invoked (accidentally and incorrectly) with anIonSequence! Use eithernewSexp(IonValue...)ornewSexp().addAll(Collection).IonStringnewString(java.lang.String value)Constructs a new Ion string with the given value.IonSymbolnewSymbol(SymbolToken value)Constructs a new Ion symbol with the given symbol token.IonSymbolnewSymbol(java.lang.String value)Constructs a new Ion symbol with the given value.IonTimestampnewTimestamp(Timestamp value)Constructs a newtimestampinstance with the given value.
-
-
-
Method Detail
-
newNullBlob
IonBlob newNullBlob()
Constructs a newnull.blobinstance.
-
newBlob
IonBlob newBlob(byte[] value)
Constructs a new Ionblobinstance, 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 benullto create anull.blobvalue.
-
newBlob
IonBlob newBlob(byte[] value, int offset, int length)
Constructs a new Ionblob, copying bytes from part of an array.This method copies
lengthbytes 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 benullto create anull.blobvalue.offset- the offset within the array of the first byte to copy; must be non-negative and no larger thanbytes.length.length- the number of bytes to be copied from the given array; must be non-negative and no larger thanbytes.length - offset.- Throws:
java.lang.IndexOutOfBoundsException- if the preconditions on theoffsetandlengthparameters are not met.
-
newNullBool
IonBool newNullBool()
Constructs a newnull.boolinstance.
-
newBool
IonBool newBool(boolean value)
Constructs a newboolinstance with the given value.- Parameters:
value- the newbool's value.- Returns:
- a bool with
.IonBool.booleanValue()== value
-
newBool
IonBool newBool(java.lang.Boolean value)
Constructs a newboolinstance with the given value.- Parameters:
value- the newbool's value. may benullto makenull.bool.
-
newNullClob
IonClob newNullClob()
Constructs a newnull.clobinstance.
-
newClob
IonClob newClob(byte[] value)
Constructs a new Ionclobinstance from a byte array.- Parameters:
value- the data for the new clob, to be copied from the given array into the new instance. May benullto create anull.clobvalue.
-
newClob
IonClob newClob(byte[] value, int offset, int length)
Constructs a new Ionclob, copying bytes from part of an array.This method copies
lengthbytes 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 benullto create anull.clobvalue.offset- the offset within the array of the first byte to copy; must be non-negative an no larger thanbytes.length.length- the number of bytes to be copied from the given array; must be non-negative an no larger thanbytes.length - offset.- Throws:
java.lang.IndexOutOfBoundsException- if the preconditions on theoffsetandlengthparameters are not met.
-
newNullDecimal
IonDecimal newNullDecimal()
Constructs a newnull.decimalinstance.
-
newDecimal
IonDecimal newDecimal(long value)
Constructs a new Iondecimalinstance from a Javalong.
-
newDecimal
IonDecimal newDecimal(double value)
Constructs a new Iondecimalinstance from a Javadouble.Note that this does not generate the exact decimal representation of the
double's binary floating-point value as viaBigDecimal(double), but instead uses the more predictable behavior of matching the double's string representation as viaBigDecimal.valueOf(double).
-
newDecimal
IonDecimal newDecimal(java.math.BigInteger value)
Constructs a new Iondecimalinstance from a JavaBigInteger.
-
newDecimal
IonDecimal newDecimal(java.math.BigDecimal value)
Constructs a new Iondecimalinstance from a JavaBigDecimal. To create negative zero values, pass aDecimal.
-
newNullFloat
IonFloat newNullFloat()
Constructs a newnull.floatinstance.
-
newFloat
IonFloat newFloat(long value)
Constructs a new Ionfloatinstance from a Javalong.
-
newFloat
IonFloat newFloat(double value)
Constructs a new Ionfloatinstance from a Javadouble.
-
newNullInt
IonInt newNullInt()
Constructs a newnull.intinstance.
-
newInt
IonInt newInt(int value)
Constructs a newintinstance with the given value.- Parameters:
value- the new int's value.
-
newInt
IonInt newInt(long value)
Constructs a newintinstance with the given value.- Parameters:
value- the new int's value.
-
newInt
IonInt newInt(java.lang.Number value)
Constructs a newintinstance 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 benullto makenull.int.
-
newNullList
IonList newNullList()
Constructs a newnull.listinstance.
-
newEmptyList
IonList newEmptyList()
Constructs a new empty (not null)listinstance.
-
newList
@Deprecated IonList newList(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
Deprecated.This method can be invoked (accidentally and incorrectly) with anIonSequence! Use eithernewList(IonValue...)ornewList().addAll(Collection).Constructs a newlistwith given children.- Parameters:
values- the initial set of children. Ifnull, then the new instance will have.IonValue.isNullValue()== true- Throws:
ContainedValueException- if any value invalueshas.IonValue.getContainer()!= nulljava.lang.NullPointerException- if any value invaluesis null.java.lang.IllegalArgumentException- if any value invaluesis anIonDatagram.
-
newList
IonList newList(IonSequence child) throws ContainedValueException, java.lang.NullPointerException
Constructs a newlistwith 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 throwContainedValueException.- Parameters:
child- the initial child of the new list.- Throws:
java.lang.NullPointerException- ifchildis null.java.lang.IllegalArgumentException- ifchildis anIonDatagram.ContainedValueException- ifchildhas.IonValue.getContainer()!= null
-
newList
IonList newList(IonValue... children) throws ContainedValueException, java.lang.NullPointerException
Constructs a newlistwith the given children.Some edge cases are worth examples:
factory.newList(); // returns [] factory.newList((IonValue[]) null); // returns null.listFor clarity, applications should prefernewEmptyList()andnewNullList()instead.- Parameters:
children- the initial sequence of children. Ifnull, then the new instance will have.IonValue.isNullValue()== true- Throws:
java.lang.NullPointerException- if any child is null.java.lang.IllegalArgumentException- if any child is anIonDatagram.ContainedValueException- if any child has.IonValue.getContainer()!= null
-
newList
IonList newList(int[] values)
Constructs a newlistwith givenintchildren.- Parameters:
values- the initial set of child values. Ifnull, then the new instance will have. Otherwise, the resulting sequence will contain newIonValue.isNullValue()== trueIonInts with the given values.- Returns:
- a new list where each element is an
IonInt.
-
newList
IonList newList(long[] values)
Constructs a newlistwith givenlongchild elements.- Parameters:
values- the initial set of child values. Ifnull, then the new instance will have. Otherwise, the resulting sequence will contain newIonValue.isNullValue()== trueIonInts with the given values.- Returns:
- a new list where each element is an
IonInt.
-
newNull
IonNull newNull()
Constructs a newnull.nullinstance.
-
newNull
IonValue newNull(IonType type)
Constructs a new Ion null value with the given type.- Parameters:
type- must not be Java null, but it may beIonType.NULL.- Returns:
- a new value such that
IonValue.isNullValue()istrue.
-
newNullSexp
IonSexp newNullSexp()
Constructs a newnull.sexpinstance.
-
newEmptySexp
IonSexp newEmptySexp()
Constructs a new empty (not null)sexpinstance.
-
newSexp
@Deprecated IonSexp newSexp(java.util.Collection<? extends IonValue> values) throws ContainedValueException, java.lang.NullPointerException
Deprecated.This method can be invoked (accidentally and incorrectly) with anIonSequence! Use eithernewSexp(IonValue...)ornewSexp().addAll(Collection).Constructs a newsexpwith given child elements.- Parameters:
values- the initial set of children. Ifnull, then the new instance will have.IonValue.isNullValue()== true- Throws:
ContainedValueException- if any value invalueshas.IonValue.getContainer()!= nulljava.lang.NullPointerException- if any value invaluesis null.java.lang.IllegalArgumentException- if any value invaluesis anIonDatagram.
-
newSexp
IonSexp newSexp(IonSequence child) throws ContainedValueException, java.lang.NullPointerException
Constructs a newsexpwith 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 throwContainedValueException.- Parameters:
child- the initial child of the new sexp.- Throws:
java.lang.NullPointerException- ifchildis null.java.lang.IllegalArgumentException- ifchildis anIonDatagram.ContainedValueException- ifchildhas.IonValue.getContainer()!= null
-
newSexp
IonSexp newSexp(IonValue... children) throws ContainedValueException, java.lang.NullPointerException
Constructs a newsexpwith given child elements.Some edge cases are worth examples:
factory.newSexp(); // returns () factory.newSexp((IonValue[]) null); // returns null.sexpFor clarity, applications should prefernewEmptySexp()andnewNullSexp()instead.- Parameters:
children- the initial set of children. Ifnull, then the new instance will have.IonValue.isNullValue()== true- Throws:
java.lang.NullPointerException- if any child is null.java.lang.IllegalArgumentException- if any child is anIonDatagram.ContainedValueException- if any child has.IonValue.getContainer()!= null
-
newSexp
IonSexp newSexp(int[] values)
Constructs a newsexpwith givenintchild values.- Parameters:
values- the initial set of child values. Ifnull, then the new instance will have. Otherwise, the resulting sequence will contain newIonValue.isNullValue()== trueIonInts with the given values.- Returns:
- a new sexp where each element is an
IonInt.
-
newSexp
IonSexp newSexp(long[] values)
Constructs a newsexpwith givenlongchild elements.- Parameters:
values- the initial set of child values. Ifnull, then the new instance will have. Otherwise, the resulting sequence will contain newIonValue.isNullValue()== trueIonInts with the given values.- Returns:
- a new sexp where each element is an
IonInt.
-
newNullString
IonString newNullString()
Constructs a newnull.stringinstance.
-
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 benullto makenull.string.
-
newNullStruct
IonStruct newNullStruct()
Constructs a newnull.structinstance.
-
newEmptyStruct
IonStruct newEmptyStruct()
Constructs a new empty (not null)structinstance.
-
newNullSymbol
IonSymbol newNullSymbol()
Constructs a newnull.symbolinstance.
-
newSymbol
IonSymbol newSymbol(java.lang.String value)
Constructs a new Ion symbol with the given value.- Parameters:
value- the text of the symbol; may benullto makenull.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 benullto makenull.symbol.
-
newNullTimestamp
IonTimestamp newNullTimestamp()
Constructs a newnull.timestampinstance.
-
newTimestamp
IonTimestamp newTimestamp(Timestamp value)
Constructs a newtimestampinstance with the given value.- Parameters:
value- may benullto makenull.timestamp.
-
clone
<T extends IonValue> T clone(T value) throws IonException
Creates a deep copy of an Ion value. This method can properly cloneIonDatagrams.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- ifvalueis 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()
-
-