public class RabbitMQUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.apache.jena.riot.Lang |
DEFAULT_RDF_LANG |
private static org.slf4j.Logger |
LOGGER |
static Charset |
STRING_ENCODING |
| Constructor and Description |
|---|
RabbitMQUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
readByteArray(ByteBuffer buffer)
Reads a byte array from the given buffer assuming that it is preceded by
an int value containing the length of the byte array.
|
static byte[] |
readByteArray(InputStream stream)
Reads a byte array from the given stream assuming that it is preceded by
an int value containing the length of the byte array.
|
static byte[] |
readByteArray(InputStream stream,
int size)
Reads a byte array of the given size from the given stream.
|
static int |
readInt(byte[] data)
Reads a
int value from the given byte array. |
static int |
readInt(InputStream stream)
Reads an
int value from the given InputStream. |
static long |
readLong(byte[] data)
Reads a long value from the given byte array.
|
static long |
readLong(byte[] data,
int offset,
int length)
Reads a long value from the given byte array.
|
static long |
readLong(InputStream stream)
Reads a
long value from the given InputStream. |
static org.apache.jena.rdf.model.Model |
readModel(byte[] data)
Reads an RDF model from the given byte array.
|
static org.apache.jena.rdf.model.Model |
readModel(byte[] data,
int offset,
int length)
Reads an RDF model from the given byte array.
|
static org.apache.jena.rdf.model.Model |
readModel(ByteBuffer buffer)
Reads an RDF model from the given byte buffer assuming that the byte
array containing the model is preceded by an int containing its length.
|
static org.apache.jena.rdf.model.Model |
readModel(String string)
Reads an RDF model from the given String.
|
static String |
readString(byte[] data)
Transforms the given byte data into a String using the UTF-8 encoding.
|
static String |
readString(byte[] data,
int offset,
int length)
Transforms the given byte data into a String using the UTF-8 encoding.
|
static String |
readString(ByteBuffer buffer)
Reads a String from the given buffer assuming that it is preceded by an
int value containing the length of the String.
|
static byte[] |
writeByteArrays(byte[][] arrays)
writes the given byte arrays and puts their length in front of them.
|
static byte[] |
writeByteArrays(byte[] precedingData,
byte[][] arrays,
byte[] subsequentData)
writes the given byte arrays and puts their length in front of them.
|
static byte[] |
writeLong(long value)
Creates a byte array representing the given long value.
|
static byte[] |
writeModel(org.apache.jena.rdf.model.Model model)
Creates a byte array containing the serialized RDF model using the
DEFAULT_RDF_LANG. |
static String |
writeModel2String(org.apache.jena.rdf.model.Model model)
Creates a String containing the serialized RDF model using the
DEFAULT_RDF_LANG. |
static byte[] |
writeString(String string)
Creates a byte array representation of the given String using UTF-8
encoding.
|
private static final org.slf4j.Logger LOGGER
public static final org.apache.jena.riot.Lang DEFAULT_RDF_LANG
public static final Charset STRING_ENCODING
public static byte[] readByteArray(ByteBuffer buffer)
buffer - the buffer containing an int containing the length of the byte
array followed by the byte array itselfpublic static byte[] readByteArray(InputStream stream) throws IOException, IllegalArgumentException
stream - the InputStream which provides Integer.BYTES =
which are interpreted as the array
length and additionally to that at least the number of bytes
needed for the byte arrayIOException - if an IO error occurs during reading from streamIllegalArgumentException - if the stream does not provide enough bytespublic static byte[] readByteArray(InputStream stream, int size) throws IOException, IllegalArgumentException
stream - the InputStream which provides at least the number of
bytes needed for the byte arraysize - the number of bytes that should be read from the given streamIOException - if an IO error occurs during reading from streamIllegalArgumentException - if the stream does not provide enough bytespublic static org.apache.jena.rdf.model.Model readModel(byte[] data)
data - the byte array containing the serialized RDF modelpublic static org.apache.jena.rdf.model.Model readModel(byte[] data,
int offset,
int length)
data - the byte array containing the serialized RDF modeloffset - position at which the parsing will startlength - number of bytes that should be parsedpublic static org.apache.jena.rdf.model.Model readModel(String string)
string - the String containing the serialized RDF modelpublic static org.apache.jena.rdf.model.Model readModel(ByteBuffer buffer)
buffer - the buffer containing the length of the serialized model (as
int) and the byte array containing the serialized modelpublic static String readString(byte[] data)
data - the byte array that should be transformedpublic static String readString(byte[] data, int offset, int length)
data - the byte array that should be transformedoffset - position at which the parsing will startlength - number of bytes that should be parsedpublic static String readString(ByteBuffer buffer)
buffer - the buffer that contains the byte data of the Stringpublic static byte[] writeByteArrays(byte[][] arrays)
readByteArray(ByteBuffer) method.arrays - arrays that should be written to a single arraypublic static byte[] writeByteArrays(byte[] precedingData,
byte[][] arrays,
byte[] subsequentData)
readByteArray(ByteBuffer) method.precedingData - data that should be written before the arrays are written.
Note that this data is not preceded with the byte array
length.arrays - arrays that should be written to a single arraysubsequentData - data that should be written after the arrays are written.
Note that this data is not preceded with the byte array
length.public static byte[] writeString(String string)
string - the String that should be transformed into a byte arraypublic static String writeModel2String(org.apache.jena.rdf.model.Model model)
DEFAULT_RDF_LANG.model - the model that should be serializedpublic static byte[] writeModel(org.apache.jena.rdf.model.Model model)
DEFAULT_RDF_LANG.model - the model that should be serializedpublic static byte[] writeLong(long value)
value - the value that should be serializedpublic static long readLong(byte[] data)
data - a serialized long valuepublic static long readLong(byte[] data,
int offset,
int length)
data - a serialized long valueoffset - position at which the parsing will startlength - number of bytes that should be parsed (should equal
Long.BYTES)public static long readLong(InputStream stream) throws IOException, IllegalArgumentException
long value from the given InputStream.stream - the InputStream which provides the bytes of the
long valuelong value that have been read from the streamIOException - if an IO error occurs during reading from streamIllegalArgumentException - if the stream does not provide enough bytes for a long valuepublic static int readInt(byte[] data)
int value from the given byte array.data - a serialized int valuepublic static int readInt(InputStream stream) throws IOException, IllegalArgumentException
int value from the given InputStream.stream - the InputStream which provides the bytes of the
int valueint value that have been read from the streamIOException - if an IO error occurs during reading from streamIllegalArgumentException - if the stream does not provide enough bytes for a long valueCopyright © 2017–2018. All rights reserved.