public class MarshallingUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
long[] |
convertByteArrayToLongArray(byte[] sequenceOfBytes)
Converts a byte[] into a long[]
|
byte[] |
convertLongArrayToByteArray(long[] sequenceOfLongs)
Converts a long[] into a byte[].
|
static MarshallingUtil |
getInstance()
Retrieve the singleton instance of the
MarshallingUtil |
int |
getInt(byte[] data,
int offset)
Given a sequence of bytes, this method returns the int value associated
with the sequence of bytes.
|
java.util.Properties |
readProperties(java.io.DataInputStream din)
Reads a property object from the underlying DataInputStream
|
java.lang.String |
readString(java.io.DataInputStream din)
Reads a String from the underlying DataInputStream
|
void |
writeProperties(java.io.DataOutputStream dout,
java.util.Properties properties)
Writes a java.util.Properties object to the underlying DataOutputStream
|
void |
writeString(java.io.DataOutputStream dout,
java.lang.String element)
Writes a String to the underlying DataOutputStream
|
public static MarshallingUtil getInstance()
MarshallingUtil
public long[] convertByteArrayToLongArray(byte[] sequenceOfBytes) throws java.io.IOException
sequenceOfBytes
- The byte[] inputjava.io.IOException
- If there are problems in the conversion process.public byte[] convertLongArrayToByteArray(long[] sequenceOfLongs) throws java.io.IOException
sequenceOfLongs
- The long[] inputjava.io.IOException
- If there are problems in the conversion process.public void writeProperties(java.io.DataOutputStream dout, java.util.Properties properties) throws java.io.IOException
dout
- The instance of the DataOutputStream
properties
- The Properties
instance that needs to be
serialized.java.io.IOException
- If there are problems in the marshalling process.public java.util.Properties readProperties(java.io.DataInputStream din) throws java.io.IOException
din
- The instance of the DataInputStream
where the
Properties
instance will be read from.Properties
instancejava.io.IOException
- If there are problems in the unmarshalling process.public void writeString(java.io.DataOutputStream dout, java.lang.String element) throws java.io.IOException
dout
- The instance of the DataOutputStream
element
- The String that needs to be writtenjava.io.IOException
- If there are problems in the Marshalling process.public java.lang.String readString(java.io.DataInputStream din) throws java.io.IOException
din
- The instance of the DataInputStream
where the
String
will be read from.String
instancejava.io.IOException
- If there are problems in the un-marshalling process.public int getInt(byte[] data, int offset)
(data.length - offset) >= 4
; otherwise, an illegal Argument
exception will be thrown.data
- the byte[] which would be used to reconstruct the bytesoffset
- The point from which an attempt to reconstruct the integer
must be madeint
value associated with the byte[] starting at
the specified offset.