Package net.handle.hdllib
Class Encoder
- java.lang.Object
-
- net.handle.hdllib.Encoder
-
public abstract class Encoder extends java.lang.Object
The static functions in this class are used to translate message objects and records to and from their byte-array representation in which they are sent over the network.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Encoder.MessageHeaders
-
Field Summary
Fields Modifier and Type Field 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_DNRF
static int
MSG_FLAG_ENCR
static int
MSG_FLAG_KPAL
static int
MSG_FLAG_MINT
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 Summary
Constructors Constructor Description Encoder()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
calcHandleValueSize(byte[] values, int offset)
Calculate the number of bytes required to store the specified valuestatic int
calcStorageSize(HandleValue value)
Calculate the number of bytes required to store the specified valuestatic 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 bufferstatic 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 bufferstatic DeleteHandleRequest
decodeDeleteHandleRequest(byte[] msg, int offset, MessageEnvelope env)
Decode, create, and return a DeleteHandleRequest from the given bufferstatic 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 HandleValue[]
decodeHandleValue(byte[][] handleValues)
Deprecated.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 HandleValue[]
decodeHandleValues(byte[][] handleValues)
Converts a raw buffer into an array of HandleValue.static java.util.Map<java.lang.String,java.lang.String>
decodeLocalAddresses(java.io.InputStream in)
Reads pairs of IP addresses into a hashtable.static java.util.Map<java.lang.String,SiteInfo[]>
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 0 envelop, return a response object.static ModifyValueRequest
decodeModifyValueRequest(byte[] msg, int offset, MessageEnvelope env)
Decode, create, and return a ModifyValueRequest object from the given bufferstatic void
decodeOpFlagsInToMessage(AbstractMessage message, int opFlags)
static RemoveValueRequest
decodeRemoveValueRequest(byte[] msg, int offset, MessageEnvelope env)
Decode, create, and return a RemoveValueRequest object from the given bufferstatic 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 SiteInfo
decodeSiteInfoRecord(byte[] data, int offset)
Decode a site info record from a byte array.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 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[]
encodeCreateHandleResponse(CreateHandleResponse res)
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[][]
encodeHandleValues(HandleValue[] values)
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 bufferstatic byte[]
encodeResolutionResponse(ResolutionResponse res)
Encode the given ResolutionResponse and return the resulting bufferstatic byte[]
encodeSecretKey(byte[] secretKey, boolean hash)
Encode the given secret key into a byte array, performing an SHA1 hash and lower-case hex encoding if the hash 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
readOpCode(byte[] msg, int offset)
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.
-
-
-
Field Detail
-
INT_SIZE
public static final int INT_SIZE
- See Also:
- Constant Field Values
-
INT2_SIZE
public static final int INT2_SIZE
- See Also:
- Constant Field Values
-
LONG_SIZE
public static final int LONG_SIZE
- See Also:
- Constant Field Values
-
MSG_FLAG_AUTH
public static final int MSG_FLAG_AUTH
- See Also:
- Constant Field Values
-
MSG_FLAG_CERT
public static final int MSG_FLAG_CERT
- See Also:
- Constant Field Values
-
MSG_FLAG_ENCR
public static final int MSG_FLAG_ENCR
- See Also:
- Constant Field Values
-
MSG_FLAG_RECU
public static final int MSG_FLAG_RECU
- See Also:
- Constant Field Values
-
MSG_FLAG_CACR
public static final int MSG_FLAG_CACR
- See Also:
- Constant Field Values
-
MSG_FLAG_CONT
public static final int MSG_FLAG_CONT
- See Also:
- Constant Field Values
-
MSG_FLAG_KPAL
public static final int MSG_FLAG_KPAL
- See Also:
- Constant Field Values
-
MSG_FLAG_PUBL
public static final int MSG_FLAG_PUBL
- See Also:
- Constant Field Values
-
MSG_FLAG_RRDG
public static final int MSG_FLAG_RRDG
- See Also:
- Constant Field Values
-
MSG_FLAG_OVRW
public static final int MSG_FLAG_OVRW
- See Also:
- Constant Field Values
-
MSG_FLAG_MINT
public static final int MSG_FLAG_MINT
- See Also:
- Constant Field Values
-
MSG_FLAG_DNRF
public static final int MSG_FLAG_DNRF
- See Also:
- Constant Field Values
-
ENV_FLAG_COMPRESSED
public static final byte ENV_FLAG_COMPRESSED
- See Also:
- Constant Field Values
-
ENV_FLAG_ENCRYPTED
public static final byte ENV_FLAG_ENCRYPTED
- See Also:
- Constant Field Values
-
ENV_FLAG_TRUNCATED
public static final byte ENV_FLAG_TRUNCATED
- See Also:
- Constant Field Values
-
PERM_ADMIN_READ
public static final byte PERM_ADMIN_READ
- See Also:
- Constant Field Values
-
PERM_ADMIN_WRITE
public static final byte PERM_ADMIN_WRITE
- See Also:
- Constant Field Values
-
PERM_PUBLIC_READ
public static final byte PERM_PUBLIC_READ
- See Also:
- Constant Field Values
-
PERM_PUBLIC_WRITE
public static final byte PERM_PUBLIC_WRITE
- See Also:
- Constant Field Values
-
MSG_INVALID_ARRAY_SIZE
public static final java.lang.String MSG_INVALID_ARRAY_SIZE
- See Also:
- Constant Field Values
-
SESSION_FLAG_CERT
public static final int SESSION_FLAG_CERT
- See Also:
- Constant Field Values
-
SESSION_FLAG_ENCR
public static final int SESSION_FLAG_ENCR
- See Also:
- Constant Field Values
-
-
Method Detail
-
readLong
public static final long readLong(byte[] buf, int offset)
Read an 8-octet integer (java long) value from the given byte array starting at the specified location.
-
writeLong
public static final 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.
-
readInt2
public static final int readInt2(byte[] buf, int offset)
Read a 2-byte integer value from the given byte array starting at the specified location.
-
writeInt2
public static final int writeInt2(byte[] buf, int offset, int value)
Write a 2-byte integer value into the given byte array starting at the specified location.
-
readInt
public static final int readInt(byte[] buf, int offset)
Read a 4-byte integer value from the given byte array starting at the specified location.
-
writeInt
public static final int writeInt(byte[] buf, int offset, int value)
Write a 4-byte integer value into the given byte array starting at the specified location.
-
readByteArray
public static final byte[] readByteArray(byte[] buf, int offset) throws HandleException
Read a byte array from the given buffer starting at the specified location. This method first reads a 4-octet integer and then reads that many bytes from the buffer.- Throws:
HandleException
-
writeByteArray
public static final int writeByteArray(byte[] buf, int offset, byte[] bufToWrite)
Write the given byte array to a given buffer starting at the specified location. This first writes the length of the array as a 4-octet integer, and then writes the bytes of the array.
-
writeByteArray
public static final 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. This first writes the length of the array as a 4-octet integer, and then writes the bytes of the array.
-
writeByteArrayArray
public static final int writeByteArrayArray(byte[] buf, int offset, byte[][] bufToWrite)
This writes an array of byte arrays to the given buffer. This first writes the number of arrays as a 4-octet integer, and then writes each individual byte array using a call to writeByteArray.
-
writeIntArray
public static final int writeIntArray(byte[] buf, int offset, int[] bufToWrite)
This writes a given array of integers to the given buffer, starting at the specified location. This first writes the length of the integer array as a 4-octet integer, then writes each integer in the array using a call to writeInt. This will return the number of bytes that were read.
-
readIntArray
public static final int[] readIntArray(byte[] buf, int offset) throws HandleException
Read an array of 4-byte integer values from the given buffer starting at the specified location. This method first reads a 4-octet integer and then reads that many integer values from the buffer.- Throws:
HandleException
-
readByteArrayArray
public static final int readByteArrayArray(byte[][] a, byte[] buf, int offset) throws HandleException
This allocates and reads an array of byte arrays where the length of the array is already known. For each byte array in 'a', this reads a byte array using a call to readByteArray. This will return the number of bytes that were read.- Throws:
HandleException
-
dumpBytes
public static final void dumpBytes(byte[] buf)
Display the contents of the given buffer in a somewhat human-readable format. This is only used for debugging.
-
dumpBytes
public static final void dumpBytes(byte[] buf, int len)
Display the contents of the given buffer in a somewhat human-readable format. This is only used for debugging.
-
dumpBytes
public static final void dumpBytes(byte[] buf, int offset, int len)
Display the contents of the given buffer in a somewhat human-readable format. This is only used for debugging.
-
readOpCode
public static int readOpCode(byte[] msg, int offset)
-
decodeMessage
public static final AbstractMessage decodeMessage(byte[] msg, int offset, MessageEnvelope envelope) throws HandleException
decode a response message - given the message buffer and a separate 0 envelop, return a response object. If the message is a certified message, the signature for the message is read and put into the message object.- Throws:
HandleException
-
decodeOpFlagsInToMessage
public static void decodeOpFlagsInToMessage(AbstractMessage message, int opFlags)
-
decodeSiteInfoRecord
public static SiteInfo decodeSiteInfoRecord(byte[] data, int offset) throws HandleException
Decode a site info record from a byte array.- Throws:
HandleException
-
decodeSiteInfoRecord
public static void decodeSiteInfoRecord(byte[] data, int offset, SiteInfo site) throws HandleException
Decode a site info record from a byte array.- Throws:
HandleException
-
encodeSiteInfoRecord
public static byte[] encodeSiteInfoRecord(SiteInfo site)
Encode the given site info record into a byte array and return the result.
-
decodeAdminRecord
public static AdminRecord decodeAdminRecord(byte[] data, int offset) throws HandleException
- Throws:
HandleException
-
decodeAdminRecord
public static void decodeAdminRecord(byte[] data, int offset, AdminRecord admin) throws HandleException
Decode an administrator record from the given byte array.- Throws:
HandleException
-
encodeAdminRecord
public static byte[] encodeAdminRecord(AdminRecord admin)
Encode the given admin record into a byte array and return it.
-
encodeSecretKey
public static byte[] encodeSecretKey(byte[] secretKey, boolean hash) throws java.lang.Exception
Encode the given secret key into a byte array, performing an SHA1 hash and lower-case hex encoding if the hash flag is set. If the hash flag is not set this may return the same secretKey array that was passed as a parameter.- Throws:
java.lang.Exception
-
calculateAdminRecordSize
public 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.
-
encodeGenericRequest
public static byte[] encodeGenericRequest(AbstractRequest req)
Encode a generic request (containing a handle, and the basic header info).
-
decodeGenericRequest
public static GenericRequest decodeGenericRequest(byte[] msg, int offset, int opCode, MessageEnvelope env) throws HandleException
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.- Throws:
HandleException
-
encodeHandleValue
public static byte[] encodeHandleValue(HandleValue value)
-
encodeHandleValues
public static byte[][] encodeHandleValues(HandleValue[] values)
-
encodeHandleValue
public static final int encodeHandleValue(byte[] buf, int offset, HandleValue value)
Encode the values of the handle into the specified array starting at offset.- Returns:
- the number of bytes written to the array.;
-
getHandleValueType
public static final byte[] getHandleValueType(byte[] buf, int offset) throws HandleException
Get only the type from the encoded handle value starting at offset.- Throws:
HandleException
-
getHandleValueIndex
public static final int getHandleValueIndex(byte[] buf, int offset)
Get only the index from the encoded handle value starting at offset.
-
getHandleValuePermissions
public static final byte getHandleValuePermissions(byte[] buf, int offset)
Get only the permissions from the encoded handle value starting at offset.
-
calcStorageSize
public static final int calcStorageSize(HandleValue value)
Calculate the number of bytes required to store the specified value
-
calcHandleValueSize
public static final int calcHandleValueSize(byte[] values, int offset)
Calculate the number of bytes required to store the specified value
-
decodeHandleValues
public static HandleValue[] decodeHandleValues(byte[][] handleValues) throws HandleException
Converts a raw buffer into an array of HandleValue.- Parameters:
handleValues
-- Returns:
- null in the case the handleValues parameter is null;
- Throws:
HandleException
-
decodeHandleValue
@Deprecated public static HandleValue[] decodeHandleValue(byte[][] handleValues) throws HandleException
Deprecated.- Throws:
HandleException
-
decodeHandleValue
public static final int decodeHandleValue(byte[] buf, int offset, HandleValue value) throws HandleException
Populate the specified handle value with the values encoded in the given byte array and return the number of bytes read.- Throws:
HandleException
-
encodeMessage
public static final byte[] encodeMessage(AbstractMessage msg) throws HandleException
Encode the given message object as a byte array and return the resulting buffer. The isResponse flag is necessary to determine the type of object being encoded (not really, maybe this can be cleaned up).- Throws:
HandleException
-
encodeEnvelope
public static final void encodeEnvelope(MessageEnvelope msgEnv, byte[] udpPkt)
Write the encoded value of the given message envelope to the given buffer.
-
decodeEnvelope
public static final void decodeEnvelope(byte[] udpPkt, MessageEnvelope msgEnv) throws HandleException
Read the encoded value of the given buffer and populate the fields of the given message envelope object.- Throws:
HandleException
-
decodeAddValueRequest
public static final AddValueRequest decodeAddValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode, create, and return an AddValueRequest object from the given buffer- Throws:
HandleException
-
encodeAddValueRequest
public static final byte[] encodeAddValueRequest(AddValueRequest req)
Encode an AddValueRequest object and return the buffer with the encoding.
-
decodeModifyValueRequest
public static final ModifyValueRequest decodeModifyValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode, create, and return a ModifyValueRequest object from the given buffer- Throws:
HandleException
-
encodeModifyValueRequest
public static final byte[] encodeModifyValueRequest(ModifyValueRequest req)
Encode a ModifyValueRequest object and return the buffer with the encoding.
-
decodeRemoveValueRequest
public static final RemoveValueRequest decodeRemoveValueRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode, create, and return a RemoveValueRequest object from the given buffer- Throws:
HandleException
-
encodeRemoveValueRequest
public static final byte[] encodeRemoveValueRequest(RemoveValueRequest req)
Encode a RemoveValueRequest object and return the buffer with the encoding.
-
decodeDeleteHandleRequest
public static final DeleteHandleRequest decodeDeleteHandleRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode, create, and return a DeleteHandleRequest from the given buffer- Throws:
HandleException
-
encodeDeleteHandleRequest
public static final byte[] encodeDeleteHandleRequest(DeleteHandleRequest req)
Encode the given DeleteHandleRequest and return the resulting buffer.
-
decodeGenericResponse
public static final 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.
-
encodeGenericResponse
public static final byte[] encodeGenericResponse(AbstractMessage res)
Encode the given generic message (identified only by the opCode, and responseCode) and return the resulting buffer.
-
decodeCreateHandleRequest
public static final CreateHandleRequest decodeCreateHandleRequest(byte[] msg, int offset, MessageEnvelope env, int opCode) throws HandleException
Decode, create, and return a CreateHandleRequest from the given buffer- Throws:
HandleException
-
encodeCreateHandleRequest
public static final byte[] encodeCreateHandleRequest(CreateHandleRequest req)
Encode the given CreateHandleRequest and return the resulting buffer.
-
decodeResolutionRequest
public static ResolutionRequest decodeResolutionRequest(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode and create a resolution request object from the given buffer.- Throws:
HandleException
-
decodeResolutionResponse
public static ResolutionResponse decodeResolutionResponse(byte[] msg, int offset, MessageEnvelope env) throws HandleException
Decode and create a resolution response object from the given buffer.- Throws:
HandleException
-
decodeServiceReferralResponse
public static ServiceReferralResponse decodeServiceReferralResponse(int responseCode, byte[] msg, int offset, MessageEnvelope env, int endOfBuf) throws HandleException
- Throws:
HandleException
-
encodeResolutionRequest
public static final byte[] encodeResolutionRequest(ResolutionRequest req)
Encode the given ResolutionRequest and return the resulting buffer
-
encodeResolutionResponse
public static final byte[] encodeResolutionResponse(ResolutionResponse res)
Encode the given ResolutionResponse and return the resulting buffer
-
encodeServiceReferralResponse
public static final byte[] encodeServiceReferralResponse(ServiceReferralResponse res)
-
decodeValueReferenceList
public static final ValueReference[] decodeValueReferenceList(byte[] buf, int offset) throws HandleException
Decode, create, and return a list of handle value references (handle/index pairs) from the given buffer.- Throws:
HandleException
-
encodeValueReferenceList
public static final byte[] encodeValueReferenceList(ValueReference[] values)
Encode the given list of handle value references (handle/index pairs) and return the resulting byte array.
-
encodeGlobalValues
public static final byte[] encodeGlobalValues(HandleValue[] values)
Encode the given handle values into a buffer that can be used as the global (or root) service/site information.
-
encodeLocalSites
public static final byte[] encodeLocalSites(SiteInfo[] sites, java.lang.String[][] na) throws HandleException
Encode the given String[]/SiteInfo pairs into a buffer that can be used as the local service/site information. For the SiteInfo object at sites[i] the corresponding prefixes should be listed in na[i].- Throws:
HandleException
-
decodeLocalSites
public static final java.util.Map<java.lang.String,SiteInfo[]> decodeLocalSites(java.io.InputStream in) throws HandleException
Reads SiteInfo/NA-list pairs into a hashtable. Each NA value is used as a key to a SiteInfo[].- Throws:
HandleException
-
decodeLocalAddresses
public static final java.util.Map<java.lang.String,java.lang.String> decodeLocalAddresses(java.io.InputStream in) throws HandleException
Reads pairs of IP addresses into a hashtable.- Throws:
HandleException
-
writeLocalAddresses
public static final void writeLocalAddresses(java.util.Map<?,?> map, java.io.OutputStream out) throws java.io.IOException
Writes pairs of IP addresses into a hashtable.- Throws:
java.io.IOException
-
decodeGlobalValues
public static final HandleValue[] decodeGlobalValues(java.io.InputStream in) throws HandleException
Decode from the given input stream a set of handle values. The stream should contain data in the format output from the encodeGlobalValues() function.- Throws:
HandleException
-
decodeHandleValues
public static final HandleValue[] decodeHandleValues(byte[] buf) throws HandleException
Decode from the given byte buffer, a set of handle values.- Throws:
HandleException
-
encodeCreateHandleResponse
public static final byte[] encodeCreateHandleResponse(CreateHandleResponse res)
-
-