|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.mq.MQMD | +--com.ibm.mq.MQMessage
MQMessage represents both the message descriptor and the data for a WebSphere MQ message.
It has a group of methods for reading data from a message and a group of
methods for writing data into a message.
The format of numbers and strings used by these read and write methods is
controlled by the encoding
and characterSet
fields.
The remaining fields contain control information that accompanies the application
message data when a message travels between sending and receiving applications.
Field Summary |
Fields inherited from class com.ibm.mq.MQMD |
accountingToken, applicationIdData, applicationOriginData, backoutCount, characterSet, correlationId, encoding, expiry, feedback, format, groupId, messageFlags, messageId, messageSequenceNumber, messageType, offset, originalLength, persistence, priority, putApplicationName, putApplicationType, putDateTime, replyToQueueManagerName, replyToQueueName, report, userId |
Constructor Summary | |
MQMessage()
The default constructor. |
Method Summary | |
void |
clearMessage()
Discards any data in the message buffer and sets the cursor position to zero. |
int |
getDataLength()
Gets the number of bytes of message data remaining to be read. |
int |
getDataOffset()
Returns the current cursor position within the message data (the point at which read and write operations take effect). |
int |
getMessageLength()
Gets the number of bytes of message data in this message. |
int |
getTotalMessageLength()
Gets the total number of bytes in the message as stored on the message queue on which this message was held. |
boolean |
readBoolean()
Reads a boolean from the current position in the message buffer. |
byte |
readByte()
Reads a byte from the current position in the message buffer. |
char |
readChar()
Reads a character from the current position in the message buffer. |
short |
readDecimal2()
Reads a 2-byte packed decimal number in the range -999 to 999. |
int |
readDecimal4()
Reads a 4-byte packed decimal number in the range -9,999,999 to 9,999,999. |
long |
readDecimal8()
Reads an 8-byte packed decimal number in the range -999,999,999,999,999 to 999,999,999,999,999. |
double |
readDouble()
Reads a double from the current position in the message buffer. |
float |
readFloat()
Reads a double from the current position in the message buffer. |
void |
readFully(byte[] b)
Fills a byte array with data from the message buffer. |
void |
readFully(byte[] b,
int off,
int len)
Partly fills a byte array with data from the message buffer. |
int |
readInt()
Reads an integer from the current position in the message buffer. |
short |
readInt2()
Identical to readShort() . |
int |
readInt4()
Synonym for readInt() , provided for cross-language WMQ API compatibility. |
long |
readInt8()
Identical to readLong() . |
java.lang.String |
readLine()
Reads a line of text from the message. |
long |
readLong()
Reads an integer from the current position in the message buffer. |
void |
readMQMDE()
Reads an embedded extended MQMD object. |
java.lang.Object |
readObject()
Reads an object carried in the message. |
short |
readShort()
Reads a short from the current position in the message buffer. |
java.lang.String |
readString(int length)
Deprecated. use readStringOfCharLength(int) method instead. |
java.lang.String |
readStringOfByteLength(int numberOfBytes)
Reads a specified number of bytes and uses them to construct a new string using the character set specified by characterSet . |
java.lang.String |
readStringOfCharLength(int numberOfChars)
Reads a string in the codeset identified by characterSet and converts it into Unicode. |
int |
readUInt2()
Identical to readUnsignedShort() , provided for cross-language WMQ API compatibility. |
int |
readUnsignedByte()
Reads an unsigned byte from the current position in the message buffer. |
int |
readUnsignedShort()
Reads an unsigned short from the current position in the message buffer. |
java.lang.String |
readUTF()
Reads a UTF format String from the current position in the message buffer. |
void |
resizeBuffer(int size)
Indicates to the MQMessage class the size of buffer that might be required. |
void |
seek(int offset)
Moves the cursor to a new absolute position in the message buffer. |
void |
setDataOffset(int offset)
Moves the cursor to a new absolute position in the message buffer. |
int |
skipBytes(int n)
Moves the cursor forward in the message buffer. |
void |
write(byte[] b)
Writes an array of bytes into the message buffer at the current position. |
void |
write(byte[] b,
int off,
int len)
Writes a series of bytes into the message buffer at the current position. |
void |
write(int b)
Writes a byte into the message buffer at the current position. |
void |
writeBoolean(boolean v)
Writes a boolean into the message buffer at the current position. |
void |
writeByte(int v)
Writes a byte into the message buffer at the current position. |
void |
writeBytes(java.lang.String s)
Writes a String as a sequence of bytes into the message buffer at the current position. |
void |
writeChar(int v)
Writes a Unicode character into the message buffer at the current position. |
void |
writeChars(java.lang.String s)
Writes a String as a sequence of Unicode characters into the message buffer at the current position. |
void |
writeDecimal2(short v)
Writes a 2-byte packed decimal format number into the message buffer at the current position. |
void |
writeDecimal4(int v)
Writes a 4-byte packed decimal format number into the message buffer at the current position. |
void |
writeDecimal8(long v)
Writes an 8-byte packed decimal format number into the message buffer at the current position. |
void |
writeDouble(double v)
Writes a double into the message buffer at the current position. |
void |
writeFloat(float v)
Writes a float into the message buffer at the current position. |
void |
writeInt(int v)
Writes an int into the message buffer at the current position. |
void |
writeInt2(int v)
Identical to writeShort() , provided for cross-language WMQ API
compatibility. |
void |
writeInt4(int v)
Synonym for writeInt() , provided for cross-language WMQ API compatibility. |
void |
writeInt8(long v)
Synonym for writeLong() , provided for cross-language WMQ API
compatibility. |
void |
writeLong(long v)
Writes a long into the message buffer at the current position. |
void |
writeMQMDE()
Writes an extended MQMD object into the message at the current position. |
void |
writeObject(java.lang.Object obj)
Writes an Object into the message. |
void |
writeShort(int v)
Writes a short into the message buffer at the current position. |
void |
writeString(java.lang.String s)
Writes a String into the message buffer at the current position, converting it to the codeset identified by characterSet . |
void |
writeUTF(java.lang.String str)
Writes a String in UTF format into the message buffer at the current position. |
Methods inherited from class com.ibm.mq.MQMD |
getVersion, setVersion |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MQMessage()
Method Detail |
public int getTotalMessageLength()
MQQueue.get()
method fails with an error code
that indicates that the message has been truncated.
public int getMessageLength() throws java.io.IOException
java.io.IOException
- if there is a problem with IO.public int getDataLength() throws java.io.IOException
java.io.IOException
- if there is a problem with IO.public void seek(int offset) throws java.io.EOFException
offset
- the new value of the cursor position.
java.io.EOFException
- if offset takes cursor outside the message data.public void setDataOffset(int offset) throws java.io.EOFException
seek()
, and is provided for cross-language
compatibility with the other WMQ APIs.
offset
- the new value of the cursor position.
java.io.EOFException
- if offset takes cursor outside the message data.public int getDataOffset() throws java.io.IOException
java.io.IOException
- if there is a problem with IO.public void clearMessage() throws java.io.IOException
java.io.IOException
- if there is a problem with IO.public void resizeBuffer(int size) throws java.io.IOException
MQQueue.get(MQMessage, MQGetMessageOptions)
, then this is
the size of buffer allocated for the get request.
size
- the new size of the buffer
java.io.IOException
- if there is a problem with IO.public boolean readBoolean() throws java.io.IOException, java.io.EOFException
readBoolean
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the read goes beyond the end of file.public byte readByte() throws java.io.IOException, java.io.EOFException
readByte
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the read goes beyond the end of file.public char readChar() throws java.io.IOException, java.io.EOFException
readChar
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the read goes beyond the end of file.public double readDouble() throws java.io.IOException, java.io.EOFException
readDouble
in interface java.io.DataInput
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian double if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if encoding
is not equal to either of these values.
java.io.EOFException
- if the read goes beyond the end of file.public float readFloat() throws java.io.IOException, java.io.EOFException
readFloat
in interface java.io.DataInput
encoding
equals
MQC.MQENC_INTEGER_NORMAL, a little-endian float if it equals
MQC.MQENC_INTEGER_REVERSED, or a
java.io.IOException
- if encoding
is none of these.
java.io.EOFException
- if the read goes beyond the end of file.public void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
b
- the byte array.
java.io.IOException
- if there is a problem with IO.public void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in interface java.io.DataInput
b
- the byte array.off
- the offset into the message buffer where the reading starts.len
- the number of bytes to be read.
java.io.IOException
- if there is a problem with IO.public java.lang.String readStringOfByteLength(int numberOfBytes) throws java.io.IOException, java.io.EOFException
characterSet
. When the given bytes
are not valid in the given charset, the behavior of this method is
dependant on the implementation of the JRE.
Where the byte length of a string is known, the entire String should be read in a single invocation of this method, thus avoiding problems where byte and char boundaries do not coincide.
numberOfBytes
- The number of bytes to read.
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
public java.lang.String readStringOfCharLength(int numberOfChars) throws java.io.IOException, java.io.EOFException
characterSet
and converts it into Unicode.
numberOfChars
- The number of characters to read (which might differ from the
number of bytes according to the codeset, because some codesets use more than
one byte per character).
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
public int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian integer if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if there is a problem with IO.public int readInt4() throws java.io.IOException
readInt()
, provided for cross-language WMQ API compatibility.
java.io.IOException
- if there is a problem with IO.public java.lang.String readLine() throws java.io.IOException
characterSet
, and then
reads in a line that has been terminated by \n, \r, \r\n, EOF or the end of a UTF
string.
readLine
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.public long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian long if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if encoding is not equal to either of these values.public long readInt8() throws java.io.IOException
readLong()
. Provided for cross-language WMQ API compatibility.
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian long if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if encoding is not equal to either of these values.public short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian short if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if encoding is not equal to either of these values.public short readInt2() throws java.io.IOException
readShort()
. Provided for cross-language MQ
API compatibility.
encoding
is
equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian short if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if there is a problem with IO.public java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.public int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.IOException
- if there is a problem with IO.public int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
encoding
is equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian short if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if encoding is not equal to either of these values.public int readUInt2() throws java.io.IOException
readUnsignedShort()
, provided for cross-language WMQ API compatibility.
encoding
is equal to MQC.MQENC_INTEGER_NORMAL, or a little-endian short if it
is equal to MQC.MQENC_INTEGER_REVERSED.
java.io.IOException
- if there is a problem with IO.public java.lang.String readString(int length) throws java.io.IOException
readStringOfCharLength(int)
method instead.
characterSet
and converts it into Unicode.
length
- The number of characters to read (which might differ from the
number of bytes according to the codeset, since some codesets use more than
one byte per character).
java.io.IOException
public short readDecimal2() throws java.io.IOException
encoding
equals MQC.MQENC_DECIMAL_NORMAL
or a little-endian short if it equals MQC.MQENC_DECIMAL_REVERSED.
java.io.IOException
- if there is a problem with IO.public int readDecimal4() throws java.io.IOException
encoding
equals MQC.MQENC_DECIMAL_NORMAL
or a little-endian int if it equals MQC.MQENC_DECIMAL_REVERSED.
java.io.IOException
- if there is a problem with IO.public long readDecimal8() throws java.io.IOException
encoding
equals MQC.MQENC_DECIMAL_NORMAL
or a little-endian long if it equals MQC.MQENC_DECIMAL_REVERSED.
java.io.IOException
- if there is a problem with IO.public void readMQMDE() throws MQException, java.io.IOException
encoding
,
characterSet
, format
, groupId
,
messageSequenceNumber
, offset
,
messageFlags
and originalLength
fields.
You should only call this method if format
is
MQC.MQFMT_MD_EXTENSION.
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the read goes beyond the end of file.
MQException
public java.lang.Object readObject() throws java.lang.ClassNotFoundException, java.io.InvalidClassException, java.io.StreamCorruptedException, java.io.OptionalDataException, java.io.IOException
java.lang.ClassNotFoundException
java.io.InvalidClassException
java.io.StreamCorruptedException
java.io.OptionalDataException
java.io.IOException
public int skipBytes(int n) throws java.io.IOException, java.io.EOFException
skipBytes
in interface java.io.DataInput
n
- the number of bytes to move.
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the skip goes beyond the end of file.public void write(int b) throws java.io.IOException
write
in interface java.io.DataOutput
b
- the byte to be written
java.io.IOException
- if there is a problem with IO.public void write(byte[] b) throws java.io.IOException
write
in interface java.io.DataOutput
b
- the array to be written.
java.io.IOException
- if there is a problem with IO.public void write(byte[] b, int off, int len) throws java.io.IOException
write
in interface java.io.DataOutput
b
- the array from which the bytes are written.off
- the offset to the first byte in the array to be written.len
- the number of bytes to be written.
java.io.IOException
- if there is a problem with IO.public void writeBoolean(boolean v) throws java.io.IOException
writeBoolean
in interface java.io.DataOutput
v
- the boolean to be written.
java.io.IOException
- if there is a problem with IO.public void writeByte(int v) throws java.io.IOException
writeByte
in interface java.io.DataOutput
v
- the byte to be written.
java.io.IOException
- if there is a problem with IO.public void writeBytes(java.lang.String s) throws java.io.IOException
writeBytes
in interface java.io.DataOutput
s
- the String to be written.
java.io.IOException
- if there is a problem with IO.public void writeChar(int v) throws java.io.IOException
writeChar
in interface java.io.DataOutput
v
- the character to be written, expressed as an int.
java.io.IOException
- if there is a problem with IO.public void writeChars(java.lang.String s) throws java.io.IOException
writeChars
in interface java.io.DataOutput
s
- the String to be written.
java.io.IOException
- if there is a problem with IO.public void writeDouble(double v) throws java.io.IOException
encoding
.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and MQENC_IEEE_FLOAT_REVERSED write IEEE standard floats in big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 writes a
writeDouble
in interface java.io.DataOutput
v
- the double to be written.
java.io.IOException
- if there is a problem with IO.public void writeFloat(float v) throws java.io.IOException
encoding
.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and MQENC_IEEE_FLOAT_REVERSED write IEEE standard floats in big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 writes a
writeFloat
in interface java.io.DataOutput
v
- the float to be written.
java.io.IOException
- if there is a problem with IO.public void writeInt(int v) throws java.io.IOException
encoding
.
Values of MQC.MQENC_INTEGER_NORMAL and MQC.MQENC_INTEGER_REVERSED write integers in big-endian and little-endian formats respectively.
writeInt
in interface java.io.DataOutput
v
- the int to be written.
java.io.IOException
- if there is a problem with IO.public void writeInt4(int v) throws java.io.IOException
writeInt()
, provided for cross-language WMQ API compatibility.
v
- the int to be written
java.io.IOException
- if there is a problem with IO.public void writeLong(long v) throws java.io.IOException
encoding
.
Values of MQC.MQENC_INTEGER_NORMAL and MQC.MQENC_INTEGER_REVERSED write longs in big-endian and little-endian formats respectively.
writeLong
in interface java.io.DataOutput
v
- the long to be written.
java.io.IOException
- if there is a problem with IO.public void writeInt8(long v) throws java.io.IOException
writeLong()
, provided for cross-language WMQ API
compatibility.
v
- the long to be written
java.io.IOException
- if there is a problem with IO.public void writeShort(int v) throws java.io.IOException
encoding
.
Values of MQC.MQENC_INTEGER_NORMAL and MQC.MQENC_INTEGER_REVERSED write shorts in big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 writes a
writeShort
in interface java.io.DataOutput
v
- the long to be written.
java.io.IOException
- if there is a problem with IO.public void writeInt2(int v) throws java.io.IOException
writeShort()
, provided for cross-language WMQ API
compatibility.
v
- the long to be written.
java.io.IOException
- if there is a problem with IO.public void writeDecimal2(short v) throws java.io.IOException
encoding
.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian packed decimal and
a value of MQC.MQENC_DECIMAL_REVERSED writes a little-endian packed decimal.
v
- is the number to be written in the range -999 to 999.
java.io.IOException
- if there is a problem with IO.public void writeDecimal4(int v) throws java.io.IOException
encoding
.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian packed decimal and
a value of MQC.MQENC_DECIMAL_REVERSED writes a little-endian packed decimal.
v
- is the number to be written in the range -9,999,999 to 9,999,999.
java.io.IOException
- if there is a problem with IO.public void writeDecimal8(long v) throws java.io.IOException
encoding
.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian packed decimal and
a value of MQC.MQENC_DECIMAL_REVERSED writes a little-endian packed decimal.
v
- is the number to be written int the range -999,999,999,999,999 to 999,999,999,999,999.
java.io.IOException
- if there is a problem with IO.public void writeUTF(java.lang.String str) throws java.io.IOException
writeUTF
in interface java.io.DataOutput
str
- the String to be written.
java.io.IOException
- if there is a problem with IO.public void writeString(java.lang.String s) throws java.io.IOException
characterSet
.
s
- the String to be written.
java.io.IOException
- if there is a problem with IO.public void writeMQMDE() throws java.io.IOException, MQException
encoding
, characterSet
,
format
, groupId
,
messageSequenceNumber
, offset
,
messageFlags
and originalLength
fields.
The current value of the format field is written into the MDE,
and the format field is then set to MQFMT_MD_EXTENSION.
java.io.IOException
- if there is a problem with IO.
java.io.EOFException
- if the read goes beyond the end of file.
MQException
public void writeObject(java.lang.Object obj) throws java.io.IOException
obj
- the Object to be written.
java.io.IOException
- if there is a problem with IO.
|
(c) Copyright IBM Corp. 2005. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |