public abstract class Encoder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte |
ENV_FLAG_COMPRESSED |
static byte |
ENV_FLAG_ENCRYPTED |
static byte |
ENV_FLAG_TRUNCATED |
static int |
INT_SIZE |
static int |
INT2_SIZE |
static int |
LONG_SIZE |
static int |
MSG_FLAG_AUTH |
static int |
MSG_FLAG_CACR |
static int |
MSG_FLAG_CERT |
static int |
MSG_FLAG_CONT |
static int |
MSG_FLAG_ENCR |
static int |
MSG_FLAG_KPAL |
static int |
MSG_FLAG_OVRW |
static int |
MSG_FLAG_PUBL |
static int |
MSG_FLAG_RECU |
static int |
MSG_FLAG_RRDG |
static java.lang.String |
MSG_INVALID_ARRAY_SIZE |
static byte |
PERM_ADMIN_READ |
static byte |
PERM_ADMIN_WRITE |
static byte |
PERM_PUBLIC_READ |
static byte |
PERM_PUBLIC_WRITE |
static int |
SESSION_FLAG_CERT |
static int |
SESSION_FLAG_ENCR |
Constructor and Description |
---|
Encoder() |
Modifier and Type | Method and Description |
---|---|
static int |
calcHandleValueSize(byte[] values,
int offset)
Calculate the number of bytes required to store the specified value
|
static int |
calcStorageSize(HandleValue value)
Calculate the number of bytes required to store the specified value
|
static int |
calculateAdminRecordSize(AdminRecord admin)
Calculate the size that a buffer would have to be in order to hold
an encoded value of the given admin record.
|
static AddValueRequest |
decodeAddValueRequest(byte[] msg,
int offset,
MessageEnvelope env)
Decode, create, and return an AddValueRequest object from the given buffer
|
static AdminRecord |
decodeAdminRecord(byte[] data,
int offset) |
static void |
decodeAdminRecord(byte[] data,
int offset,
AdminRecord admin)
Decode an administrator record from the given byte array.
|
static CreateHandleRequest |
decodeCreateHandleRequest(byte[] msg,
int offset,
MessageEnvelope env,
int opCode)
Decode, create, and return a CreateHandleRequest from the given buffer
|
static DeleteHandleRequest |
decodeDeleteHandleRequest(byte[] msg,
int offset,
MessageEnvelope env)
Decode, create, and return a DeleteHandleRequest from the given buffer
|
static void |
decodeEnvelope(byte[] udpPkt,
MessageEnvelope msgEnv)
Read the encoded value of the given buffer and populate the fields
of the given message envelope object.
|
static GenericRequest |
decodeGenericRequest(byte[] msg,
int offset,
int opCode,
MessageEnvelope env)
Decode and return a generic request method with the given encoding and opCode
This returns a GenericRequest object which consists of all the normal message
info along with a handle.
|
static GenericResponse |
decodeGenericResponse(byte[] msg,
int loc,
MessageEnvelope env)
Decode the given generic message (ie no body, identified only by the opCode
and responseCode) from the given buffer.
|
static HandleValue[] |
decodeGlobalValues(java.io.InputStream in)
Decode from the given input stream a set of handle values.
|
static int |
decodeHandleValue(byte[] buf,
int offset,
HandleValue value)
Populate the specified handle value with the values encoded in the given
byte array and return the number of bytes read.
|
static HandleValue[] |
decodeHandleValues(byte[] buf)
Decode from the given byte buffer, a set of handle values.
|
static java.util.HashMap |
decodeLocalAddresses(java.io.InputStream in)
Reads pairs of IP addresses into a hashtable.
|
static java.util.HashMap |
decodeLocalSites(java.io.InputStream in)
Reads SiteInfo/NA-list pairs into a hashtable.
|
static AbstractMessage |
decodeMessage(byte[] msg,
int offset,
MessageEnvelope envelope)
decode a response message - given the message buffer and a separate
envelop, return a response object.
|
static ModifyValueRequest |
decodeModifyValueRequest(byte[] msg,
int offset,
MessageEnvelope env)
Decode, create, and return a ModifyValueRequest object from the given buffer
|
static RemoveValueRequest |
decodeRemoveValueRequest(byte[] msg,
int offset,
MessageEnvelope env)
Decode, create, and return a RemoveValueRequest object from the given buffer
|
static ResolutionRequest |
decodeResolutionRequest(byte[] msg,
int offset,
MessageEnvelope env)
Decode and create a resolution request object from the given buffer.
|
static ResolutionResponse |
decodeResolutionResponse(byte[] msg,
int offset,
MessageEnvelope env)
Decode and create a resolution response object from the given buffer.
|
static ServiceReferralResponse |
decodeServiceReferralResponse(int responseCode,
byte[] msg,
int offset,
MessageEnvelope env,
int endOfBuf) |
static void |
decodeSiteInfoRecord(byte[] data,
int offset,
SiteInfo site)
Decode a site info record from a byte array.
|
static ValueReference[] |
decodeValueReferenceList(byte[] buf,
int offset)
Decode, create, and return a list of handle value references (handle/index
pairs) from the given buffer.
|
static byte[] |
decryptMessage(SessionInfo session,
byte[] ciphermsg,
byte[] secretKey)
Deprecated.
use SessionInfo.decryptBuffer
|
static void |
dumpBytes(byte[] buf)
Display the contents of the given buffer in a somewhat human-readable
format.
|
static void |
dumpBytes(byte[] buf,
int len)
Display the contents of the given buffer in a somewhat human-readable
format.
|
static void |
dumpBytes(byte[] buf,
int offset,
int len)
Display the contents of the given buffer in a somewhat human-readable
format.
|
static byte[] |
encodeAddValueRequest(AddValueRequest req)
Encode an AddValueRequest object and return the buffer with the encoding.
|
static byte[] |
encodeAdminRecord(AdminRecord admin)
Encode the given admin record into a byte array and return it.
|
static byte[] |
encodeCreateHandleRequest(CreateHandleRequest req)
Encode the given CreateHandleRequest and return the resulting buffer.
|
static byte[] |
encodeDeleteHandleRequest(DeleteHandleRequest req)
Encode the given DeleteHandleRequest and return the resulting buffer.
|
static void |
encodeEnvelope(MessageEnvelope msgEnv,
byte[] udpPkt)
Write the encoded value of the given message envelope to the
given buffer.
|
static byte[] |
encodeGenericRequest(AbstractRequest req)
Encode a generic request (containing a handle, and the basic header info).
|
static byte[] |
encodeGenericResponse(AbstractMessage res)
Encode the given generic message (identified only by the opCode, and responseCode)
and return the resulting buffer.
|
static byte[] |
encodeGlobalValues(HandleValue[] values)
Encode the given handle values into a buffer that can be used as the global
(or root) service/site information.
|
static int |
encodeHandleValue(byte[] buf,
int offset,
HandleValue value)
Encode the values of the handle into the specified array starting at offset.
|
static byte[] |
encodeHandleValue(HandleValue value) |
static byte[] |
encodeLocalSites(SiteInfo[] sites,
java.lang.String[][] na)
Encode the given String[]/SiteInfo pairs into a buffer that can be used
as the local service/site information.
|
static byte[] |
encodeMessage(AbstractMessage msg)
Encode the given message object as a byte array and return the resulting
buffer.
|
static byte[] |
encodeModifyValueRequest(ModifyValueRequest req)
Encode a ModifyValueRequest object and return the buffer with the encoding.
|
static byte[] |
encodeRemoveValueRequest(RemoveValueRequest req)
Encode a RemoveValueRequest object and return the buffer with the encoding.
|
static byte[] |
encodeResolutionRequest(ResolutionRequest req)
Encode the given ResolutionRequest and return the resulting buffer
|
static byte[] |
encodeResolutionResponse(ResolutionResponse res)
Encode the given ResolutionResponse and return the resulting buffer
|
static byte[] |
encodeSecretKey(byte[] secretKey,
boolean shadow)
Encode the given secret key into a byte array, performing an SHA1 hash
and upper-case hex encoding if the shadow flag is set.
|
static byte[] |
encodeServiceReferralResponse(ServiceReferralResponse res) |
static byte[] |
encodeSiteInfoRecord(SiteInfo site)
Encode the given site info record into a byte array and return
the result.
|
static byte[] |
encodeValueReferenceList(ValueReference[] values)
Encode the given list of handle value references (handle/index pairs)
and return the resulting byte array.
|
static int |
getHandleValueIndex(byte[] buf,
int offset)
Get only the index from the encoded handle value starting at offset.
|
static byte |
getHandleValuePermissions(byte[] buf,
int offset)
Get only the permissions from the encoded handle value starting at offset.
|
static byte[] |
getHandleValueType(byte[] buf,
int offset)
Get only the type from the encoded handle value starting at offset.
|
static byte[] |
readByteArray(byte[] buf,
int offset)
Read a byte array from the given buffer starting at the specified
location.
|
static int |
readByteArrayArray(byte[][] a,
byte[] buf,
int offset)
This allocates and reads an array of byte arrays where the length of the
array is already known.
|
static int |
readInt(byte[] buf,
int offset)
Read a 4-byte integer value from the given byte array
starting at the specified location.
|
static int |
readInt2(byte[] buf,
int offset)
Read a 2-byte integer value from the given byte array
starting at the specified location.
|
static int[] |
readIntArray(byte[] buf,
int offset)
Read an array of 4-byte integer values from the given buffer starting at
the specified location.
|
static long |
readLong(byte[] buf,
int offset)
Read an 8-octet integer (java long) value from the given byte array
starting at the specified location.
|
static int |
writeByteArray(byte[] buf,
int offset,
byte[] bufToWrite)
Write the given byte array to a given buffer starting at the specified
location.
|
static int |
writeByteArray(byte[] buf,
int offset,
byte[] bufToWrite,
int woffset,
int length)
Write the given byte array to a given buffer starting at the specified
location.
|
static int |
writeByteArrayArray(byte[] buf,
int offset,
byte[][] bufToWrite)
This writes an array of byte arrays to the given buffer.
|
static int |
writeInt(byte[] buf,
int offset,
int value)
Write a 4-byte integer value into the given byte array
starting at the specified location.
|
static int |
writeInt2(byte[] buf,
int offset,
int value)
Write a 2-byte integer value into the given byte array
starting at the specified location.
|
static int |
writeIntArray(byte[] buf,
int offset,
int[] bufToWrite)
This writes a given array of integers to the given buffer, starting at the
specified location.
|
static void |
writeLocalAddresses(java.util.Map map,
java.io.OutputStream out)
Writes pairs of IP addresses into a hashtable.
|
static int |
writeLong(byte[] buf,
int offset,
long value)
Write an 8-octet integer (java long) value into the given byte array
starting at the specified location.
|
public static final int INT_SIZE
public static final int INT2_SIZE
public static final int LONG_SIZE
public static final int MSG_FLAG_AUTH
public static final int MSG_FLAG_CERT
public static final int MSG_FLAG_ENCR
public static final int MSG_FLAG_RECU
public static final int MSG_FLAG_CACR
public static final int MSG_FLAG_CONT
public static final int MSG_FLAG_KPAL
public static final int MSG_FLAG_PUBL
public static final int MSG_FLAG_RRDG
public static final int MSG_FLAG_OVRW
public static final byte ENV_FLAG_COMPRESSED
public static final byte ENV_FLAG_ENCRYPTED
public static final byte ENV_FLAG_TRUNCATED
public static final byte PERM_ADMIN_READ
public static final byte PERM_ADMIN_WRITE
public static final byte PERM_PUBLIC_READ
public static final byte PERM_PUBLIC_WRITE
public static final java.lang.String MSG_INVALID_ARRAY_SIZE
public static final int SESSION_FLAG_CERT
public static final int SESSION_FLAG_ENCR
public static final long readLong(byte[] buf, int offset)
public static final int writeLong(byte[] buf, int offset, long value)
public static final int readInt2(byte[] buf, int offset)
public static final int writeInt2(byte[] buf, int offset, int value)
public static final int readInt(byte[] buf, int offset)
public static final int writeInt(byte[] buf, int offset, int value)
public static final byte[] readByteArray(byte[] buf, int offset) throws HandleException
HandleException
public static final int writeByteArray(byte[] buf, int offset, byte[] bufToWrite)
public static final int writeByteArray(byte[] buf, int offset, byte[] bufToWrite, int woffset, int length)
public static final int writeByteArrayArray(byte[] buf, int offset, byte[][] bufToWrite)
public static final int writeIntArray(byte[] buf, int offset, int[] bufToWrite)
public static final int[] readIntArray(byte[] buf, int offset) throws HandleException
HandleException
public static final int readByteArrayArray(byte[][] a, byte[] buf, int offset) throws HandleException
HandleException
public static final void dumpBytes(byte[] buf)
public static final void dumpBytes(byte[] buf, int len)
public static final void dumpBytes(byte[] buf, int offset, int len)
public static final AbstractMessage decodeMessage(byte[] msg, int offset, MessageEnvelope envelope) throws HandleException
HandleException
public static void decodeSiteInfoRecord(byte[] data, int offset, SiteInfo site) throws HandleException
HandleException
public static byte[] encodeSiteInfoRecord(SiteInfo site)
public static AdminRecord decodeAdminRecord(byte[] data, int offset) throws HandleException
HandleException
public static void decodeAdminRecord(byte[] data, int offset, AdminRecord admin) throws HandleException
HandleException
public static byte[] encodeAdminRecord(AdminRecord admin)
public static byte[] encodeSecretKey(byte[] secretKey, boolean shadow) throws java.lang.Exception
java.lang.Exception
public static int calculateAdminRecordSize(AdminRecord admin)
public static byte[] encodeGenericRequest(AbstractRequest req)
public static GenericRequest decodeGenericRequest(byte[] msg, int offset, int opCode, MessageEnvelope env) throws HandleException
HandleException
public static byte[] encodeHandleValue(HandleValue value)
public static final int encodeHandleValue(byte[] buf, int offset, HandleValue value)
public static final byte[] getHandleValueType(byte[] buf, int offset) throws HandleException
HandleException
public static final int getHandleValueIndex(byte[] buf, int offset)
public static final byte getHandleValuePermissions(byte[] buf, int offset)
public static final int calcStorageSize(HandleValue value)
public static final int calcHandleValueSize(byte[] values, int offset)
public static final int decodeHandleValue(byte[] buf, int offset, HandleValue value) throws HandleException
HandleException
public static final byte[] encodeMessage(AbstractMessage msg) throws HandleException
HandleException
public static final void encodeEnvelope(MessageEnvelope msgEnv, byte[] udpPkt) throws HandleException
HandleException
public static final void decodeEnvelope(byte[] udpPkt, MessageEnvelope msgEnv) throws HandleException
HandleException
public static final AddValueRequest decodeAddValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static final byte[] encodeAddValueRequest(AddValueRequest req) throws HandleException
HandleException
public static final ModifyValueRequest decodeModifyValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static final byte[] encodeModifyValueRequest(ModifyValueRequest req) throws HandleException
HandleException
public static final RemoveValueRequest decodeRemoveValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static final byte[] encodeRemoveValueRequest(RemoveValueRequest req) throws HandleException
HandleException
public static final DeleteHandleRequest decodeDeleteHandleRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static final byte[] encodeDeleteHandleRequest(DeleteHandleRequest req)
public static final GenericResponse decodeGenericResponse(byte[] msg, int loc, MessageEnvelope env)
public static final byte[] encodeGenericResponse(AbstractMessage res)
public static final CreateHandleRequest decodeCreateHandleRequest(byte[] msg, int offset, MessageEnvelope env, int opCode) throws HandleException
HandleException
public static final byte[] encodeCreateHandleRequest(CreateHandleRequest req) throws HandleException
HandleException
public static ResolutionRequest decodeResolutionRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static ResolutionResponse decodeResolutionResponse(byte[] msg, int offset, MessageEnvelope env) throws HandleException
HandleException
public static ServiceReferralResponse decodeServiceReferralResponse(int responseCode, byte[] msg, int offset, MessageEnvelope env, int endOfBuf) throws HandleException
HandleException
public static final byte[] encodeResolutionRequest(ResolutionRequest req)
public static final byte[] encodeResolutionResponse(ResolutionResponse res)
public static final byte[] encodeServiceReferralResponse(ServiceReferralResponse res)
public static final ValueReference[] decodeValueReferenceList(byte[] buf, int offset) throws HandleException
HandleException
public static final byte[] encodeValueReferenceList(ValueReference[] values)
public static final byte[] encodeGlobalValues(HandleValue[] values) throws HandleException
HandleException
public static final byte[] encodeLocalSites(SiteInfo[] sites, java.lang.String[][] na) throws HandleException
HandleException
public static final java.util.HashMap decodeLocalSites(java.io.InputStream in) throws HandleException
HandleException
public static final java.util.HashMap decodeLocalAddresses(java.io.InputStream in) throws HandleException
HandleException
public static final void writeLocalAddresses(java.util.Map map, java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public static final HandleValue[] decodeGlobalValues(java.io.InputStream in) throws HandleException
HandleException
public static final HandleValue[] decodeHandleValues(byte[] buf) throws HandleException
HandleException
@Deprecated public static final byte[] decryptMessage(SessionInfo session, byte[] ciphermsg, byte[] secretKey) throws HandleException
HandleException