Top Description Constructors Methods
com.amazon.ion.util

public Class IonStreamUtils

extends Object
Class Inheritance
Static Imports
com.amazon.ion.impl._Private_IonConstants.BINARY_VERSION_MARKER_1_0, com.amazon.ion.util.GzipOrRawInputStream.GZIP_HEADER

Utility methods for working with the Ion streaming interfaces, IonReader and IonWriter.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
cookieMatches(byte[] cookie, byte[] buffer, int offset, int length)

public static boolean

Returns:

true if the buffer contains GZIPped data; false if the buffer is null or if the length is too short.
isGzip
(byte[]
the data to check.
buffer
,
int
the position in the buffer at which to start reading.
offset
,
int
the number of bytes in the buffer that are valid, starting from offset.
length
)

Determines whether a buffer contains GZIPped data.

public static boolean

Returns:

true if the buffer contains Ion binary (starting from offset zero); false if the buffer is null or too short.
isIonBinary
(byte[]
the data to check.
buffer
)

Determines whether a buffer contains Ion binary data by looking for the presence of the Ion Version Marker at its start.

public static boolean

Returns:

true if the buffer contains Ion binary (starting from offset); false if the buffer is null or if the length is too short.
isIonBinary
(byte[]
the data to check.
buffer
,
int
the position in the buffer at which to start reading.
offset
,
int
the number of bytes in the buffer that are valid, starting from offset.
length
)

Determines whether a buffer contains Ion binary data by looking for the presence of the Ion Version Marker at a given offset.

public static void
throwAsIonException(Exception
the exception to wrap.
e
)

Wraps the given Exception with IonException and throws.

public static InputStream
unGzip(InputStream in)

Returns a stream that decompresses a stream if it contains GZIPped data, otherwise has no effect on the stream (but may wrap it).

public static void
writeBoolList(IonWriter writer, boolean[]
boolean values to populate the list with
values
)

writes an IonList with a series of IonBool values.

public static void
writeFloatList(IonWriter writer, float[]
32 bit float values to populate the lists IonFloat's with
values
)

writes an IonList with a series of IonFloat values.

public static void
writeFloatList(IonWriter writer, double[]
64 bit float values to populate the lists IonFloat's with
values
)

writes an IonList with a series of IonFloat values.

public static void
writeIntList(IonWriter writer, byte[]
signed byte values to populate the lists int's with
values
)

writes an IonList with a series of IonInt values.

public static void
writeIntList(IonWriter writer, short[]
signed short values to populate the lists int's with
values
)

writes an IonList with a series of IonInt values.

public static void
writeIntList(IonWriter writer, int[]
signed int values to populate the lists int's with
values
)

writes an IonList with a series of IonInt values.

public static void
writeIntList(IonWriter writer, long[]
signed long values to populate the lists int's with
values
)

writes an IonList with a series of IonInt values.

public static void
writeStringList(IonWriter writer, String[]
Java String to populate the lists IonString's from
values
)

writes an IonList with a series of IonString values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IonStreamUtilsback to summary
public IonStreamUtils()

Method Detail

cookieMatchesback to summary
private static boolean cookieMatches(byte[] cookie, byte[] buffer, int offset, int length)
isGzipback to summary
public static boolean isGzip(byte[] buffer, int offset, int length)

Determines whether a buffer contains GZIPped data.

Parameters
buffer:byte[]

the data to check.

offset:int

the position in the buffer at which to start reading.

length:int

the number of bytes in the buffer that are valid, starting from offset.

Returns:boolean

true if the buffer contains GZIPped data; false if the buffer is null or if the length is too short.

isIonBinaryback to summary
public static boolean isIonBinary(byte[] buffer)

Determines whether a buffer contains Ion binary data by looking for the presence of the Ion Version Marker at its start. A false result does not imply that the buffer has Ion text, just that it's not Ion binary.

Parameters
buffer:byte[]

the data to check.

Returns:boolean

true if the buffer contains Ion binary (starting from offset zero); false if the buffer is null or too short.

See Also
isIonBinary(byte[], int, int)
isIonBinaryback to summary
public static boolean isIonBinary(byte[] buffer, int offset, int length)

Determines whether a buffer contains Ion binary data by looking for the presence of the Ion Version Marker at a given offset. A false result does not imply that the buffer has Ion text, just that it's not Ion binary.

Parameters
buffer:byte[]

the data to check.

offset:int

the position in the buffer at which to start reading.

length:int

the number of bytes in the buffer that are valid, starting from offset.

Returns:boolean

true if the buffer contains Ion binary (starting from offset); false if the buffer is null or if the length is too short.

See Also
isIonBinary(byte[])
throwAsIonExceptionback to summary
public static void throwAsIonException(Exception e)

Wraps the given Exception with IonException and throws.

Parameters
e:Exception

the exception to wrap.

unGzipback to summary
public static InputStream unGzip(InputStream in) throws IOException

Returns a stream that decompresses a stream if it contains GZIPped data, otherwise has no effect on the stream (but may wrap it).

writeBoolListback to summary
public static void writeBoolList(IonWriter writer, boolean[] values) throws IOException

writes an IonList with a series of IonBool values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:boolean[]

boolean values to populate the list with

writeFloatListback to summary
public static void writeFloatList(IonWriter writer, float[] values) throws IOException

writes an IonList with a series of IonFloat values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally. Note that since, currently, IonFloat is a 64 bit float this is a helper that simply casts the passed in floats to double before writing them.

Parameters
values:float[]

32 bit float values to populate the lists IonFloat's with

writeFloatListback to summary
public static void writeFloatList(IonWriter writer, double[] values) throws IOException

writes an IonList with a series of IonFloat values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:double[]

64 bit float values to populate the lists IonFloat's with

writeIntListback to summary
public static void writeIntList(IonWriter writer, byte[] values) throws IOException

writes an IonList with a series of IonInt values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:byte[]

signed byte values to populate the lists int's with

writeIntListback to summary
public static void writeIntList(IonWriter writer, short[] values) throws IOException

writes an IonList with a series of IonInt values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:short[]

signed short values to populate the lists int's with

writeIntListback to summary
public static void writeIntList(IonWriter writer, int[] values) throws IOException

writes an IonList with a series of IonInt values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:int[]

signed int values to populate the lists int's with

writeIntListback to summary
public static void writeIntList(IonWriter writer, long[] values) throws IOException

writes an IonList with a series of IonInt values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:long[]

signed long values to populate the lists int's with

writeStringListback to summary
public static void writeStringList(IonWriter writer, String[] values) throws IOException

writes an IonList with a series of IonString values. This starts a List, writes the values (without any annoations) and closes the list. For text and tree writers this is just a convienience, but for the binary writer it can be optimized internally.

Parameters
values:String[]

Java String to populate the lists IonString's from