Interface ValueFactory
- All Known Subinterfaces:
_Private_IonSystem,_Private_ValueFactory,IonSystem
- All Known Implementing Classes:
_Private_CurriedValueFactory
IonValues.
WARNING: This interface should not be implemented or extended by code outside of this library.
-
Method Summary
Modifier and TypeMethodDescription<T extends IonValue>
Tclone(T value) Creates a deep copy of an Ion value.newBlob(byte[] value) Constructs a new Ionblobinstance, copying bytes from an array.newBlob(byte[] value, int offset, int length) Constructs a new Ionblob, copying bytes from part of an array.newBool(boolean value) Constructs a newboolinstance with the given value.Constructs a newboolinstance with the given value.newClob(byte[] value) Constructs a new Ionclobinstance from a byte array.newClob(byte[] value, int offset, int length) Constructs a new Ionclob, copying bytes from part of an array.newDecimal(double value) Constructs a new Iondecimalinstance from a Javadouble.newDecimal(long value) Constructs a new Iondecimalinstance from a Javalong.newDecimal(BigDecimal value) Constructs a new Iondecimalinstance from a JavaBigDecimal.newDecimal(BigInteger value) Constructs a new Iondecimalinstance from a JavaBigInteger.Constructs a new empty (not null)listinstance.Constructs a new empty (not null)sexpinstance.Constructs a new empty (not null)structinstance.newFloat(double value) Constructs a new Ionfloatinstance from a Javadouble.newFloat(long value) Constructs a new Ionfloatinstance from a Javalong.newInt(int value) Constructs a newintinstance with the given value.newInt(long value) Constructs a newintinstance with the given value.Constructs a newintinstance with the given value.newList(int[] values) Constructs a newlistwith givenintchildren.newList(long[] values) Constructs a newlistwith givenlongchild elements.newList(IonSequence child) Constructs a newlistwith the given child.Constructs a newlistwith the given children.newList(Collection<? extends IonValue> values) Deprecated.newNull()Constructs a newnull.nullinstance.Constructs a new Ion null value with the given type.Constructs a newnull.blobinstance.Constructs a newnull.boolinstance.Constructs a newnull.clobinstance.Constructs a newnull.decimalinstance.Constructs a newnull.floatinstance.Constructs a newnull.intinstance.Constructs a newnull.listinstance.Constructs a newnull.sexpinstance.Constructs a newnull.stringinstance.Constructs a newnull.structinstance.Constructs a newnull.symbolinstance.Constructs a newnull.timestampinstance.newSexp(int[] values) Constructs a newsexpwith givenintchild values.newSexp(long[] values) Constructs a newsexpwith givenlongchild elements.newSexp(IonSequence child) Constructs a newsexpwith the given child.Constructs a newsexpwith given child elements.newSexp(Collection<? extends IonValue> values) Deprecated.This method can be invoked (accidentally and incorrectly) with anIonSequence! Use eithernewSexp(IonValue...)ornewSexp().addAll(Collection).Constructs a new Ion string with the given value.newSymbol(SymbolToken value) Constructs a new Ion symbol with the given symbol token.Constructs a new Ion symbol with the given value.newTimestamp(Timestamp value) Constructs a newtimestampinstance with the given value.
-
Method Details
-
newNullBlob
IonBlob newNullBlob()Constructs a newnull.blobinstance. -
newBlob
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
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:
IndexOutOfBoundsException- if the preconditions on theoffsetandlengthparameters are not met.
-
newNullBool
IonBool newNullBool()Constructs a newnull.boolinstance. -
newBool
Constructs a newboolinstance with the given value.- Parameters:
value- the newbool's value.- Returns:
- a bool with
.IonBool.booleanValue()== value
-
newBool
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
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
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:
IndexOutOfBoundsException- if the preconditions on theoffsetandlengthparameters are not met.
-
newNullDecimal
IonDecimal newNullDecimal()Constructs a newnull.decimalinstance. -
newDecimal
Constructs a new Iondecimalinstance from a Javalong. -
newDecimal
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
Constructs a new Iondecimalinstance from a JavaBigInteger. -
newDecimal
Constructs a new Iondecimalinstance from a JavaBigDecimal. To create negative zero values, pass aDecimal. -
newNullFloat
IonFloat newNullFloat()Constructs a newnull.floatinstance. -
newFloat
Constructs a new Ionfloatinstance from a Javalong. -
newFloat
Constructs a new Ionfloatinstance from a Javadouble. -
newNullInt
IonInt newNullInt()Constructs a newnull.intinstance. -
newInt
Constructs a newintinstance with the given value.- Parameters:
value- the new int's value.
-
newInt
Constructs a newintinstance with the given value.- Parameters:
value- the new int's value.
-
newInt
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(Collection<? extends IonValue> values) throws ContainedValueException, 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()!= nullNullPointerException- if any value invaluesis null.IllegalArgumentException- if any value invaluesis anIonDatagram.
-
newList
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:
NullPointerException- ifchildis null.IllegalArgumentException- ifchildis anIonDatagram.ContainedValueException- ifchildhas.IonValue.getContainer()!= null
-
newList
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:
NullPointerException- if any child is null.IllegalArgumentException- if any child is anIonDatagram.ContainedValueException- if any child has.IonValue.getContainer()!= null
-
newList
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
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
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(Collection<? extends IonValue> values) throws ContainedValueException, 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()!= nullNullPointerException- if any value invaluesis null.IllegalArgumentException- if any value invaluesis anIonDatagram.
-
newSexp
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:
NullPointerException- ifchildis null.IllegalArgumentException- ifchildis anIonDatagram.ContainedValueException- ifchildhas.IonValue.getContainer()!= null
-
newSexp
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:
NullPointerException- if any child is null.IllegalArgumentException- if any child is anIonDatagram.ContainedValueException- if any child has.IonValue.getContainer()!= null
-
newSexp
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
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
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
Constructs a new Ion symbol with the given value.- Parameters:
value- the text of the symbol; may benullto makenull.symbol.
-
newSymbol
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
Constructs a newtimestampinstance with the given value.- Parameters:
value- may benullto makenull.timestamp.
-
clone
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:
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:
-
IonSequence! Use eithernewList(IonValue...)ornewList().addAll(Collection).