Example usage for javax.jms MessageEOFException MessageEOFException

List of usage examples for javax.jms MessageEOFException MessageEOFException

Introduction

In this page you can find the example usage for javax.jms MessageEOFException MessageEOFException.

Prototype

public MessageEOFException(String reason) 

Source Link

Document

Constructs a MessageEOFException with the specified reason.

Usage

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads 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 the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 *///from   www.ja  v  a2s  .  c  om
public double readDouble() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readDouble();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a string that has been encoded using a modified UTF-8 format from the bytes message stream.
 * <P>/*from   w w w . j  a v a 2  s .  co  m*/
 * For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UTF)", 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 the JMS provider fails to read the message due to some internal error.
 * @throws MessageEOFException         if unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException if the message is in write-only mode.
 */
public String readUTF() throws JMSException {
    initializeReading();
    try {
        return this.dataIn.readUTF();
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoBytesMessage.java

/**
 * Reads a portion of the bytes message stream.
 * <P>//from w w  w  .  j a v a2  s.c o m
 * If the length of array <code>value</code> is less than the number of bytes remaining to be read from the
 * stream, the array should be filled. A subsequent call reads the next increment, and so on.
 * <P>
 * If the number of 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 <code>value.length</code>
 * @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 the JMS provider fails to read the message due to some internal error.
 * @throws MessageNotReadableException if the message is in write-only mode.
 */
public int readBytes(byte[] value, int length) throws JMSException {
    initializeReading();
    try {
        int n = 0;
        while (n < length) {
            int count = this.dataIn.read(value, n, length - n);
            if (count < 0) {
                break;
            }
            n += count;
        }
        if (n == 0 && length > 0) {
            n = -1;
        }
        return n;
    } catch (EOFException eof) {
        JMSException jmsEx = new MessageEOFException(eof.getMessage());
        jmsEx.setLinkedException(eof);
        throw jmsEx;
    } catch (IOException ioe) {
        JMSException jmsEx = new JMSException("Format error occured" + ioe.getMessage());
        jmsEx.setLinkedException(ioe);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <code>boolean</code> from the stream message.
 *
 * @return the <code>boolean</code> value read
 * @throws JMSException//  www .java2 s  .co  m
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws javax.jms.MessageNotReadableException
 *             if the message is in write-only mode.
 */
public boolean readBoolean() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(10);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.BOOLEAN_TYPE) {
            return this.dataIn.readBoolean();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Boolean.valueOf(this.dataIn.readUTF()).booleanValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to boolean.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a boolean type");
        }
    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <code>byte</code> value from the stream message.
 *
 * @return the next byte from the stream message as a 8-bit
 *         <code>byte</code>
 * @throws JMSException//from   w w  w .j a va  2 s  .  com
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws javax.jms.MessageNotReadableException
 *             if the message is in write-only mode.
 */

public byte readByte() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(10);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Byte.valueOf(this.dataIn.readUTF()).byteValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to byte.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a byte type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;
    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 16-bit integer from the stream message.
 *
 * @return a 16-bit integer from the stream message
 * @throws JMSException/*ww  w .j a v a2  s. c  o  m*/
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public short readShort() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Short.valueOf(this.dataIn.readUTF()).shortValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to short.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a short type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a Unicode character value from the stream message.
 *
 * @return a Unicode character from the stream message
 * @throws JMSException/*w  w  w  .  jav a 2  s  .  com*/
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public char readChar() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.CHAR_TYPE) {
            return this.dataIn.readChar();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to char.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a char type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 32-bit integer from the stream message.
 *
 * @return a 32-bit integer value from the stream message, interpreted as an
 *         <code>int</code>//from w  ww . j  av  a  2  s.  c  om
 * @throws JMSException
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public int readInt() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(33);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return this.dataIn.readInt();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Integer.valueOf(this.dataIn.readUTF()).intValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to int.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not an int type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 64-bit integer from the stream message.
 *
 * @return a 64-bit integer value from the stream message, interpreted as a
 *         <code>long</code>
 * @throws JMSException//  www . ja  v  a  2 s  .c o  m
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public long readLong() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.LONG_TYPE) {
            return this.dataIn.readLong();
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return this.dataIn.readInt();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Long.valueOf(this.dataIn.readUTF()).longValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to long.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a long type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <code>float</code> from the stream message.
 *
 * @return a <code>float</code> value from the stream message
 * @throws JMSException// ww w .ja v a  2 s.c  om
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public float readFloat() throws JMSException {
    initializeReading();
    try {
        this.dataIn.mark(33);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return this.dataIn.readFloat();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Float.valueOf(this.dataIn.readUTF()).floatValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to float.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a float type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}