Package org.hobbit.core.rabbit
Class RabbitMQUtils
java.lang.Object
org.hobbit.core.rabbit.RabbitMQUtils
Contains utility methods for working with RabbitMQ.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.jena.riot.Langprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 longreadLong(byte[] data) Reads a long value from the given byte array.static longreadLong(byte[] data, int offset, int length) Reads a long value from the given byte array.static org.apache.jena.rdf.model.ModelreadModel(byte[] data) Reads an RDF model from the given byte array.static org.apache.jena.rdf.model.ModelreadModel(byte[] data, int offset, int length) Reads an RDF model from the given byte array.static org.apache.jena.rdf.model.ModelReads an RDF model from the given String.static org.apache.jena.rdf.model.ModelreadModel(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 StringreadString(byte[] data) Transforms the given byte data into a String using the UTF-8 encoding.static StringreadString(byte[] data, int offset, int length) Transforms the given byte data into a String using the UTF-8 encoding.static StringreadString(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 theDEFAULT_RDF_LANG.static StringwriteModel2String(org.apache.jena.rdf.model.Model model) Creates a String containing the serialized RDF model using theDEFAULT_RDF_LANG.static byte[]writeString(String string) Creates a byte array representation of the given String using UTF-8 encoding.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DEFAULT_RDF_LANG
public static final org.apache.jena.riot.Lang DEFAULT_RDF_LANG
-
-
Constructor Details
-
RabbitMQUtils
public RabbitMQUtils()
-
-
Method Details
-
readByteArray
Reads a byte array from the given buffer assuming that it is preceded by an int value containing the length of the byte array.- Parameters:
buffer- the buffer containing an int containing the length of the byte array followed by the byte array itself- Returns:
- the byte array or null if the given byte array is null
-
readModel
public static org.apache.jena.rdf.model.Model readModel(byte[] data) Reads an RDF model from the given byte array.- Parameters:
data- the byte array containing the serialized RDF model- Returns:
- the deserialized model
-
readModel
public static org.apache.jena.rdf.model.Model readModel(byte[] data, int offset, int length) Reads an RDF model from the given byte array.- Parameters:
data- the byte array containing the serialized RDF modeloffset- position at which the parsing will startlength- number of bytes that should be parsed- Returns:
- the deserialized model
-
readModel
Reads an RDF model from the given String.- Parameters:
string- the String containing the serialized RDF model- Returns:
- the deserialized model
-
readModel
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.- Parameters:
buffer- the buffer containing the length of the serialized model (as int) and the byte array containing the serialized model- Returns:
- the deserialized model
-
readString
Transforms the given byte data into a String using the UTF-8 encoding.- Parameters:
data- the byte array that should be transformed- Returns:
- the String or null if the given byte array is null
-
readString
Transforms the given byte data into a String using the UTF-8 encoding.- Parameters:
data- the byte array that should be transformedoffset- position at which the parsing will startlength- number of bytes that should be parsed- Returns:
- the String or null if the given byte array is null
-
readString
Reads a String from the given buffer assuming that it is preceded by an int value containing the length of the String.- Parameters:
buffer- the buffer that contains the byte data of the String- Returns:
- the String or null if the given buffer is null
-
writeByteArrays
public static byte[] writeByteArrays(byte[][] arrays) writes the given byte arrays and puts their length in front of them. Thus, they can be read using a ByteBuffer and thereadByteArray(ByteBuffer)method.- Parameters:
arrays- arrays that should be written to a single array- Returns:
- the byte array containing all given arrays and their lengths
-
writeByteArrays
public static byte[] writeByteArrays(byte[] precedingData, byte[][] arrays, byte[] subsequentData) writes the given byte arrays and puts their length in front of them. Thus, they can be read using a ByteBuffer and thereadByteArray(ByteBuffer)method.- Parameters:
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.- Returns:
- the byte array containing all given arrays and their lengths
-
writeString
Creates a byte array representation of the given String using UTF-8 encoding.- Parameters:
string- the String that should be transformed into a byte array- Returns:
- the UTF-8 byte array of the given String
-
writeModel2String
Creates a String containing the serialized RDF model using theDEFAULT_RDF_LANG.- Parameters:
model- the model that should be serialized- Returns:
- the String containing the model
-
writeModel
public static byte[] writeModel(org.apache.jena.rdf.model.Model model) Creates a byte array containing the serialized RDF model using theDEFAULT_RDF_LANG.- Parameters:
model- the model that should be serialized- Returns:
- the byte array containing the model
-
writeLong
public static byte[] writeLong(long value) Creates a byte array representing the given long value.- Parameters:
value- the value that should be serialized- Returns:
- the byte array containing the given long value
-
readLong
public static long readLong(byte[] data) Reads a long value from the given byte array.- Parameters:
data- a serialized long value- Returns:
- the value read from the array
-
readLong
public static long readLong(byte[] data, int offset, int length) Reads a long value from the given byte array.- Parameters:
data- a serialized long valueoffset- position at which the parsing will startlength- number of bytes that should be parsed (should equalLong.BYTES)- Returns:
- the value read from the array
-