Search in sources :

Example 6 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQStreamMessage method readChar.

public char readChar() throws OpenwireException {
    initializeReading();
    try {
        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new OpenwireException("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 OpenwireException(" not a char type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        }
        throw mfe;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 7 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQStreamMessage method readLong.

public long readLong() throws OpenwireException {
    initializeReading();
    try {
        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new OpenwireException("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 OpenwireException(" not a long type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        }
        throw mfe;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 8 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQStreamMessage method readShort.

public short readShort() throws OpenwireException {
    initializeReading();
    try {
        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new OpenwireException("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 OpenwireException(" not a short type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        }
        throw mfe;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 9 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQStreamMessage method readDouble.

public double readDouble() throws OpenwireException {
    initializeReading();
    try {
        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new OpenwireException("reached end of data");
        }
        if (type == MarshallingSupport.DOUBLE_TYPE) {
            return this.dataIn.readDouble();
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return this.dataIn.readFloat();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Double.valueOf(this.dataIn.readUTF()).doubleValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to double.");
        } else {
            this.dataIn.reset();
            throw new OpenwireException(" not a double type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        }
        throw mfe;
    } catch (EOFException e) {
        throw new OpenwireException(e);
    } catch (IOException e) {
        throw new OpenwireException(e);
    }
}
Also used : OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)

Example 10 with OpenwireException

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException in project fabric8 by jboss-fuse.

the class ActiveMQTextMessage method getText.

public String getText() throws OpenwireException {
    if (text == null && getContent() != null) {
        InputStream is = null;
        try {
            Buffer bodyAsBytes = getContent();
            if (bodyAsBytes != null) {
                is = new ByteArrayInputStream(bodyAsBytes);
                if (isCompressed()) {
                    is = new InflaterInputStream(is);
                }
                DataInputStream dataIn = new DataInputStream(is);
                text = MarshallingSupport.readUTF8(dataIn);
                dataIn.close();
                setContent(null);
                setCompressed(false);
            }
        } catch (IOException ioe) {
            throw new OpenwireException(ioe);
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                // ignore
                }
            }
        }
    }
    return text;
}
Also used : Buffer(org.fusesource.hawtbuf.Buffer) OpenwireException(io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException) ByteArrayInputStream(org.fusesource.hawtbuf.ByteArrayInputStream) ByteArrayInputStream(org.fusesource.hawtbuf.ByteArrayInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) InflaterInputStream(java.util.zip.InflaterInputStream)

Aggregations

OpenwireException (io.fabric8.gateway.handlers.detecting.protocol.openwire.support.OpenwireException)18 OpenwireException (io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireException)3 InflaterInputStream (java.util.zip.InflaterInputStream)3 Buffer (org.fusesource.hawtbuf.Buffer)3 ByteArrayInputStream (org.fusesource.hawtbuf.ByteArrayInputStream)3 IOException (java.io.IOException)2 UTF8Buffer (org.fusesource.hawtbuf.UTF8Buffer)2 Constructor (java.lang.reflect.Constructor)1 URL (java.net.URL)1 Deflater (java.util.zip.Deflater)1 DeflaterOutputStream (java.util.zip.DeflaterOutputStream)1 ByteArrayOutputStream (org.fusesource.hawtbuf.ByteArrayOutputStream)1