Interface IonSystem
- All Superinterfaces:
ValueFactory
- All Known Subinterfaces:
_Private_IonSystem
WARNING: This interface should not be implemented or extended by code outside of this library.
In general, IonValue instances returned from one system instance
are not interoperable with those returned by other instances.
The intended usage pattern is for an application to construct a single
IonSystem instance and use it throughout,
rather than constructing multiple systems and intermingling their use.
To create a copy of a value for use by a different system, use
ValueFactory.clone(IonValue).
To create an IonSystem,
see IonSystemBuilder.
Implementations of this interface are safe for use by multiple threads.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the catalog used by this system.Gets the default system loader.Gets the default system symbol table.getSystemSymbolTable(String ionVersionId) Gets a system symbol table for a specific version of Ion.iterate(byte[] ionData) Deprecated.Will cause a memory leak when reading a gzipped byte[].Creates an iterator over Ion data.iterate(InputStream ionData) Deprecated.Will cause a memory leak when reading a gzipped stream.Creates an iterator over a stream of Ion text data.Creates an iterator over a string containing Ion text data.Deprecated.UseĀnewBinaryWriter(OutputStream, SymbolTable...)instead.newBinaryWriter(SymbolTable... imports) Deprecated.UsenewBinaryWriter(OutputStream, SymbolTable...)instead.newBinaryWriter(OutputStream out, SymbolTable... imports) Creates a new writer that will encode binary Ion data, using the given shared symbol tables as imports.Constructs a new UTCtimestampinstance initialized so that it represents the time at which it was allocated, measured to the nearest millisecond.Creates a new empty datagram.newDatagram(IonValue initialChild) Creates a new datagram containing one value.newDatagram(SymbolTable... imports) Creates a new datagram, bootstrapped with imported symbol tables.Constructs a new loader instance using the default system catalog.newLoader(IonCatalog catalog) Constructs a new loader instance using the given catalog.newLocalSymbolTable(SymbolTable... imports) Creates a new local symbol table based on specific imported tables.newReader(byte[] ionData) Creates an newIonReaderinstance over a block of Ion data, detecting whether it's text or binary data.newReader(byte[] ionData, int offset, int len) Creates an newIonReaderinstance over a block of Ion data, detecting whether it's text or binary data.newReader(InputStream ionData) Creates a newIonReaderinstance over a stream of Ion data, detecting whether it's text or binary data.Creates an newIonReaderinstance over Ion text data.Creates an newIonReaderinstance over Ion text data.newSharedSymbolTable(IonReader reader) Materializes a shared symbol table from its serialized form.newSharedSymbolTable(IonReader reader, boolean alreadyOnStruct) Materializes a shared symbol table from its serialized form.newSharedSymbolTable(String name, int version, Iterator<String> newSymbols, SymbolTable... imports) Creates a new shared symbol table containing a given set of symbols.Creates a new writer that will write UTF-8 text to the given output stream.newTextWriter(OutputStream out, SymbolTable... imports) Creates a new writer that will write UTF-8 text to the given output stream, using the given shared symbol tables as imports.newTextWriter(Appendable out) Creates a new writer that will write text to the given output stream.newTextWriter(Appendable out, SymbolTable... imports) Creates a new writer that will write text to the given output stream, using the given shared symbol tables as imports.newUtcTimestamp(Date utcDate) Constructs a new UTCtimestampinstance initialized so that it represents the given time.newUtcTimestampFromMillis(long millis) Constructs a new UTCtimestampinitialized to represent the specified number of milliseconds since the standard base time known as "the epoch", namely 1970-01-01T00:00:00Z.Extracts the current value from a reader into anIonValue.newWriter(IonContainer container) Creates a new writer that will addIonValues to the given container.singleValue(byte[] ionData) Extracts a single value from Ion text or binary data.singleValue(byte[] ionData, int offset, int len) Extracts a single value from Ion text or binary data.singleValue(String ionText) Extracts a single value from Ion text data.Methods inherited from interface com.amazon.ion.ValueFactory
clone, newBlob, newBlob, newBool, newBool, newClob, newClob, newDecimal, newDecimal, newDecimal, newDecimal, newEmptyList, newEmptySexp, newEmptyStruct, newFloat, newFloat, newInt, newInt, newInt, newList, newList, newList, newList, newList, newNull, newNull, newNullBlob, newNullBool, newNullClob, newNullDecimal, newNullFloat, newNullInt, newNullList, newNullSexp, newNullString, newNullStruct, newNullSymbol, newNullTimestamp, newSexp, newSexp, newSexp, newSexp, newSexp, newString, newSymbol, newSymbol, newTimestamp
-
Method Details
-
getSystemSymbolTable
SymbolTable getSystemSymbolTable()Gets the default system symbol table.- Returns:
- not null.
-
getSystemSymbolTable
Gets a system symbol table for a specific version of Ion.- Parameters:
ionVersionId- must be of the form"$ion_X_Y".- Returns:
- the requested system table.
- Throws:
UnsupportedIonVersionException- if the requested version of Ion is not supported by this implementation.
-
getCatalog
IonCatalog getCatalog()Gets the catalog used by this system. Unless otherwise noted, all objects derived from this system will use this catalog.- Returns:
- this system's default catalog; not null.
-
newLocalSymbolTable
Creates a new local symbol table based on specific imported tables. If the first imported table is a system table, then the local table will use it appropriately. Otherwise, the local table will use this system's default system symbol table.- Parameters:
imports- the set of shared symbol tables to import. The first (and only the first) may be a system table.- Returns:
- a new local symbol table.
- Throws:
IllegalArgumentException- if any import is a local table, or if any but the first is a system table.NullPointerException- if any import is null.
-
newLoader
IonLoader newLoader()Constructs a new loader instance using the default system catalog. -
newLoader
Constructs a new loader instance using the given catalog.- Parameters:
catalog- may be null, in which case the loader will use the default system catalog.- See Also:
-
getLoader
IonLoader getLoader()Gets the default system loader. Applications may replace this loader with one configured appropriately, and then access it here.- Returns:
- not
null.
-
iterate
Creates an iterator over a stream of Ion text data. Values returned by the iterator have no container.The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
If the input source throws an
IOExceptionduring iteration, it will be wrapped in anIonException. See documentation there for tips on how to recover the cause.This method is suitable for use over unbounded streams with a reasonable schema.
Applications should generally use
iterate(InputStream)whenever possible, since this library has much faster Unicode decoding than the Java IO framework.Because this library performs its own buffering, it's recommended that you avoid adding additional buffering to the given stream.
- Parameters:
ionText- a stream of Ion text data. The caller is responsible for closing the Reader after iteration is complete.- Returns:
- a new iterator instance.
- Throws:
NullPointerException- ifionTextis null.IonException- if the source throwsIOException.
-
iterate
Deprecated.Will cause a memory leak when reading a gzipped stream. Useiterate(IonReader)instead.WARNING: Will cause a memory leak when reading a gzipped stream, use
Creates an iterator over a stream of Ion data, detecting whether it's text or binary data. Values returned by the iterator have no container.iterate(IonReader)instead.The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
If the input source throws an
IOExceptionduring iteration, it will be wrapped in anIonException. See documentation there for tips on how to recover the cause.This method is suitable for use over unbounded streams with a reasonable schema.
This method will auto-detect and uncompress GZIPped Ion data.
Because this library performs its own buffering, it's recommended that you avoid adding additional buffering to the given stream.
- Parameters:
ionData- a stream of Ion data. The caller is responsible for closing the InputStream after iteration is complete.- Returns:
- a new iterator instance.
- Throws:
NullPointerException- ifionDatais null.IonException- if the source throwsIOException.
-
iterate
Creates an iterator over a string containing Ion text data. Values returned by the iterator have no container.The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
- Parameters:
ionText- must not be null.- Returns:
- a new iterator instance.
- Throws:
NullPointerException- ifionTextis null.
-
iterate
Deprecated.Will cause a memory leak when reading a gzipped byte[]. Useiterate(IonReader)instead.WARNING: Will cause a memory leak when reading a gzipped byte[], use
Creates an iterator over Ion data. Values returned by the iterator have no container.iterate(IonReader)instead.The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
This method will auto-detect and uncompress GZIPped Ion data.
- Parameters:
ionData- may be either Ion binary data or (UTF-8) Ion text, or GZIPped Ion data. This method assumes ownership of the array and may modify it at will.- Returns:
- a new iterator instance.
- Throws:
NullPointerException- ifionDatais null.
-
iterate
Creates an iterator over Ion data. Values returned by the iterator have no container.
The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
- Parameters:
reader- source of the Ion data to iterate over.- Returns:
- a new iterator instance.
- Throws:
NullPointerException- ifreaderis null.
-
singleValue
Extracts a single value from Ion text data.- Parameters:
ionText- must not be null.- Returns:
- the first (and only) user value in the data; not null.
- Throws:
NullPointerException- ifionTextis null.UnexpectedEofException- if the data doesn't contain any user values.IonException- if the data does not contain exactly one user value.
-
singleValue
Extracts a single value from Ion text or binary data.This method will auto-detect and uncompress GZIPped Ion data.
- Parameters:
ionData- may be either Ion binary data or (UTF-8) Ion text, or GZIPped Ion data. This method assumes ownership of the array and may modify it at will.- Returns:
- the first (and only) user value in the data; not null.
- Throws:
NullPointerException- ifionDatais null.UnexpectedEofException- if the data doesn't contain any user values.IonException- if the data does not contain exactly one user value.
-
singleValue
Extracts a single value from Ion text or binary data.This method will auto-detect and uncompress GZIPped Ion data.
- Parameters:
ionData- is used only within the range of bytes starting atoffsetforlenbytes. The data in that range may be either Ion binary data, or UTF-8 Ion text.offset- must be non-negative and less thanionData.length.len- must be non-negative andoffset+lenmust not exceed- Returns:
- the first (and only) user value in the data; not null.
- Throws:
NullPointerException- ifionDatais null.UnexpectedEofException- if the data doesn't contain any user values.IonException- if the data does not contain exactly one user value.
-
newReader
Creates an newIonReaderinstance over Ion text data.The text is parsed incrementally by the reader, so any syntax errors will not be detected during this call.
- Parameters:
ionText- must not be null.
-
newReader
Creates an newIonReaderinstance over a block of Ion data, detecting whether it's text or binary data.This method will auto-detect and uncompress GZIPped Ion data.
- Parameters:
ionData- may be either Ion binary data, or UTF-8 Ion text. The reader retains a reference to the array, so its data must not be modified while the reader is active.
-
newReader
Creates an newIonReaderinstance over a block of Ion data, detecting whether it's text or binary data.This method will auto-detect and uncompress GZIPped Ion data.
- Parameters:
ionData- is used only within the range of bytes starting atoffsetforlenbytes. The data in that range may be either Ion binary data, or UTF-8 Ion text. The reader retains a reference to the array, so its data must not be modified while the reader is active.offset- must be non-negative and less thanionData.length.len- must be non-negative andoffset+lenmust not exceedionData.length.
-
newReader
Creates a newIonReaderinstance over a stream of Ion data, detecting whether it's text or binary data.This method will auto-detect and uncompress GZIPped Ion data.
Because this library performs its own buffering, it's recommended that you avoid adding additional buffering to the given stream.
- Parameters:
ionData- must not be null.- Returns:
- a new reader instance.
Callers must call
Closeable.close()when finished with it. - Throws:
IonException- if the source throwsIOException.
-
newReader
Creates an newIonReaderinstance over Ion text data.Applications should generally us
newReader(InputStream)whenever possible, since this library has much faster Unicode decoding than the Java IO framework.Because this library performs its own buffering, it's recommended that you avoid adding additional buffering to the given stream.
- Throws:
IonException- if the source throwsIOException.
-
newReader
Creates an newIonReaderinstance over anIonValuedata model. Typically this is used to iterate over a collection, such as anIonStruct. The given value and its children, if any, must not be modified until after the IonReader constructed by this method is closed. Violating this constraint results in undefined behavior.- Parameters:
value- must not be null.
-
newWriter
Creates a new writer that will addIonValues to the given container.- Parameters:
container- a container that will receive new children from the the returned writer. Must not be null.- Returns:
- a new
IonWriterinstance; notnull.
-
newTextWriter
Creates a new writer that will write UTF-8 text to the given output stream.- Parameters:
out- the stream that will receive UTF-8 Ion text data. Must not be null.- Returns:
- a new
IonWriterinstance; notnull. - See Also:
-
newTextWriter
Creates a new writer that will write text to the given output stream.- Parameters:
out- the stream that will receive Ion text data. Must not be null.- Returns:
- a new
IonWriterinstance; notnull. - See Also:
-
newTextWriter
Creates a new writer that will write UTF-8 text to the given output stream, using the given shared symbol tables as imports.The output stream will start with an Ion Version Marker and a local symbol table that uses the given
imports.- Parameters:
out- the stream that will receive UTF-8 Ion text data. Must not be null.imports- a sequence of shared symbol tables- Returns:
- a new
IonWriterinstance; notnull. - Throws:
IOException- if its thrown by the output stream.- See Also:
-
newTextWriter
Creates a new writer that will write text to the given output stream, using the given shared symbol tables as imports.The output stream will start with an Ion Version Marker and a local symbol table that uses the given
imports.- Parameters:
out- the stream that will receive Ion text data. Must not be null.imports- a sequence of shared symbol tables. The first (and only the first) may be a system table.- Returns:
- a new
IonWriterinstance; notnull. - Throws:
IOException- if its thrown by the output stream.- See Also:
-
newBinaryWriter
Creates a new writer that will encode binary Ion data, using the given shared symbol tables as imports.The output stream will start with an Ion Version Marker and a local symbol table that uses the given
imports.- Parameters:
out- the stream to receive binary Ion data; not null.imports- a sequence of shared symbol tables to import. The first (and only the first) may be a system table.- Returns:
- a new
IonWriterinstance; not null. - Throws:
IllegalArgumentException- if any import is a local table, or if any but the first is a system table.NullPointerException- if any import is null.
-
newBinaryWriter
Deprecated.UseĀnewBinaryWriter(OutputStream, SymbolTable...)instead.Creates a new writer that will encode binary Ion data.- Returns:
- a new
IonBinaryWriterinstance; notnull.
-
newBinaryWriter
Deprecated.UsenewBinaryWriter(OutputStream, SymbolTable...)instead.Creates a new writer that will encode binary Ion data, using the given shared symbol tables as imports.The output stream will be start with an Ion Version Marker and a local symbol table that uses the given
imports.- Parameters:
imports- a sequence of shared symbol tables- Returns:
- a new
IonBinaryWriterinstance; notnull.
-
newDatagram
IonDatagram newDatagram()Creates a new empty datagram.- Returns:
- a new datagram with no user values.
-
newDatagram
Creates a new datagram containing one value. If the given value is contained elsewhere, it is cloned before insertion.- Parameters:
initialChild- becomes the first and only (user) value in the datagram. The child'ssystemmust be this system. Ifnull, then the returned datagram will have no user values.- Returns:
- a new datagram.
- Throws:
IllegalArgumentException- ifinitialChildis anIonDatagram.
-
newDatagram
Creates a new datagram, bootstrapped with imported symbol tables. Generally an application will use this to aquire a datagram, then adds values to it, then callsIonDatagram.getBytes(byte[])(or similar) to extract binary data.- Parameters:
imports- the set of shared symbol tables to import. The first (and only the first) may be a system table.- Returns:
- a new datagram with no user values.
- Throws:
IllegalArgumentException- if any import is a local table, or if any but the first is a system table.- See Also:
-
newValue
Extracts the current value from a reader into anIonValue. The caller must position the reader on the correct value by callingIonReader.next()beforehand.- Returns:
- a new value object, not null.
-
newUtcTimestampFromMillis
Constructs a new UTCtimestampinitialized to represent the specified number of milliseconds since the standard base time known as "the epoch", namely 1970-01-01T00:00:00Z.- Parameters:
millis- the milliseconds since 1970-01-01T00:00:00Z.
-
newUtcTimestamp
Constructs a new UTCtimestampinstance initialized so that it represents the given time. As perDateclass, this will have millisecond precision.This is equivalent to
newUtcTimestampFromMillis(utcDate.getTime()).- Parameters:
utcDate- the time of the new instance; may benullto makenull.timestamp.
-
newCurrentUtcTimestamp
IonTimestamp newCurrentUtcTimestamp()Constructs a new UTCtimestampinstance initialized so that it represents the time at which it was allocated, measured to the nearest millisecond.
-