Top Description Methods
com.amazon.ion.util

public Interface InputStreamInterceptor

Known Direct Implementers
com.amazon.ion.util.GzipStreamInterceptor
Imports
com.amazon.ion.IonReader, com.amazon.ion.system.IonReaderBuilder, java.io.IOException, .InputStream

An interceptor to be consulted by the com.amazon.ion.system.IonReaderBuilder when creating an IonReader over a user-provided stream. This allows users to transform a stream's raw bytes into valid text or binary Ion.
See Also
com.amazon.ion.system.IonReaderBuilder#addInputStreamInterceptor(InputStreamInterceptor), com.amazon.ion.system.IonSystemBuilder#withReaderBuilder(IonReaderBuilder)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a constant String.
formatName
()

The name of the format the interceptor recognizes.

public boolean

Returns:

true if the candidate byte sequence matches; otherwise, false.
isMatch
(byte[]
the candidate byte sequence.
candidate
,
int
the offset into the candidate bytes to begin matching.
offset
,
int
the number of bytes (beginning at 'offset') in `candidate`. Must be greater than or equal to numberOfBytesNeededToDetermineMatch().
length
)

Determines whether the given candidate byte sequence matches this format.

public InputStream

Returns:

a new InputStream.
newInputStream
(InputStream
the stream containing bytes in this format.
interceptedStream
)

Creates a new InputStream that transforms the bytes in the given InputStream into valid text or binary Ion.

public int

Returns:

the length in bytes.
numberOfBytesNeededToDetermineMatch
()

The number of bytes required to be read from the beginning of the stream in order to determine whether it matches the format relevant to this interceptor.

Method Detail

formatNameback to summary
public String formatName()

The name of the format the interceptor recognizes.

Returns:String

a constant String.

isMatchback to summary
public boolean isMatch(byte[] candidate, int offset, int length)

Determines whether the given candidate byte sequence matches this format.

Parameters
candidate:byte[]

the candidate byte sequence.

offset:int

the offset into the candidate bytes to begin matching.

length:int

the number of bytes (beginning at 'offset') in `candidate`. Must be greater than or equal to numberOfBytesNeededToDetermineMatch().

Returns:boolean

true if the candidate byte sequence matches; otherwise, false.

newInputStreamback to summary
public InputStream newInputStream(InputStream interceptedStream) throws IOException

Creates a new InputStream that transforms the bytes in the given InputStream into valid text or binary Ion.

Parameters
interceptedStream:InputStream

the stream containing bytes in this format.

Returns:InputStream

a new InputStream.

Exceptions
IOException:
if thrown when constructing the new InputStream.
numberOfBytesNeededToDetermineMatchback to summary
public int numberOfBytesNeededToDetermineMatch()

The number of bytes required to be read from the beginning of the stream in order to determine whether it matches the format relevant to this interceptor. If a stream contains fewer than the number of bytes returned by this method, then this interceptor will not be considered a match and isMatch(byte[], int, int) will not be called.

Returns:int

the length in bytes.