|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.ByteEncoder
A ByteEncoder is used to encode data as a sequence of bytes in an efficient manner. It consists of a number of static methods that encode data to a ByteArray or decode data from a sequence of bytes.
| Constructor Summary | |
ByteEncoder()
|
|
| Method Summary | |
static String |
classOfData(byte[] source,
int offset,
int lengthLeft)
Return the class of the data as a string as it would be returned if you had called getClass().getName() on the original data. |
static int |
countEncoded(byte[] source,
int offset,
int lengthLeft)
Count how many data units (primitive values or object values) are stored in sequence in the specified sequence of bytes. |
static Wrapper[] |
decode(byte[] source,
int offset,
int lengthLeft)
|
static int |
decode(byte[] source,
int offset,
int lengthLeft,
Wrapper dest)
Decode a data unit at the specified location, placing it in the destination Wrapper. |
static void |
decodeEncodableObjectData(byte[] source,
int offset,
int dataLength,
Object obj)
Decode the fields of an Encodable object, as encoded by encodeEncodableObjectData(). |
static Wrapper |
decodeField(byte[] source,
int offset,
int length,
String fieldName,
Wrapper dest)
This searchs for a field name and returns the encoded value associated with the field. |
static Object |
decodeObject(byte[] source,
int offset,
int lengthLeft,
Object dest)
Decode an object into the specified destination object. |
static void |
decodeObjectData(byte[] source,
int offset,
int dataLength,
Object obj)
Decode the data bytes of the object, as encoded by encodeObjectData. |
static Object |
decodeObjectField(byte[] source,
int offset,
int length,
String fieldName,
Object dest)
|
static Object |
decodeObjectField(ByteArray source,
String fieldName)
|
static Object[] |
decodeObjects(byte[] source,
int offset,
int lengthLeft,
Object[] dest)
Decode an array of Objects. |
static int |
decodeString(byte[] source,
int offset,
int lengthLeft,
Wrapper dest)
|
static String |
decodeStringField(byte[] source,
int offset,
int length,
String fieldName)
|
static String |
decodeStringField(ByteArray source,
String fieldName)
|
static int |
encode(ByteArray dest,
byte[] source,
int offset,
int length)
This encodes the bytes as a byte array data unit. |
static int |
encode(ByteArray dest,
Wrapper w)
Fully encode any data type, including a null object reference. |
static int |
encodeEncodableObjectData(ByteArray dest,
Encodable obj)
Encode the fields of an Encodable object. |
static int |
encodeField(ByteArray dest,
String fieldName,
byte[] data,
int offset,
int length)
|
static int |
encodeField(ByteArray dest,
String fieldName,
Object data)
|
static int |
encodeField(ByteArray dest,
String fieldName,
Wrapper data)
|
static int |
encodeObject(ByteArray dest,
Object obj)
Encode an object, specifying the full class of the object. |
static int |
encodeObjectData(ByteArray dest,
Object obj)
Encode only the data for the Object, not any information about the class of the Object. |
static Range |
findField(byte[] source,
int offset,
int length,
String fieldName,
Range dest)
|
static Range |
getByteArrayBytes(byte[] source,
int offset,
int length,
Range dest)
|
static Range |
getByteArrayBytes(byte[] source,
Range foundData,
Range dest)
|
static Range |
getFieldByteArray(byte[] source,
int offset,
int length,
String fieldName,
Range dest)
|
static boolean |
isObjectOrArray(byte[] source,
int offset,
int lengthLeft)
|
static boolean |
isString(byte[] source,
int offset,
int lengthLeft)
|
static int |
sizeOfData(byte[] source,
int offset,
int lengthLeft)
Return the number of bytes stored starting at the particular offset. |
static int |
typeOfData(byte[] source,
int offset,
int lengthLeft)
Return the Wrapper type of the data stored at the specified location. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Constructor Detail |
public ByteEncoder()
| Method Detail |
public static int encodeEncodableObjectData(ByteArray dest,
Encodable obj)
Note that this method does not store information about the class of the object. This means you must know the object class and have a pre-created object to call the corresponding decodeEncodableObjectData() when you are ready to decode it.
dest - The destination ByteArray or null to just get the number of bytes needed.obj - The object to encode.
public static int encodeObjectData(ByteArray dest,
Object obj)
The method used to encode the object depends on the class of the object or the interfaces it implements. The type of Objects you can encode are:
dest - The destination ByteArray or null to just get the number of bytes needed.obj - The object to encode.
public static void decodeEncodableObjectData(byte[] source,
int offset,
int dataLength,
Object obj)
throws StreamCorruptedException
source - the source of the data bytes.offset - the offset of the first byte.dataLength - the number of bytes.obj - the destination object.
StreamCorruptedException
public static void decodeObjectData(byte[] source,
int offset,
int dataLength,
Object obj)
throws StreamCorruptedException,
ClassNotFoundException
source - the source of the data bytes.offset - the offset of the first byte.dataLength - the number of bytes.obj - the destination object.
StreamCorruptedException
ClassNotFoundException
public static int sizeOfData(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
source - the source of the data bytes.offset - the offset of the first byte.
StreamCorruptedException
public static int typeOfData(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
source - the source of the data bytes.offset - the offset of the first byte.lengthLeft - the number of bytes.
StreamCorruptedException
public static boolean isString(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
StreamCorruptedException
public static boolean isObjectOrArray(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
StreamCorruptedException
public static String classOfData(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
source - the source of the data bytes.offset - the offset of the first byte.lengthLeft - the number of bytes.
IllegalArgumentException - if the data at the specified location is not
an Object or Array class.
StreamCorruptedException
public static int countEncoded(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException
source - the source of the data bytes.offset - the offset of the first byte.lengthLeft - the number of bytes.
StreamCorruptedException
public static int encode(ByteArray dest,
Wrapper w)
dest - the destination ByteArray or null to determine the number of bytes needed.w - a wrapper that holds the data to be encoded.
public static int decode(byte[] source,
int offset,
int lengthLeft,
Wrapper dest)
throws StreamCorruptedException,
ClassNotFoundException
source - the source of the data bytes.offset - the offset of the first byte.lengthLeft - the number of bytes.
StreamCorruptedException
ClassNotFoundException
public static int decodeString(byte[] source,
int offset,
int lengthLeft,
Wrapper dest)
throws StreamCorruptedException
StreamCorruptedException
public static int encodeObject(ByteArray dest,
Object obj)
dest - The destination ByteArray or null to just find out how many bytes are needed.obj - The object to encode.
public static Object decodeObject(byte[] source,
int offset,
int lengthLeft,
Object dest)
throws StreamCorruptedException,
ClassNotFoundException
source - the source of the data bytes.offset - the offset of the first byte.dest - the destination object which may be null, in which case a new instance of the
object will be created (if possible).
StreamCorruptedException
ClassNotFoundException
public static Object[] decodeObjects(byte[] source,
int offset,
int lengthLeft,
Object[] dest)
throws StreamCorruptedException,
ClassNotFoundException
source - the source of the data bytes.offset - the offset of the first byte.lengthLeft - the number of bytes.dest - the destination objects which may be null, in which case a new instance of the
objects will be returned.
StreamCorruptedException
ClassNotFoundException
public static Wrapper[] decode(byte[] source,
int offset,
int lengthLeft)
throws StreamCorruptedException,
ClassNotFoundException
StreamCorruptedException
ClassNotFoundException
public static int encodeField(ByteArray dest,
String fieldName,
Wrapper data)
public static int encodeField(ByteArray dest,
String fieldName,
Object data)
public static int encodeField(ByteArray dest,
String fieldName,
byte[] data,
int offset,
int length)
public static int encode(ByteArray dest,
byte[] source,
int offset,
int length)
dest - source - offset - length -
public static Range findField(byte[] source,
int offset,
int length,
String fieldName,
Range dest)
throws StreamCorruptedException
StreamCorruptedException
public static Range getByteArrayBytes(byte[] source,
int offset,
int length,
Range dest)
throws StreamCorruptedException
StreamCorruptedException
public static Range getByteArrayBytes(byte[] source,
Range foundData,
Range dest)
throws StreamCorruptedException
StreamCorruptedException
public static Range getFieldByteArray(byte[] source,
int offset,
int length,
String fieldName,
Range dest)
throws StreamCorruptedException
StreamCorruptedException
public static Wrapper decodeField(byte[] source,
int offset,
int length,
String fieldName,
Wrapper dest)
throws StreamCorruptedException,
ClassNotFoundException
StreamCorruptedException
ClassNotFoundException
public static Object decodeObjectField(byte[] source,
int offset,
int length,
String fieldName,
Object dest)
throws StreamCorruptedException,
ClassNotFoundException
StreamCorruptedException
ClassNotFoundException
public static Object decodeObjectField(ByteArray source,
String fieldName)
throws StreamCorruptedException,
ClassNotFoundException
StreamCorruptedException
ClassNotFoundException
public static String decodeStringField(byte[] source,
int offset,
int length,
String fieldName)
throws StreamCorruptedException
StreamCorruptedException
public static String decodeStringField(ByteArray source,
String fieldName)
throws StreamCorruptedException
StreamCorruptedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||