use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.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);
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.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);
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.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);
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.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);
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.support.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;
}
Aggregations