Package com.sun.jini.discovery.internal
Class Plaintext
java.lang.Object
com.sun.jini.discovery.internal.Plaintext
Provides utility methods for plaintext data operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckConstraints(InvocationConstraints constraints) Returns normally if the given constraints can be satisfied by a plaintext-based format/protocol (such as net.jini.discovery.plaintext, or version 1 of the discovery protocols); otherwise, throws an UnsupportedConstraintException .static MulticastAnnouncementDecodes multicast announcement according to the net.jini.discovery.plaintext format.static MulticastRequestDecodes multicast request according to the net.jini.discovery.plaintext format.static voidencodeMulticastAnnouncement(MulticastAnnouncement announcement, DatagramBufferFactory bufs) Encodes multicast announcement according to the net.jini.discovery.plaintext format.static voidencodeMulticastRequest(MulticastRequest request, DatagramBufferFactory bufs) Encodes multicast request according to the net.jini.discovery.plaintext format.static StringgetUtf(ByteBuffer buf) Returns string read from the given buffer in UTF format , starting at the buffer's current position and not exceeding its limit.static shortintToUshort(int i) Returns the given integer value as an unsigned short, throwing an IllegalArgumentException if the value is negative or too large.static voidputUtf(ByteBuffer buf, String s) Writes the given string to the provided buffer in UTF format, starting at the buffer's current position and not exceeding its limit.static UnicastResponsereadUnicastResponse(InputStream in, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection context) Reads unicast response according to the net.jini.discovery.plaintext format.static byte[]Returns a byte array containing the UTF encoding of the given string.static intushortToInt(short s) Returns an integer with the unsigned value of the given short.static voidwriteUnicastResponse(OutputStream out, UnicastResponse response, Collection context) Writes unicast response according to the net.jini.discovery.plaintext format.
-
Method Details
-
intToUshort
public static short intToUshort(int i) Returns the given integer value as an unsigned short, throwing an IllegalArgumentException if the value is negative or too large. -
ushortToInt
public static int ushortToInt(short s) Returns an integer with the unsigned value of the given short. -
toUtf
Returns a byte array containing the UTF encoding of the given string.- Throws:
UTFDataFormatException
-
putUtf
Writes the given string to the provided buffer in UTF format, starting at the buffer's current position and not exceeding its limit. If the encoding of the given string exceeds the buffer's limit, then a BufferOverflowException is thrown and the position of the buffer is left unchanged from its initial value.- Throws:
UTFDataFormatException
-
getUtf
Returns string read from the given buffer in UTF format , starting at the buffer's current position and not exceeding its limit. If the string's encoding extends past the buffer's limit, then a BufferUnderflowException is thrown and the position of the buffer is left unchanged from its initial value.- Throws:
UTFDataFormatException
-
checkConstraints
public static void checkConstraints(InvocationConstraints constraints) throws UnsupportedConstraintException Returns normally if the given constraints can be satisfied by a plaintext-based format/protocol (such as net.jini.discovery.plaintext, or version 1 of the discovery protocols); otherwise, throws an UnsupportedConstraintException . Null constraints are considered equivalent to empty constraints.- Throws:
UnsupportedConstraintException
-
encodeMulticastRequest
public static void encodeMulticastRequest(MulticastRequest request, DatagramBufferFactory bufs) throws IOException Encodes multicast request according to the net.jini.discovery.plaintext format.- Throws:
IOException
-
decodeMulticastRequest
Decodes multicast request according to the net.jini.discovery.plaintext format.- Throws:
IOException
-
encodeMulticastAnnouncement
public static void encodeMulticastAnnouncement(MulticastAnnouncement announcement, DatagramBufferFactory bufs) throws IOException Encodes multicast announcement according to the net.jini.discovery.plaintext format.- Throws:
IOException
-
decodeMulticastAnnouncement
Decodes multicast announcement according to the net.jini.discovery.plaintext format.- Throws:
IOException
-
writeUnicastResponse
public static void writeUnicastResponse(OutputStream out, UnicastResponse response, Collection context) throws IOException Writes unicast response according to the net.jini.discovery.plaintext format.- Throws:
IOException
-
readUnicastResponse
public static UnicastResponse readUnicastResponse(InputStream in, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection context) throws IOException, ClassNotFoundException Reads unicast response according to the net.jini.discovery.plaintext format.- Throws:
IOExceptionClassNotFoundException
-