Interface IonDatagram
-
- All Superinterfaces:
java.lang.Cloneable,java.util.Collection<IonValue>,IonContainer,IonSequence,IonValue,java.lang.Iterable<IonValue>,java.util.List<IonValue>
- All Known Subinterfaces:
_Private_IonDatagram
public interface IonDatagram extends IonSequence
A datagram is a "top-level" container of Ion values, and the granularity of binary encoding Ion content.WARNING: This interface should not be implemented or extended by code outside of this library. Some inherited methods are not yet implemented or are unsupported for datagrams.
Along with the normal user values, datagrams contain system values, notably the symbol table(s) used to atomize all symbols. Most uses of a datagram will not see system values, but applications that need visibility into that data can use the
system*()methods.
-
-
Field Summary
-
Fields inherited from interface com.amazon.ion.IonValue
EMPTY_ARRAY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ValueFactoryadd(int index)This inherited method is not yet supported by datagrams.voidadd(int index, IonValue element)This inherited method is not yet supported by datagrams.booleanaddAll(int index, java.util.Collection<? extends IonValue> c)This inherited method is not yet supported by datagrams.voidaddTypeAnnotation(java.lang.String annotation)This inherited method is not supported by datagrams.intbyteSize()Gets the number of bytes used to encode this datagram.IonDatagramclone()Creates a copy of this value and all of its children.IonValueget(int index)Gets a selected non-system element from this datagram.byte[]getBytes()Copies the binary-encoded form of this datagram into a new byte array.intgetBytes(byte[] dst)Deprecated.intgetBytes(byte[] dst, int offset)Deprecated.intgetBytes(java.io.OutputStream out)Copies the binary-encoded form of this datagram to a specified stream.IonContainergetContainer()Gets the container of this value, ornullif this is not part of one.SymbolTablegetSymbolTable()This inherited method is not supported by datagrams because there's no single symbol table used across the contents.booleanisNullValue()Returnsfalseat every call, since datagrams cannot be null.java.util.Iterator<IonValue>iterator()Creates an iterator providing the (direct) elements of this datagram.voidmakeNull()This inherited method is not supported by datagrams.IonValueset(int index, IonValue element)This inherited method is not yet supported by datagrams.intsize()Gets the number of elements in the datagram, not counting system elements.IonValuesystemGet(int index)Gets a selected element from this datagram, potentially getting a hidden system element (such as a symbol table).java.util.ListIterator<IonValue>systemIterator()Iterate all values in the datagram, including the otherwise-hidden system values such as version markers and symbol tables.intsystemSize()Gets the number of elements in the datagram, including system elements such as version markers and symbol tables.byte[]toBytes()Deprecated.UsegetBytes()instead, which is renamed for consistency with other interfaces.-
Methods inherited from interface com.amazon.ion.IonContainer
clear, isEmpty, remove
-
Methods inherited from interface com.amazon.ion.IonSequence
add, add, addAll, contains, containsAll, extract, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, subList, toArray, toArray
-
Methods inherited from interface com.amazon.ion.IonValue
accept, clearTypeAnnotations, equals, getFieldId, getFieldName, getFieldNameSymbol, getSystem, getType, getTypeAnnotations, getTypeAnnotationSymbols, hashCode, hasTypeAnnotation, isReadOnly, makeReadOnly, removeFromContainer, removeTypeAnnotation, setTypeAnnotations, setTypeAnnotationSymbols, topLevelValue, toPrettyString, toString, toString, writeTo
-
-
-
-
Method Detail
-
add
void add(int index, IonValue element) throws ContainedValueException, java.lang.NullPointerExceptionThis inherited method is not yet supported by datagrams.Vote for issue amazon-ion/ion-java/issues/48 if you need this.
- Specified by:
addin interfaceIonSequence- Specified by:
addin interfacejava.util.List<IonValue>element- is the element to be appended to this sequence.- Throws:
java.lang.UnsupportedOperationException- at every call.ContainedValueException- ifchildis already part of a container.java.lang.NullPointerException- ifchildisnull.- See Also:
- amazon-ion/ion-java/issues/48
-
add
ValueFactory add(int index) throws ContainedValueException, java.lang.NullPointerException
This inherited method is not yet supported by datagrams.Vote for issue amazon-ion/ion-java/issues/48 if you need this.
- Specified by:
addin interfaceIonSequence- Throws:
java.lang.UnsupportedOperationException- at every call.ContainedValueExceptionjava.lang.NullPointerException- See Also:
- amazon-ion/ion-java/issues/48
-
addAll
boolean addAll(int index, java.util.Collection<? extends IonValue> c)This inherited method is not yet supported by datagrams.Vote for issue amazon-ion/ion-java/issues/47 if you need this.
- Specified by:
addAllin interfaceIonSequence- Specified by:
addAllin interfacejava.util.List<IonValue>- Parameters:
index- index at which to insert first element from the specified collection.c- elements to be inserted into this sequence.- Returns:
trueif this sequence changed as a result of the call.- Throws:
java.lang.UnsupportedOperationException- at every call.- See Also:
- amazon-ion/ion-java/issues/47
-
set
IonValue set(int index, IonValue element)
This inherited method is not yet supported by datagrams.Vote for issue amazon-ion/ion-java/issues/50 if you need this.
- Specified by:
setin interfaceIonSequence- Specified by:
setin interfacejava.util.List<IonValue>- Parameters:
index- index of the element to replace.element- element to be stored at the specified position.- Returns:
- the element previously at the specified index.
- Throws:
java.lang.UnsupportedOperationException- at every call.- See Also:
- amazon-ion/ion-java/issues/50
-
isNullValue
boolean isNullValue()
Returnsfalseat every call, since datagrams cannot be null.- Specified by:
isNullValuein interfaceIonValue- Returns:
false
-
getContainer
IonContainer getContainer()
Gets the container of this value, ornullif this is not part of one.Datagrams always return
nullfrom this method, since by definition they have no container.- Specified by:
getContainerin interfaceIonValue
-
size
int size()
Gets the number of elements in the datagram, not counting system elements.- Specified by:
sizein interfacejava.util.Collection<IonValue>- Specified by:
sizein interfaceIonContainer- Specified by:
sizein interfacejava.util.List<IonValue>- Returns:
- the number of elements, zero if
this.isNullValue().
-
systemSize
int systemSize()
Gets the number of elements in the datagram, including system elements such as version markers and symbol tables. Unless your application needs to be aware of such low-level details, you almost certainly want to usesize()instead.- See Also:
size()
-
get
IonValue get(int index) throws java.lang.IndexOutOfBoundsException
Gets a selected non-system element from this datagram.- Specified by:
getin interfaceIonSequence- Specified by:
getin interfacejava.util.List<IonValue>- Parameters:
index- must be less than.size()- Returns:
- the selected element; not
null. - Throws:
java.lang.IndexOutOfBoundsException- if the index is bad.
-
systemGet
IonValue systemGet(int index) throws java.lang.IndexOutOfBoundsException
Gets a selected element from this datagram, potentially getting a hidden system element (such as a symbol table). Unless your application needs to be aware of such low-level details, you almost certainly want to useget(int)instead.- Parameters:
index- must be less than.systemSize()- Returns:
- the selected element; not
null. - Throws:
java.lang.IndexOutOfBoundsException- if the index is bad.- See Also:
get(int)
-
iterator
java.util.Iterator<IonValue> iterator()
Creates an iterator providing the (direct) elements of this datagram. Elements will be returned in order of their appearance in the Ion representation.This iterator returns only user values, ignoring symbol tables and other system values. It does not support the
Iterator.remove()operation.- Specified by:
iteratorin interfacejava.util.Collection<IonValue>- Specified by:
iteratorin interfaceIonContainer- Specified by:
iteratorin interfacejava.lang.Iterable<IonValue>- Specified by:
iteratorin interfacejava.util.List<IonValue>- Returns:
- a new iterator, not
null. - See Also:
systemIterator()
-
systemIterator
java.util.ListIterator<IonValue> systemIterator()
Iterate all values in the datagram, including the otherwise-hidden system values such as version markers and symbol tables. Unless your application needs to be aware of such low-level details, you almost certainly want to useiterator()instead.This iterator does not support the modification methods
Iterator.remove(),ListIterator.add(Object), orListIterator.set(Object).- Returns:
- not null.
- See Also:
iterator()
-
byteSize
int byteSize() throws IonExceptionGets the number of bytes used to encode this datagram. As a side effect, this method encodes the entire datagram into Ion binary format.- Returns:
- the number of bytes in the binary encoding of this datagram.
- Throws:
IonException- if there's an error encoding the data.
-
toBytes
@Deprecated byte[] toBytes() throws IonExceptionDeprecated.UsegetBytes()instead, which is renamed for consistency with other interfaces.Copies the binary-encoded form of this datagram into a new byte array.- Returns:
- a new, non-empty byte array containing the encoded datagram.
- Throws:
IonException- if there's an error encoding the data.
-
getBytes
byte[] getBytes() throws IonExceptionCopies the binary-encoded form of this datagram into a new byte array.- Returns:
- a new, non-empty byte array containing the encoded datagram.
- Throws:
IonException- if there's an error encoding the data.
-
getBytes
@Deprecated int getBytes(byte[] dst) throws IonExceptionDeprecated.Copies the binary-encoded form of this datagram into a given array.The given array must be large enough to contain all the bytes of this datagram.
An invocation of this method of the form
dg.get(a)behaves in exactly the same way as the invocation:dg.get(a, 0)- Parameters:
dst- the array into which bytes are to be written.- Returns:
- the number of bytes copied into
dst. - Throws:
IonException- if there's an error encoding the data.java.lang.IndexOutOfBoundsException- ifdst.lengthis smaller than the result ofbyteSize().- See Also:
getBytes(byte[],int)
-
getBytes
@Deprecated int getBytes(byte[] dst, int offset) throws IonExceptionDeprecated.Copies the binary-encoded form of this datagram into a given sub-array.The given subarray must be large enough to contain all the bytes of this datagram.
- Parameters:
dst- the array into which bytes are to be written.offset- the offset within the array of the first byte to be written; must be non-negative and no larger thandst.length- Returns:
- the number of bytes copied into
dst. - Throws:
IonException- if there's an error encoding the data.java.lang.IndexOutOfBoundsException- if(dst.length - offset)is smaller than the result ofbyteSize().
-
getBytes
int getBytes(java.io.OutputStream out) throws java.io.IOException, IonExceptionCopies the binary-encoded form of this datagram to a specified stream.- Parameters:
out- the output stream to which to write the data.- Returns:
- the number of bytes written.
- Throws:
IonException- if there's an error encoding the data.java.io.IOException- if an error occurs writing the data to the stream.
-
getSymbolTable
SymbolTable getSymbolTable()
This inherited method is not supported by datagrams because there's no single symbol table used across the contents. Each value contained by the datagram may have its own symbol table.- Specified by:
getSymbolTablein interfaceIonValue- Returns:
- nothing, always throws an exception.
- Throws:
java.lang.UnsupportedOperationException- at every call.
-
addTypeAnnotation
void addTypeAnnotation(java.lang.String annotation)
This inherited method is not supported by datagrams.- Specified by:
addTypeAnnotationin interfaceIonValue- Parameters:
annotation- as a string value.- Throws:
java.lang.UnsupportedOperationException- at every call.
-
makeNull
void makeNull()
This inherited method is not supported by datagrams.- Specified by:
makeNullin interfaceIonContainer- Throws:
java.lang.UnsupportedOperationException- at every call.
-
clone
IonDatagram clone() throws UnknownSymbolException
Description copied from interface:IonValueCreates a copy of this value and all of its children. The cloned value may use the same shared symbol tables, but it will have an independent local symbol table if necessary. The cloned value will be modifiable regardless of whether this instanceIonValue.isReadOnly().The cloned value will be created in the context of the same
ValueFactoryas this instance; if you want a copy using a different factory, then useValueFactory.clone(IonValue)instead.- Specified by:
clonein interfaceIonContainer- Specified by:
clonein interfaceIonSequence- Specified by:
clonein interfaceIonValue- Throws:
UnknownSymbolException- if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
-
-