bytesmessageimpl.java
来自「OpenJMS是一个开源的Java Message Service API 1.」· Java 代码 · 共 968 行 · 第 1/3 页
JAVA
968 行
try { result = _in.readUnsignedShort(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a Unicode character value from the bytes message stream. * * @return the next two bytes from the bytes message stream as a Unicode * character * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageNotReadableException if message is in write-only mode */ public final char readChar() throws JMSException { char result = 0; prepare(); try { result = _in.readChar(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a signed 32-bit integer from the bytes message stream. * * @return the next four bytes from the bytes message stream, interpreted * as an <code>int</code> * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageNotReadableException if message is in write-only mode */ public final int readInt() throws JMSException { int result = 0; prepare(); try { result = _in.readInt(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a signed 64-bit integer from the bytes message stream. * * @return the next eight bytes from the bytes message stream, interpreted * as a <code>long</code>. * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageNotReadableException if message is in write-only mode */ public final long readLong() throws JMSException { long result = 0; prepare(); try { result = _in.readLong(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a <code>float</code> from the bytes message stream. * * @return the next four bytes from the bytes message stream, interpreted * as a <code>float</code> * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageNotReadableException if message is in write-only mode */ public final float readFloat() throws JMSException { float result = 0; prepare(); try { result = _in.readFloat(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a <code>double</code> from the bytes message stream. * * @return the next eight bytes from the bytes message stream, * interpreted as a <code>double</code> * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageNotReadableException if message is in write-only mode */ public final double readDouble() throws JMSException { double result = 0; prepare(); try { result = _in.readDouble(); } catch (IOException exception) { revert(exception); } return result; } /** * Read in a string that has been encoded using a modified UTF-8 format * from the bytes message stream. * * <p>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. * * @return a Unicode string from the bytes message stream * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageEOFException if end of message stream * @throws MessageFormatException if string has an invalid format * @throws MessageNotReadableException if message is in write-only mode */ public final String readUTF() throws JMSException { String result = null; prepare(); try { result = _in.readUTF(); } catch (IOException exception) { revert(exception); } return result; } /** * Read a byte array from the bytes message stream. * * <p>If the length of array <code>value</code> is less than * the bytes remaining to be read from the stream, the array should * be filled. A subsequent call reads the next increment, etc. * * <p>If the bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. * The return value of the total number of bytes read will be less than * the length of the array, indicating that there are no more bytes left * to be read from the stream. The next read of the stream returns -1. * * @param value the buffer into which the data is read * @return 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 JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageNotReadableException if message is in write-only mode */ public final int readBytes(byte[] value) throws JMSException { return readBytes(value, value.length); } /** * Read a portion of the bytes message stream. * * <p>If the length of array <code>value</code> is less than * the bytes remaining to be read from the stream, the array should * be filled. A subsequent call reads the next increment, etc. * * <p>If the bytes remaining in the stream is less than the length of * array <code>value</code>, the bytes should be read into the array. * The return value of the total number of bytes read will be less than * the length of the array, indicating that there are no more bytes left * to be read from the stream. The next read of the stream returns -1. * * <p> If <code>length</code> is negative, or * <code>length</code> is greater than the length of the array * <code>value</code>, then an <code>IndexOutOfBoundsException</code> is * thrown. No bytes will be read from the stream for this exception case. * * @param value the buffer into which the data is read. * @param length the number of bytes to read. Must be less than or equal * to value.length. * @return 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 IndexOutOfBoundsException if <code>length</code> is invalid * @throws JMSException if JMS fails to read message due to some internal * JMS error * @throws MessageNotReadableException if message is in write-only mode */ public final int readBytes(byte[] value, int length) throws JMSException { int read = -1; prepare(); if (length < 0 || length > value.length) { throw new IndexOutOfBoundsException( "Length must be > 0 and less than array size"); } try { _in.mark(length); int remain = _in.available(); if (remain == 0) { read = -1; } else if (length <= remain) { read = length; _in.read(value, 0, length); } else { _in.readFully(value, 0, remain); read = remain; } } catch (EOFException ignore) { } catch (IOException exception) { revert(exception); } return read; } /** * Write a <code>boolean</code> to the bytes message stream as a 1-byte * value. * The value <code>true</code> is written out as the value * <code>(byte)1</code>; the value <code>false</code> is written out as * the value <code>(byte)0</code>. * * @param value the <code>boolean</code> value to be written * @throws JMSException if JMS fails to write message due to some internal * JMS error * @throws MessageNotWriteableException if message is in read-only mode */ public final void writeBoolean(boolean value) throws JMSException { checkWrite(); try { getOutputStream().writeBoolean(value); } catch (IOException exception) { raise(exception); } } /** * Write out a <code>byte</code> to the bytes message stream as a 1-byte * value. * * @param value the <code>byte</code> value to be written * @throws JMSException if JMS fails to write message due to some internal * JMS error * @throws MessageNotWriteableException if message is in read-only mode */ public final void writeByte(byte value) throws JMSException { checkWrite(); try { getOutputStream().writeByte(value); } catch (IOException exception) { raise(exception); } } /** * Write a <code>short</code> to the bytes message stream as two bytes, * high byte first. * * @param value the <code>short</code> to be written * @throws JMSException if JMS fails to write message due to some internal * JMS error * @throws MessageNotWriteableException if message is in read-only mode */ public final void writeShort(short value) throws JMSException { checkWrite(); try { getOutputStream().writeShort(value); } catch (IOException exception) { raise(exception); } } /** * Write a <code>char</code> to the bytes message stream as a 2-byte * value, high byte first. * * @param value the <code>char</code> value to be written * @throws MessageNotWriteableException if message is in read-only mode * @throws JMSException if JMS fails to write message due to some internal * JMS error */ public final void writeChar(char value) throws JMSException { checkWrite(); try { getOutputStream().writeChar(value); } catch (IOException exception) { raise(exception); } } /** * Write an <code>int</code> to the bytes message stream as four bytes, * high byte first. * * @param value the <code>int</code> to be written * @throws JMSException if JMS fails to write message due to some internal * JMS error * @throws MessageNotWriteableException if message is in read-only mode */ public final void writeInt(int value) throws JMSException { checkWrite(); try { getOutputStream().writeInt(value); } catch (IOException exception) { raise(exception); } } /** * Write a <code>long</code> to the bytes message stream as eight bytes, * high byte first * * @param value the <code>long</code> to be written * @throws JMSException if JMS fails to write message due to some internal * JMS error * @throws MessageNotWriteableException if message is in read-only mode */ public final void writeLong(long value) throws JMSException { checkWrite();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?