Class BytesMessageTestImpl

java.lang.Object
com.sun.ts.tests.jms.common.MessageTestImpl
com.sun.ts.tests.jms.common.BytesMessageTestImpl
All Implemented Interfaces:
jakarta.jms.BytesMessage, jakarta.jms.Message

public class BytesMessageTestImpl extends MessageTestImpl implements jakarta.jms.BytesMessage
Class Declaration.
  • Constructor Details

    • BytesMessageTestImpl

      public BytesMessageTestImpl()
  • Method Details

    • readBoolean

      public boolean readBoolean() throws jakarta.jms.JMSException
      Class Constructor. / public BytesMessageTestImpl() { super(); init(); } /** Method Declaration. / private void init() { buf = new byte[0]; baos = new ByteArrayOutputStream(); dos = new DataOutputStream(baos); } /** Method Declaration.
      Specified by:
      readBoolean in interface jakarta.jms.BytesMessage
      Parameters:
      oos -
      ois -
      Returns:
      the boolean value read.
      Throws:
      IOException - / private void writeObject(ObjectOutputStream oos) throws IOException { dos.flush(); buf = baos.toByteArray(); oos.defaultWriteObject(); } /** Method Declaration.
      ClassNotFoundException
      IOException - / private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); baos = new ByteArrayOutputStream(); dos = new DataOutputStream(baos); if (buf != null) { dos.write(buf); buf = null; } } /** Method Declaration.
      jakarta.jms.JMSException - / public void clearBody() throws JMSException { buf = null; bais = null; dis = null; readMode = false; } /** Read a boolean from the BytesMessage.
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
      jakarta.jms.MessageEOFException - if end of message stream
    • readByte

      public byte readByte() throws jakarta.jms.JMSException
      Read a signed 8-bit value from the BytesMessage.
      Specified by:
      readByte in interface jakarta.jms.BytesMessage
      Returns:
      the next byte from the BytesMessage as a signed 8-bit byte.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readUnsignedByte

      public int readUnsignedByte() throws jakarta.jms.JMSException
      Read an unsigned 8-bit number from the BytesMessage.
      Specified by:
      readUnsignedByte in interface jakarta.jms.BytesMessage
      Returns:
      the next byte from the BytesMessage, interpreted as an unsigned 8-bit number.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readShort

      public short readShort() throws jakarta.jms.JMSException
      Read a signed 16-bit number from the BytesMessage.
      Specified by:
      readShort in interface jakarta.jms.BytesMessage
      Returns:
      the next two bytes from the BytesMessage, interpreted as a signed 16-bit number.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readUnsignedShort

      public int readUnsignedShort() throws jakarta.jms.JMSException
      Read an unsigned 16-bit number from the BytesMessage.
      Specified by:
      readUnsignedShort in interface jakarta.jms.BytesMessage
      Returns:
      the next two bytes from the BytesMessage, interpreted as an unsigned 16-bit integer.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readChar

      public char readChar() throws jakarta.jms.JMSException
      Read a Unicode character value from the BytesMessage.
      Specified by:
      readChar in interface jakarta.jms.BytesMessage
      Returns:
      the next two bytes from the BytesMessage as a Unicode character.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readInt

      public int readInt() throws jakarta.jms.JMSException
      Read a signed 32-bit integer from the BytesMessage.
      Specified by:
      readInt in interface jakarta.jms.BytesMessage
      Returns:
      the next four bytes from the BytesMessage, interpreted as an int.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readLong

      public long readLong() throws jakarta.jms.JMSException
      Read a signed 64-bit integer from the BytesMessage.
      Specified by:
      readLong in interface jakarta.jms.BytesMessage
      Returns:
      the next eight bytes from the BytesMessage, interpreted as a long.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readFloat

      public float readFloat() throws jakarta.jms.JMSException
      Read a float from the BytesMessage.
      Specified by:
      readFloat in interface jakarta.jms.BytesMessage
      Returns:
      the next four bytes from the BytesMessage, interpreted as a float.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readDouble

      public double readDouble() throws jakarta.jms.JMSException
      Read a double from the BytesMessage.
      Specified by:
      readDouble in interface jakarta.jms.BytesMessage
      Returns:
      the next eight bytes from the BytesMessage, interpreted as a double.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readUTF

      public String readUTF() throws jakarta.jms.JMSException
      Read in a string that has been encoded using a modified UTF-8 format from the BytesMessage. For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UFT)", X/Open Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.
      Specified by:
      readUTF in interface jakarta.jms.BytesMessage
      Returns:
      a Unicode string from the BytesMessage.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readBytes

      public int readBytes(byte[] value) throws jakarta.jms.JMSException
      Read a byte array from the BytesMessage.
      Specified by:
      readBytes in interface jakarta.jms.BytesMessage
      Parameters:
      value - the buffer into which the data is read.
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • readBytes

      public int readBytes(byte[] value, int length) throws jakarta.jms.JMSException
      Read a portion of the bytes message.
      Specified by:
      readBytes in interface jakarta.jms.BytesMessage
      Parameters:
      value - the buffer into which the data is read.
      length - the number of bytes to read.
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
      Throws:
      jakarta.jms.MessageNotReadableException - if message in write-only mode.
      jakarta.jms.MessageEOFException - if end of message stream
      jakarta.jms.JMSException - if JMS fails to read message due to some internal JMS error.
    • writeBoolean

      public void writeBoolean(boolean writeBoolean) throws jakarta.jms.JMSException
      Write a boolean to the BytesMessage as a 1-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0.
      Specified by:
      writeBoolean in interface jakarta.jms.BytesMessage
      Parameters:
      value - the boolean value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeByte

      public void writeByte(byte value) throws jakarta.jms.JMSException
      Write out a byte to the BytesMessage as a 1-byte value.
      Specified by:
      writeByte in interface jakarta.jms.BytesMessage
      Parameters:
      value - the byte value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeShort

      public void writeShort(short value) throws jakarta.jms.JMSException
      Write a short to the BytesMessage as two bytes, high byte first.
      Specified by:
      writeShort in interface jakarta.jms.BytesMessage
      Parameters:
      value - the short to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeChar

      public void writeChar(char value) throws jakarta.jms.JMSException
      Write a char to the BytesMessage as a 2-byte value, high byte first.
      Specified by:
      writeChar in interface jakarta.jms.BytesMessage
      Parameters:
      value - the char value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeInt

      public void writeInt(int value) throws jakarta.jms.JMSException
      Write an int to the BytesMessage as four bytes, high byte first.
      Specified by:
      writeInt in interface jakarta.jms.BytesMessage
      Parameters:
      value - the int to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeLong

      public void writeLong(long value) throws jakarta.jms.JMSException
      Write a long to the BytesMessage as eight bytes, high byte first.
      Specified by:
      writeLong in interface jakarta.jms.BytesMessage
      Parameters:
      value - the long to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeFloat

      public void writeFloat(float value) throws jakarta.jms.JMSException
      Convert the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the stream message as a 4-byte quantity, high byte first.
      Specified by:
      writeFloat in interface jakarta.jms.BytesMessage
      Parameters:
      value - the float value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeDouble

      public void writeDouble(double value) throws jakarta.jms.JMSException
      Convert the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the stream message as an 8-byte quantity, high byte first.
      Specified by:
      writeDouble in interface jakarta.jms.BytesMessage
      Parameters:
      value - the double value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeUTF

      public void writeUTF(String value) throws jakarta.jms.JMSException
      Write a string to the BytesMessage using UTF-8 encoding in a machine-independent manner. For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UFT)", X/Open Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.
      Specified by:
      writeUTF in interface jakarta.jms.BytesMessage
      Parameters:
      value - the String value to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeBytes

      public void writeBytes(byte[] value) throws jakarta.jms.JMSException
      Write a byte array to the BytesMessage.
      Specified by:
      writeBytes in interface jakarta.jms.BytesMessage
      Parameters:
      value - the byte array to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeBytes

      public void writeBytes(byte[] value, int offset, int length) throws jakarta.jms.JMSException
      Write a portion of a byte array to the BytesMessage.
      Specified by:
      writeBytes in interface jakarta.jms.BytesMessage
      Parameters:
      value - the byte array value to be written.
      offset - the initial offset within the byte array.
      length - the number of bytes to use.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • writeObject

      public void writeObject(Object value) throws jakarta.jms.JMSException
      Write a Java object to the BytesMessage. Note that this method only works for the objectified primitive object types (Integer, Double, Long ...), String's and byte arrays.
      Specified by:
      writeObject in interface jakarta.jms.BytesMessage
      Parameters:
      value - the Java object to be written.
      Throws:
      jakarta.jms.MessageNotWriteableException - if message in read-only mode.
      jakarta.jms.MessageFormatException - if object is invalid type.
      jakarta.jms.JMSException - if JMS fails to write message due to some internal JMS error.
    • reset

      public void reset() throws jakarta.jms.JMSException
      Put the message in read-only mode, and reposition the stream of bytes to the beginning.
      Specified by:
      reset in interface jakarta.jms.BytesMessage
      Throws:
      jakarta.jms.JMSException - if JMS fails to reset the message due to some internal JMS error.
      jakarta.jms.MessageFormatException - if message has an invalid format
    • getBodyLength

      public long getBodyLength()
      Specified by:
      getBodyLength in interface jakarta.jms.BytesMessage
    • setBodyLength

      public void setBodyLength(long l)