Package org.fusesource.hawtbuf

Examples of org.fusesource.hawtbuf.Buffer


     * @throws OpenwireException
     */
    public Serializable getObject() throws OpenwireException {
        if (object == null && getContent() != null) {
            try {
                Buffer content = getContent();
                InputStream is = new ByteArrayInputStream(content);
                if (isCompressed()) {
                    is = new InflaterInputStream(is);
                }
                DataInputStream dataIn = new DataInputStream(is);
View Full Code Here


    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);
                    }
View Full Code Here

    }

    public void beforeMarshall(OpenWireFormat wireFormat) throws IOException {
        super.beforeMarshall(wireFormat);

        Buffer content = getContent();
        if (content == null && text != null) {
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            if (Settings.enable_compression()) {
                compressed = true;
View Full Code Here

    private void storeContent() {
        try {
            if (dataOut != null) {
                dataOut.close();
                Buffer bs = bytesOut.toBuffer();
                if (compressed) {
                    int pos = bs.offset;
                    bs.offset = 0;
                    BufferEditor e = BufferEditor.big(bs);
                    e.writeInt(length);
View Full Code Here

    }

    private void initializeReading() throws OpenwireException {
        checkWriteOnlyBody();
        if (dataIn == null) {
            Buffer data = getContent();
            if (data == null) {
                data = new Buffer(new byte[] {}, 0, 0);
            }
            InputStream is = new ByteArrayInputStream(data);
            if (isCompressed()) {
                // keep track of the real length of the content if
                // we are compressed.
                try {
                    DataInputStream dis = new DataInputStream(is);
                    length = dis.readInt();
                    dis.close();
                } catch (IOException e) {
                    throw new OpenwireException(e);
                }
                is = new InflaterInputStream(is);
            } else {
                length = data.getLength();
            }
            dataIn = new DataInputStream(is);
        }
    }
View Full Code Here

    /**
     * Convert a AMQP command
     */
    public void onAMQPData(Object command) throws Exception {
        Buffer frame;
        if( command.getClass() == AmqpHeader.class ) {
            AmqpHeader header = (AmqpHeader)command;
            switch( header.getProtocolId() ) {
                case 0:
                    // amqpTransport.sendToAmqp(new AmqpHeader());
View Full Code Here

                    // Lets try to complete the sasl handshake.
                    if( sasl.getRemoteMechanisms().length > 0 ) {
                        if( "PLAIN".equals(sasl.getRemoteMechanisms()[0]) ) {
                            byte[] data = new byte[sasl.pending()];
                            sasl.recv(data, 0, data.length);
                            Buffer[] parts = new Buffer(data).split((byte) 0);
                            if( parts.length > 0 ) {
                                connectionInfo.setUserName(parts[0].utf8().toString());
                            }
                            if( parts.length > 1 ) {
                                connectionInfo.setPassword(parts[1].utf8().toString());
View Full Code Here

    }
    HashMap<Long, Transaction> transactions = new HashMap<Long, Transaction>();

    public byte[] toBytes(long value) {
        Buffer buffer = new Buffer(8);
        buffer.bigEndianEditor().writeLong(value);
        return buffer.data;
    }
View Full Code Here

        buffer.bigEndianEditor().writeLong(value);
        return buffer.data;
    }

    private long toLong(Binary value) {
        Buffer buffer = new Buffer(value.getArray(), value.getArrayOffset(), value.getLength());
        return buffer.bigEndianEditor().readLong();
    }
View Full Code Here

            if( count == 0 ) {
                return;
            }

            receiver.advance();
            Buffer buffer = current.toBuffer();
            current = null;
            onMessage(receiver, delivery, buffer);
        }
View Full Code Here

TOP

Related Classes of org.fusesource.hawtbuf.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.