public interface IonSystem extends ValueFactory
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.
IonSystemBuilder
Modifier and Type | Method and Description |
---|---|
IonCatalog |
getCatalog()
Gets the catalog used by this system.
|
IonLoader |
getLoader()
Gets the default system loader.
|
SymbolTable |
getSystemSymbolTable()
Gets the default system symbol table.
|
SymbolTable |
getSystemSymbolTable(String ionVersionId)
Gets a system symbol table for a specific version of Ion.
|
Iterator<IonValue> |
iterate(byte[] ionData)
Creates an iterator over Ion data.
|
Iterator<IonValue> |
iterate(InputStream ionData)
Creates an iterator over a stream of Ion data,
detecting whether it's text or binary data.
|
Iterator<IonValue> |
iterate(Reader ionText)
Creates an iterator over a stream of Ion text data.
|
Iterator<IonValue> |
iterate(String ionText)
Creates an iterator over a string containing Ion text data.
|
IonWriter |
newBinaryWriter(OutputStream out,
SymbolTable... imports)
Creates a new writer that will encode binary Ion data,
using the given shared symbol tables as imports.
|
IonTimestamp |
newCurrentUtcTimestamp()
Constructs a new UTC
timestamp instance initialized so that
it represents the time at which it was allocated, measured to the nearest
millisecond. |
IonDatagram |
newDatagram()
Creates a new empty datagram.
|
IonDatagram |
newDatagram(IonValue initialChild)
Creates a new datagram containing one value.
|
IonDatagram |
newDatagram(SymbolTable... imports)
Creates a new datagram, bootstrapped with imported symbol tables.
|
IonLoader |
newLoader()
Constructs a new loader instance using the
default system catalog.
|
IonLoader |
newLoader(IonCatalog catalog)
Constructs a new loader instance using the given catalog.
|
SymbolTable |
newLocalSymbolTable(SymbolTable... imports)
Creates a new local symbol table based on specific imported tables.
|
IonReader |
newReader(byte[] ionData)
Creates an new
IonReader instance over a block of Ion data,
detecting whether it's text or binary data. |
IonReader |
newReader(byte[] ionData,
int offset,
int len)
Creates an new
IonReader instance over a block of Ion data,
detecting whether it's text or binary data. |
IonReader |
newReader(InputStream ionData)
Creates a new
IonReader instance over a stream of Ion data,
detecting whether it's text or binary data. |
IonReader |
newReader(IonValue value)
|
IonReader |
newReader(Reader ionText)
Creates an new
IonReader instance over Ion text data. |
IonReader |
newReader(String ionText)
Creates an new
IonReader instance over Ion text data. |
SymbolTable |
newSharedSymbolTable(IonReader reader)
Materializes a shared symbol table from its serialized form.
|
SymbolTable |
newSharedSymbolTable(IonReader reader,
boolean alreadyOnStruct)
Materializes a shared symbol table from its serialized form.
|
SymbolTable |
newSharedSymbolTable(String name,
int version,
Iterator<String> newSymbols,
SymbolTable... imports)
Creates a new shared symbol table containing a given set of symbols.
|
IonWriter |
newTextWriter(Appendable out)
Creates a new writer that will write text to the given output
stream.
|
IonWriter |
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.
|
IonWriter |
newTextWriter(OutputStream out)
Creates a new writer that will write UTF-8 text to the given output
stream.
|
IonWriter |
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.
|
IonTimestamp |
newUtcTimestamp(Date utcDate)
Constructs a new UTC
timestamp instance initialized so that
it represents the given time. |
IonTimestamp |
newUtcTimestampFromMillis(long millis)
Constructs a new UTC
timestamp initialized to represent
the specified number of milliseconds since the standard base time known
as "the epoch", namely 1970-01-01T00:00:00Z. |
IonValue |
newValue(IonReader reader)
Extracts the current value from a reader into an
IonValue . |
IonWriter |
newWriter(IonContainer container)
Creates a new writer that will add
IonValue s to the given
container. |
IonValue |
singleValue(byte[] ionData)
Extracts a single value from Ion text or binary data.
|
IonValue |
singleValue(String ionText)
Extracts a single value from Ion text data.
|
clone, newBlob, newBlob, newBool, newBool, newClob, newClob, newDecimal, newDecimal, newDecimal, newDecimal, newEmptyList, newEmptySexp, newEmptyStruct, newFloat, newFloat, newInt, newInt, newInt, newList, newList, newList, newList, newNull, newNull, newNullBlob, newNullBool, newNullClob, newNullDecimal, newNullFloat, newNullInt, newNullList, newNullSexp, newNullString, newNullStruct, newNullSymbol, newNullTimestamp, newSexp, newSexp, newSexp, newSexp, newString, newSymbol, newSymbol, newTimestamp
SymbolTable getSystemSymbolTable()
SymbolTable getSystemSymbolTable(String ionVersionId) throws UnsupportedIonVersionException
ionVersionId
- must be of the form "$ion_X_Y"
.UnsupportedIonVersionException
- if the requested version of
Ion is not supported by this implementation.IonCatalog getCatalog()
SymbolTable newLocalSymbolTable(SymbolTable... imports)
imports
- the set of shared symbol tables to import.
The first (and only the first) may be a system table.IllegalArgumentException
- if any import is a local table,
or if any but the first is a system table.NullPointerException
- if any import is null.SymbolTable newSharedSymbolTable(String name, int version, Iterator<String> newSymbols, SymbolTable... imports)
version
is larger than 1, the prior version of the
named table is retrieved from the catalog and all of its symbols
are added.
imports
, add all of its
declared symbols.
newSymbols
.
This method is intended for use by utilities that are defining new
symbol tables for use by applications. The result will typically be
added to an IonCatalog
which is responsible for persistence.
Shared symbol tables are serialized via
SymbolTable.writeTo(IonWriter)
and materialized via
newSharedSymbolTable(IonReader)
.
name
- the symbol table name, a non-empty string.version
- at least one.newSymbols
- provides symbol names; may be null.imports
- other tables from which to import symbols.IonException
- if version > 1
and the prior version does
not exist in this system's catalog.SymbolTable newSharedSymbolTable(IonReader reader)
reader
- must not be null.SymbolTable newSharedSymbolTable(IonReader reader, boolean alreadyOnStruct)
reader
- must not be null.alreadyOnStruct
- is true if the caller has aleady next-ed onto the struct, false if a next call is neededIonLoader newLoader()
IonLoader newLoader(IonCatalog catalog)
catalog
- may be null, in which case the loader will use the
default system catalog.newLoader()
IonLoader getLoader()
null
.Iterator<IonValue> iterate(Reader ionText)
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 IOException
during iteration, it
will be wrapped in an IonException
. 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 UTF-8 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.
ionText
- a stream of Ion text data. The caller is responsible for
closing the Reader after iteration is complete.NullPointerException
- if ionText
is null.IonException
- if the source throws IOException
.Iterator<IonValue> iterate(InputStream ionData)
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 IOException
during iteration, it
will be wrapped in an IonException
. 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.
ionData
- a stream of Ion data. The caller is responsible for
closing the InputStream after iteration is complete.NullPointerException
- if ionData
is null.IonException
- if the source throws IOException
.Iterator<IonValue> iterate(String ionText)
The iterator will automatically consume Ion system IDs and local symbol tables; they will not be returned by the iterator.
ionText
- must not be null.NullPointerException
- if ionText
is null.Iterator<IonValue> iterate(byte[] ionData)
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.
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.NullPointerException
- if ionData
is null.IonValue singleValue(String ionText)
ionText
- must not be null.NullPointerException
- if ionText
is null.UnexpectedEofException
- if the data doesn't contain any user
values.IonException
- if the data does not contain exactly one user
value.IonValue singleValue(byte[] ionData)
This method will auto-detect and uncompress GZIPped Ion data.
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.NullPointerException
- if ionData
is null.UnexpectedEofException
- if the data doesn't contain any user
values.IonException
- if the data does not contain exactly one user
value.IonReader newReader(String ionText)
IonReader
instance over Ion text data.
The text is parsed incrementally by the reader, so any syntax errors will not be detected during this call.
ionText
- must not be null.IonReader newReader(byte[] ionData)
IonReader
instance over a block of Ion data,
detecting whether it's text or binary data.
This method will auto-detect and uncompress GZIPped Ion data.
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.IonReader newReader(byte[] ionData, int offset, int len)
IonReader
instance over a block of Ion data,
detecting whether it's text or binary data.
This method will auto-detect and uncompress GZIPped Ion data.
ionData
- is used only within the range of bytes starting at
offset
for len
bytes.
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 than ionData.length
.len
- must be non-negative and offset+len
must not exceed
ionData.length
.IonReader newReader(InputStream ionData)
IonReader
instance 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.
ionData
- must not be null.Closeable.close()
when finished with it.IonException
- if the source throws IOException
.IonReader newReader(Reader ionText)
IonReader
instance over Ion text data.
Applications should generally us newReader(InputStream)
whenever possible, since this library has much faster UTF-8 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.
IonException
- if the source throws IOException
.IonReader newReader(IonValue value)
IonReader
instance over an IonValue
data
model. Typically this is used to iterate over a collection, such as an
IonStruct
.value
- must not be null.IonWriter newWriter(IonContainer container)
IonValue
s to the given
container.container
- a container that will receive new children from the
the returned writer.
Must not be null.IonWriter
instance; not null
.IonWriter newTextWriter(OutputStream out)
out
- the stream that will receive UTF-8 Ion text data.
Must not be null.IonWriter
instance; not null
.IonTextWriterBuilder
IonWriter newTextWriter(Appendable out)
out
- the stream that will receive Ion text data.
Must not be null.IonWriter
instance; not null
.IonTextWriterBuilder
IonWriter newTextWriter(OutputStream out, SymbolTable... imports) throws IOException
The output stream will start with an Ion Version Marker and a
local symbol table that uses the given imports
.
out
- the stream that will receive UTF-8 Ion text data.
Must not be null.imports
- a sequence of shared symbol tablesIonWriter
instance; not null
.IOException
- if its thrown by the output stream.IonTextWriterBuilder
IonWriter newTextWriter(Appendable out, SymbolTable... imports) throws IOException
The output stream will start with an Ion Version Marker and a
local symbol table that uses the given imports
.
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.IonWriter
instance; not null
.IOException
- if its thrown by the output stream.IonTextWriterBuilder
IonWriter newBinaryWriter(OutputStream out, SymbolTable... imports)
The output stream will start with an Ion Version Marker and a
local symbol table that uses the given imports
.
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.IonWriter
instance; not null.IllegalArgumentException
- if any import is a local table,
or if any but the first is a system table.NullPointerException
- if any import is null.IonDatagram newDatagram()
IonDatagram newDatagram(IonValue initialChild)
initialChild
- becomes the first and only (user) value in the
datagram. The child's system
must be this system.
If null
, then the returned datagram will have no
user values.IllegalArgumentException
- if initialChild
is an IonDatagram
.IonDatagram newDatagram(SymbolTable... imports)
IonDatagram.getBytes()
(or similar) to extract binary data.imports
- the set of shared symbol tables to import.
The first (and only the first) may be a system table.IllegalArgumentException
- if any import is a local table,
or if any but the first is a system table.newLocalSymbolTable(SymbolTable...)
IonValue newValue(IonReader reader)
IonValue
.
The caller must position the reader on the correct value by calling
IonReader.next()
beforehand.IonTimestamp newUtcTimestampFromMillis(long millis)
timestamp
initialized to represent
the specified number of milliseconds since the standard base time known
as "the epoch", namely 1970-01-01T00:00:00Z.millis
- the milliseconds since 1970-01-01T00:00:00Z.IonTimestamp newUtcTimestamp(Date utcDate)
timestamp
instance initialized so that
it represents the given time. As per Date
class, this will have
millisecond precision.
This is equivalent to
newUtcTimestampFromMillis(utcDate.getTime())
.
utcDate
- the time of the new instance;
may be null
to make null.timestamp
.IonTimestamp newCurrentUtcTimestamp()
timestamp
instance initialized so that
it represents the time at which it was allocated, measured to the nearest
millisecond.