Class Plaintext

java.lang.Object
com.sun.jini.discovery.internal.Plaintext

public class Plaintext extends Object
Provides utility methods for plaintext data operations.
  • 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

      public static byte[] toUtf(String s) throws UTFDataFormatException
      Returns a byte array containing the UTF encoding of the given string.
      Throws:
      UTFDataFormatException
    • putUtf

      public static void putUtf(ByteBuffer buf, String s) throws UTFDataFormatException
      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

      public static String getUtf(ByteBuffer buf) throws UTFDataFormatException
      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

      public static MulticastRequest decodeMulticastRequest(ByteBuffer buf) throws IOException
      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

      public static MulticastAnnouncement decodeMulticastAnnouncement(ByteBuffer buf) throws IOException
      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:
      IOException
      ClassNotFoundException