Top Description Inners Fields Constructors Methods
com.amazon.ion.impl

public Class _Private_IonReaderBuilder

extends IonReaderBuilder
Class Inheritance
Known Direct Subclasses
com.amazon.ion.impl._Private_IonReaderBuilder.Mutable
Imports
com.amazon.ion.IonCatalog, .IonException, .IonReader, .IonTextReader, .IonValue, com.amazon.ion.util.InputStreamInterceptor, .IonStreamUtils, com.amazon.ion.system.IonReaderBuilder, java.io.ByteArrayInputStream, .EOFException, .IOException, .InputStream, .Reader, java.util.Collections, .List

IonReaderBuilder extension for internal use only.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
pack-priv static interface
pack-priv static interface
pack-priv static interface
public static class
private static class
_Private_IonReaderBuilder.TwoElementInputStream

InputStream that reads from exactly two delegate InputStreams in sequence.

Field Summary

Modifier and TypeField and Description
private _Private_LocalSymbolTableFactory

Constructor Summary

AccessConstructor and Description
private
private

Method Summary

Modifier and TypeMethod and Description
public IonReader
build(byte[]
the source of the Ion data, which 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. Must not be null.
ionData
,
int
must be non-negative and less than ionData.length.
offset
,
int
must be non-negative and offset+length must not exceed ionData.length.
length
)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over the given block of Ion data, detecting whether it's text or binary data.

public IonReader
build(InputStream
the source of the Ion data, which may be either Ion binary data or UTF-8 Ion text. Must not be null.
source
)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over the given stream of Ion data, detecting whether it's text or binary data.

public IonReader
build(Reader
the source of the Ion text data. Must not be null.
ionText
)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over Ion text data.

public IonReader
build(IonValue
must not be null.
value
)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over an IonValue data model.

public IonTextReader
build(String
the source of the Ion text data. Must not be null.
ionText
)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

References Deprecated IonTextReader is deprecated or references (maybe indirectly) at least one deprecated element.

Based on the builder's configuration properties, creates an new IonReader instance over Ion text data.

pack-priv static IonReader
pack-priv static IonReader
private static int

Returns:

the number of bytes read into `destination`.
fillToLengthOrStreamEnd
(InputStream
the source of the bytes to read.
source
,
byte[]
the destination for the bytes read.
destination
,
int
the number of bytes to attempt to read.
length
)

Reads from the given source into the given byte array, stopping once either

  1. `length` bytes have been read, or
  2. the end of the source stream has been reached, or
  3. the source stream throws an exception.
public void
private static boolean

Returns:

true if the first 'length' bytes in 'buffer' match the first 'length' bytes in the binary IVM.
startsWithIvm
(byte[]
up to the first four bytes in a stream.
buffer
,
int
the actual number of bytes in the buffer.
length
)

Determines whether a stream that begins with the bytes in the provided buffer could be binary Ion.

private static void
validateHeaderLength(int maxHeaderLength)

public IonReaderBuilder

Returns:

this builder instance, if mutable; otherwise a mutable copy of this builder.
withLstFactory
(_Private_LocalSymbolTableFactory
the factory to use, or LocalSymbolTable#DEFAULT_LST_FACTORY if null.
factory
)

Declares the _Private_LocalSymbolTableFactory to use when constructing applicable readers.

Inherited from com.amazon.ion.system.IonReaderBuilder:
addInputStreamInterceptorbuildcopygetBufferConfigurationgetCataloggetInputStreamInterceptorsimmutableisIncrementalReadingEnabledmutablemutationChecksetBufferConfigurationsetCatalogsetIncrementalReadingDisabledsetIncrementalReadingEnabledstandardvalidateCatalogwithBufferConfigurationwithCatalogwithIncrementalReadingEnabled

Field Detail

lstFactoryback to summary
private _Private_LocalSymbolTableFactory lstFactory

Constructor Detail

_Private_IonReaderBuilderback to summary
private _Private_IonReaderBuilder()
_Private_IonReaderBuilderback to summary
private _Private_IonReaderBuilder(_Private_IonReaderBuilder that)

Method Detail

buildback to summary
public IonReader build(byte[] ionData, int offset, int length)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Doc from com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over the given block of Ion data, detecting whether it's text or binary data.

This method will auto-detect and uncompress GZIPped Ion data.

Parameters
ionData:byte[]

the source of the Ion data, which 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. Must not be null.

offset:int

must be non-negative and less than ionData.length.

length:int

must be non-negative and offset+length must not exceed ionData.length.

Annotations
@Override
buildback to summary
public IonReader build(InputStream source)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Doc from com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over the given 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 users avoid adding additional buffering to the given stream.

Parameters
source:InputStream

the source of the Ion data, which may be either Ion binary data or UTF-8 Ion text. Must not be null.

Returns:IonReader

a new reader instance. Callers must call IonReader#close() when finished with it.

Annotations
@Override
buildback to summary
public IonReader build(Reader ionText)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Doc from com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over Ion text data.

Applications should generally use build(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:Reader

the source of the Ion text data. Must not be null.

Annotations
@Override
buildback to summary
public IonReader build(IonValue value)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Doc from com.amazon.ion.system.IonReaderBuilder.build.

Based on the builder's configuration properties, creates a new IonReader instance over an IonValue data model. Typically this is used to iterate over a collection, such as an IonStruct. 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:IonValue

must not be null.

Annotations
@Override
buildback to summary
public IonTextReader build(String ionText)

Implements abstract com.amazon.ion.system.IonReaderBuilder.build.

Doc from com.amazon.ion.system.IonReaderBuilder.build.

References Deprecated

IonTextReader is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Based on the builder's configuration properties, creates an new IonReader instance over Ion text data.

Parameters
ionText:String

the source of the Ion text data. Must not be null.

Annotations
@Override
buildReaderback to summary
pack-priv static IonReader buildReader(_Private_IonReaderBuilder builder, byte[] ionData, int offset, int length, _Private_IonReaderBuilder.IonReaderFromBytesFactoryBinary binary, _Private_IonReaderBuilder.IonReaderFromBytesFactoryText text)
buildReaderback to summary
pack-priv static IonReader buildReader(_Private_IonReaderBuilder builder, InputStream source, _Private_IonReaderBuilder.IonReaderFromInputStreamFactoryBinary binary, _Private_IonReaderBuilder.IonReaderFromInputStreamFactoryText text, List<InputStreamInterceptor> inputStreamInterceptors)
fillToLengthOrStreamEndback to summary
private static int fillToLengthOrStreamEnd(InputStream source, byte[] destination, int length)

Reads from the given source into the given byte array, stopping once either

  1. `length` bytes have been read, or
  2. the end of the source stream has been reached, or
  3. the source stream throws an exception.
Parameters
source:InputStream

the source of the bytes to read.

destination:byte[]

the destination for the bytes read.

length:int

the number of bytes to attempt to read.

Returns:int

the number of bytes read into `destination`.

setLstFactoryback to summary
public void setLstFactory(_Private_LocalSymbolTableFactory factory)
See Also
withLstFactory(_Private_LocalSymbolTableFactory)
startsWithIvmback to summary
private static boolean startsWithIvm(byte[] buffer, int length)

Determines whether a stream that begins with the bytes in the provided buffer could be binary Ion.

Parameters
buffer:byte[]

up to the first four bytes in a stream.

length:int

the actual number of bytes in the buffer.

Returns:boolean

true if the first 'length' bytes in 'buffer' match the first 'length' bytes in the binary IVM.

validateHeaderLengthback to summary
private static void validateHeaderLength(int maxHeaderLength)
withLstFactoryback to summary
public IonReaderBuilder withLstFactory(_Private_LocalSymbolTableFactory factory)

Declares the _Private_LocalSymbolTableFactory to use when constructing applicable readers.

Parameters
factory:_Private_LocalSymbolTableFactory

the factory to use, or LocalSymbolTable#DEFAULT_LST_FACTORY if null.

Returns:IonReaderBuilder

this builder instance, if mutable; otherwise a mutable copy of this builder.

See Also
setLstFactory(_Private_LocalSymbolTableFactory)
com.amazon.ion.impl back to summary

pack-priv Interface _Private_IonReaderBuilder.IonReaderFromBytesFactoryBinary

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public IonReader
makeReader(_Private_IonReaderBuilder builder, byte[] ionData, int offset, int length)

Method Detail

makeReaderback to summary
public IonReader makeReader(_Private_IonReaderBuilder builder, byte[] ionData, int offset, int length)
com.amazon.ion.impl back to summary

pack-priv Interface _Private_IonReaderBuilder.IonReaderFromBytesFactoryText

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public IonReader
makeReader(IonCatalog catalog, byte[] ionData, int offset, int length, _Private_LocalSymbolTableFactory lstFactory)

Method Detail

makeReaderback to summary
public IonReader makeReader(IonCatalog catalog, byte[] ionData, int offset, int length, _Private_LocalSymbolTableFactory lstFactory)
com.amazon.ion.impl back to summary

pack-priv Interface _Private_IonReaderBuilder.IonReaderFromInputStreamFactoryBinary

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public IonReader
makeReader(_Private_IonReaderBuilder builder, InputStream source, byte[] alreadyRead, int alreadyReadOff, int alreadyReadLen)

Method Detail

makeReaderback to summary
public IonReader makeReader(_Private_IonReaderBuilder builder, InputStream source, byte[] alreadyRead, int alreadyReadOff, int alreadyReadLen)
com.amazon.ion.impl back to summary

pack-priv Interface _Private_IonReaderBuilder.IonReaderFromInputStreamFactoryText

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public IonReader

Method Detail

makeReaderback to summary
public IonReader makeReader(IonCatalog catalog, InputStream source, _Private_LocalSymbolTableFactory lstFactory)
com.amazon.ion.impl back to summary

public Class _Private_IonReaderBuilder.Mutable

extends _Private_IonReaderBuilder
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public IonReaderBuilder
immutable()

Overrides com.amazon.ion.system.IonReaderBuilder.immutable.

Returns an immutable builder configured exactly like this one.

public IonReaderBuilder
mutable()

Overrides com.amazon.ion.system.IonReaderBuilder.mutable.

Returns a mutable builder configured exactly like this one.

protected void
Inherited from com.amazon.ion.impl._Private_IonReaderBuilder:
buildbuildbuildbuildbuildbuildReaderbuildReadersetLstFactorywithLstFactory

Constructor Detail

Mutableback to summary
public Mutable()
Mutableback to summary
public Mutable(IonReaderBuilder that)

Method Detail

immutableback to summary
public IonReaderBuilder immutable()

Overrides com.amazon.ion.system.IonReaderBuilder.immutable.

Doc from com.amazon.ion.system.IonReaderBuilder.immutable.

Returns an immutable builder configured exactly like this one.

Returns:IonReaderBuilder

this builder instance, if immutable; otherwise an immutable copy of this builder.

Annotations
@Override
mutableback to summary
public IonReaderBuilder mutable()

Overrides com.amazon.ion.system.IonReaderBuilder.mutable.

Doc from com.amazon.ion.system.IonReaderBuilder.mutable.

Returns a mutable builder configured exactly like this one.

Returns:IonReaderBuilder

this instance, if mutable; otherwise a mutable copy of this instance.

Annotations
@Override
mutationCheckback to summary
protected void mutationCheck()

Overrides com.amazon.ion.system.IonReaderBuilder.mutationCheck.

Doc from com.amazon.ion.system.IonReaderBuilder.mutationCheck.

NOT FOR APPLICATION USE!

Annotations
@Override
com.amazon.ion.impl back to summary

private final Class _Private_IonReaderBuilder.TwoElementInputStream

extends InputStream
Class Inheritance

InputStream that reads from exactly two delegate InputStreams in sequence. The second delegate remains in place even if it indicates EOF during a read call. This behavior differentiates this implementation from SequenceInputStream, which will return EOF forever after its final delegate returns EOF for the first time. The TwoElementSequenceInputStream allows the second delegate InputStream to return valid data if it subsequently receives more data, which is common when performing continuable reads.

Field Summary

Modifier and TypeField and Description
private final InputStream
first

The first InputStream in the sequence.

private InputStream
in

The current InputStream.

private final InputStream
last

The last InputStream in the sequence.

Constructor Summary

AccessConstructor and Description
private
TwoElementInputStream(final InputStream
first InputStream in the sequence.
first
,
final InputStream
last InputStream in the sequence.
last
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

Inherited from java.io.InputStream:
markmarkSupportednullInputStreamreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

firstback to summary
private final InputStream first

The first InputStream in the sequence.

inback to summary
private InputStream in

The current InputStream.

lastback to summary
private final InputStream last

The last InputStream in the sequence.

Constructor Detail

TwoElementInputStreamback to summary
private TwoElementInputStream(final InputStream first, final InputStream last)

Constructor.

Parameters
first:InputStream

first InputStream in the sequence.

last:InputStream

last InputStream in the sequence.

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.