use of org.fusesource.hawtbuf.Buffer in project fabric8 by jboss-fuse.
the class BaseDataStreamMarshaller method tightUnmarshalBuffer.
protected Buffer tightUnmarshalBuffer(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException {
Buffer rc = null;
if (bs.readBoolean()) {
int size = dataIn.readInt();
byte[] t = new byte[size];
dataIn.readFully(t);
return new Buffer(t, 0, size);
}
return rc;
}
use of org.fusesource.hawtbuf.Buffer in project fabric8 by jboss-fuse.
the class ActiveMQStreamMessage method initializeReading.
private void initializeReading() throws OpenwireException {
checkWriteOnlyBody();
if (this.dataIn == null) {
Buffer data = getContent();
if (data == null) {
data = new Buffer(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
is = new InflaterInputStream(is);
is = new BufferedInputStream(is);
}
this.dataIn = new DataInputStream(is);
}
}
use of org.fusesource.hawtbuf.Buffer 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;
}
use of org.fusesource.hawtbuf.Buffer in project activemq-artemis by apache.
the class AmqpSupport method toBuffer.
/**
* Conversion from Java ByteBuffer to a HawtBuf buffer.
*
* @param data the ByteBuffer instance to convert.
* @return a new HawtBuf buffer converted from the given ByteBuffer.
*/
public static Buffer toBuffer(ByteBuffer data) {
if (data == null) {
return null;
}
Buffer rc;
if (data.isDirect()) {
rc = new Buffer(data.remaining());
data.get(rc.data);
} else {
rc = new Buffer(data);
data.position(data.position() + data.remaining());
}
return rc;
}
use of org.fusesource.hawtbuf.Buffer in project activemq-artemis by apache.
the class AmqpSupport method toBytes.
/**
* Given a long value, convert it to a byte array for marshalling.
*
* @param value the value to convert.
* @return a new byte array that holds the big endian value of the long.
*/
public static byte[] toBytes(long value) {
Buffer buffer = new Buffer(8);
buffer.bigEndianEditor().writeLong(value);
return buffer.data;
}
Aggregations