Package com.amazon.ion.util
Class IonStreamUtils
java.lang.Object
com.amazon.ion.util.IonStreamUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isGzip
(byte[] buffer, int offset, int length) Determines whether a buffer contains GZIPped data.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.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.static void
Wraps the given Exception with IonException and throws.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).static void
writeBoolList
(IonWriter writer, boolean[] values) writes an IonList with a series of IonBool values.static void
writeFloatList
(IonWriter writer, double[] values) writes an IonList with a series of IonFloat values.static void
writeFloatList
(IonWriter writer, float[] values) writes an IonList with a series of IonFloat values.static void
writeIntList
(IonWriter writer, byte[] values) writes an IonList with a series of IonInt values.static void
writeIntList
(IonWriter writer, int[] values) writes an IonList with a series of IonInt values.static void
writeIntList
(IonWriter writer, long[] values) writes an IonList with a series of IonInt values.static void
writeIntList
(IonWriter writer, short[] values) writes an IonList with a series of IonInt values.static void
writeStringList
(IonWriter writer, String[] values) writes an IonList with a series of IonString values.
-
Constructor Details
-
IonStreamUtils
public IonStreamUtils()
-
-
Method Details
-
isIonBinary
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. Afalse
result does not imply that the buffer has Ion text, just that it's not Ion binary.- Parameters:
buffer
- the data to check.- Returns:
true
if the buffer contains Ion binary (starting from offset zero);false
if the buffer is null or too short.- See Also:
-
isIonBinary
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. Afalse
result does not imply that the buffer has Ion text, just that it's not Ion binary.- Parameters:
buffer
- the data to check.offset
- the position in the buffer at which to start reading.length
- the number of bytes in the buffer that are valid, starting fromoffset
.- Returns:
true
if the buffer contains Ion binary (starting fromoffset
);false
if the buffer is null or if thelength
is too short.- See Also:
-
isGzip
public static boolean isGzip(byte[] buffer, int offset, int length) Determines whether a buffer contains GZIPped data.- Parameters:
buffer
- the data to check.offset
- the position in the buffer at which to start reading.length
- the number of bytes in the buffer that are valid, starting fromoffset
.- Returns:
true
if the buffer contains GZIPped data;false
if the buffer is null or if thelength
is too short.
-
unGzip
Returns a stream that decompresses a stream if it contains GZIPped data, otherwise has no effect on the stream (but may wrap it).- Throws:
IOException
-
throwAsIonException
Wraps the given Exception with IonException and throws.- Parameters:
e
- the exception to wrap.
-
writeBoolList
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 values to populate the list with- Throws:
IOException
-
writeFloatList
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
- 32 bit float values to populate the lists IonFloat's with- Throws:
IOException
-
writeFloatList
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
- 64 bit float values to populate the lists IonFloat's with- Throws:
IOException
-
writeIntList
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
- signed byte values to populate the lists int's with- Throws:
IOException
-
writeIntList
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
- signed short values to populate the lists int's with- Throws:
IOException
-
writeIntList
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
- signed int values to populate the lists int's with- Throws:
IOException
-
writeIntList
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
- signed long values to populate the lists int's with- Throws:
IOException
-
writeStringList
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
- Java String to populate the lists IonString's from- Throws:
IOException
-