Package com.sun.ts.tests.jms.common
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
Class Declaration.
-
Field Summary
Fields inherited from class com.sun.ts.tests.jms.common.MessageTestImpl
bufferIsDirty, dummy, readMode
Fields inherited from interface jakarta.jms.Message
DEFAULT_DELIVERY_DELAY, DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
boolean
Class Constructor.byte
readByte()
Read a signed 8-bit value from the BytesMessage.int
readBytes
(byte[] value) Read a byte array from the BytesMessage.int
readBytes
(byte[] value, int length) Read a portion of the bytes message.char
readChar()
Read a Unicode character value from the BytesMessage.double
Read adouble
from the BytesMessage.float
Read afloat
from the BytesMessage.int
readInt()
Read a signed 32-bit integer from the BytesMessage.long
readLong()
Read a signed 64-bit integer from the BytesMessage.short
Read a signed 16-bit number from the BytesMessage.int
Read an unsigned 8-bit number from the BytesMessage.int
Read an unsigned 16-bit number from the BytesMessage.readUTF()
Read in a string that has been encoded using a modified UTF-8 format from the BytesMessage.void
reset()
Put the message in read-only mode, and reposition the stream of bytes to the beginning.void
setBodyLength
(long l) void
writeBoolean
(boolean writeBoolean) Write aboolean
to the BytesMessage as a 1-byte value.void
writeByte
(byte value) Write out abyte
to the BytesMessage as a 1-byte value.void
writeBytes
(byte[] value) Write a byte array to the BytesMessage.void
writeBytes
(byte[] value, int offset, int length) Write a portion of a byte array to the BytesMessage.void
writeChar
(char value) Write achar
to the BytesMessage as a 2-byte value, high byte first.void
writeDouble
(double value) Convert the double argument to along
using thedoubleToLongBits
method in classDouble
, and then writes thatlong
value to the stream message as an 8-byte quantity, high byte first.void
writeFloat
(float value) Convert the float argument to anint
using thefloatToIntBits
method in classFloat
, and then writes thatint
value to the stream message as a 4-byte quantity, high byte first.void
writeInt
(int value) Write anint
to the BytesMessage as four bytes, high byte first.void
writeLong
(long value) Write along
to the BytesMessage as eight bytes, high byte first.void
writeObject
(Object value) Write a Java object to the BytesMessage.void
writeShort
(short value) Write ashort
to the BytesMessage as two bytes, high byte first.void
Write a string to the BytesMessage using UTF-8 encoding in a machine-independent manner.Methods inherited from class com.sun.ts.tests.jms.common.MessageTestImpl
acknowledge, checkReadAccess, clearBody, clearProperties, getBody, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, isBodyAssignableTo, propertyExists, setBooleanProperty, setBufferIsDirty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.jms.Message
acknowledge, clearBody, clearProperties, getBody, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, isBodyAssignableTo, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
-
Constructor Details
-
BytesMessageTestImpl
public BytesMessageTestImpl()
-
-
Method Details
-
readBoolean
public boolean readBoolean() throws jakarta.jms.JMSExceptionClass 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 interfacejakarta.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 aboolean
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.JMSExceptionRead a signed 8-bit value from the BytesMessage.- Specified by:
readByte
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readUnsignedByte
public int readUnsignedByte() throws jakarta.jms.JMSExceptionRead an unsigned 8-bit number from the BytesMessage.- Specified by:
readUnsignedByte
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readShort
public short readShort() throws jakarta.jms.JMSExceptionRead a signed 16-bit number from the BytesMessage.- Specified by:
readShort
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readUnsignedShort
public int readUnsignedShort() throws jakarta.jms.JMSExceptionRead an unsigned 16-bit number from the BytesMessage.- Specified by:
readUnsignedShort
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readChar
public char readChar() throws jakarta.jms.JMSExceptionRead a Unicode character value from the BytesMessage.- Specified by:
readChar
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readInt
public int readInt() throws jakarta.jms.JMSExceptionRead a signed 32-bit integer from the BytesMessage.- Specified by:
readInt
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readLong
public long readLong() throws jakarta.jms.JMSExceptionRead a signed 64-bit integer from the BytesMessage.- Specified by:
readLong
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readFloat
public float readFloat() throws jakarta.jms.JMSExceptionRead afloat
from the BytesMessage.- Specified by:
readFloat
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readDouble
public double readDouble() throws jakarta.jms.JMSExceptionRead adouble
from the BytesMessage.- Specified by:
readDouble
in interfacejakarta.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 streamjakarta.jms.JMSException
- if JMS fails to read message due to some internal JMS error.
-
readUTF
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 interfacejakarta.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 streamjakarta.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 interfacejakarta.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 streamjakarta.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 interfacejakarta.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 streamjakarta.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 aboolean
to the BytesMessage as a 1-byte value. The valuetrue
is written out as the value(byte)1
; the valuefalse
is written out as the value(byte)0
.- Specified by:
writeBoolean
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- theboolean
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 abyte
to the BytesMessage as a 1-byte value.- Specified by:
writeByte
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- thebyte
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 ashort
to the BytesMessage as two bytes, high byte first.- Specified by:
writeShort
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- theshort
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 achar
to the BytesMessage as a 2-byte value, high byte first.- Specified by:
writeChar
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- thechar
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 anint
to the BytesMessage as four bytes, high byte first.- Specified by:
writeInt
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- theint
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 along
to the BytesMessage as eight bytes, high byte first.- Specified by:
writeLong
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- thelong
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 anint
using thefloatToIntBits
method in classFloat
, and then writes thatint
value to the stream message as a 4-byte quantity, high byte first.- Specified by:
writeFloat
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- thefloat
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 along
using thedoubleToLongBits
method in classDouble
, and then writes thatlong
value to the stream message as an 8-byte quantity, high byte first.- Specified by:
writeDouble
in interfacejakarta.jms.BytesMessage
- Parameters:
value
- thedouble
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
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 interfacejakarta.jms.BytesMessage
- Parameters:
value
- theString
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 interfacejakarta.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 interfacejakarta.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
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 interfacejakarta.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.JMSExceptionPut the message in read-only mode, and reposition the stream of bytes to the beginning.- Specified by:
reset
in interfacejakarta.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 interfacejakarta.jms.BytesMessage
-
setBodyLength
public void setBodyLength(long l)
-