当前位置: 首页>>代码示例>>Java>>正文


Java Buffer.getLength方法代码示例

本文整理汇总了Java中org.fusesource.hawtbuf.Buffer.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.getLength方法的具体用法?Java Buffer.getLength怎么用?Java Buffer.getLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fusesource.hawtbuf.Buffer的用法示例。


在下文中一共展示了Buffer.getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unmarshal

import org.fusesource.hawtbuf.Buffer; //导入方法依赖的package包/类
public synchronized Object unmarshal(Buffer sequence) throws IOException {
    bytesIn.restart(sequence);
    // DataByteArrayInputStreamStream dis = new DataByteArrayInputStreamStream(new
    // ByteArrayInputStream(sequence));

    if (!sizePrefixDisabled) {
        int size = bytesIn.readInt();
        if (sequence.getLength() - 4 != size) {
            // throw new IOException("Packet size does not match marshaled
            // size");
        }

        if (size > maxFrameSize) {
            throw new IOException(
                    "Frame size of " + (size / (1024 * 1024)) +
                    " MB larger than max allowed " +
                            (maxFrameSize / (1024 * 1024)) + " MB");
        }
    }

    Object command = doUnmarshal(bytesIn);
    // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) {
    // ((MarshallAware) command).setCachedMarshalledForm(this, sequence);
    // }
    return command;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:27,代码来源:OpenWireFormat.java

示例2: tightMarshalNestedObject1

import org.fusesource.hawtbuf.Buffer; //导入方法依赖的package包/类
public int tightMarshalNestedObject1(DataStructure o, BooleanStream bs) throws IOException {
    bs.writeBoolean(o != null);
    if (o == null) {
        return 0;
    }

    if (o.isMarshallAware()) {
        // MarshallAware ma = (MarshallAware)o;
        Buffer sequence = null;
        // sequence=ma.getCachedMarshalledForm(this);
        bs.writeBoolean(sequence != null);
        if (sequence != null) {
            return 1 + sequence.getLength();
        }
    }

    byte type = o.getDataStructureType();
    DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
    if (dsm == null) {
        throw new IOException("Unknown data type: " + type);
    }
    return 1 + dsm.tightMarshal1(this, o, bs);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:OpenWireFormat.java

示例3: tightMarshalBuffer1

import org.fusesource.hawtbuf.Buffer; //导入方法依赖的package包/类
protected int tightMarshalBuffer1(Buffer data, BooleanStream bs) throws IOException {
    bs.writeBoolean(data != null);
    if (data != null) {
        return data.getLength() + 4;
    } else {
        return 0;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:BaseDataStreamMarshaller.java

示例4: marshal

import org.fusesource.hawtbuf.Buffer; //导入方法依赖的package包/类
public synchronized Buffer marshal(Object command) throws IOException {

        if (cacheEnabled) {
            runMarshallCacheEvictionSweep();
        }

        //        MarshallAware ma = null;
        //        // If not using value caching, then the marshaled form is always the
        //        // same
        //        if (!cacheEnabled && ((DataStructure)command).isMarshallAware()) {
        //            ma = (MarshallAware)command;
        //        }

        Buffer sequence = null;
        // if( ma!=null ) {
        // sequence = ma.getCachedMarshalledForm(this);
        // }

        if (sequence == null) {

            int size = 1;
            if (command != null) {

                DataStructure c = (DataStructure) command;
                byte type = c.getDataStructureType();
                DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
                if (dsm == null) {
                    throw new IOException("Unknown data type: " + type);
                }
                if (tightEncodingEnabled) {

                    BooleanStream bs = new BooleanStream();
                    size += dsm.tightMarshal1(this, c, bs);
                    size += bs.marshalledSize();

                    bytesOut.restart(size);
                    if (!sizePrefixDisabled) {
                        bytesOut.writeInt(size);
                    }
                    bytesOut.writeByte(type);
                    bs.marshal(bytesOut);
                    dsm.tightMarshal2(this, c, bytesOut, bs);
                    sequence = bytesOut.toBuffer();

                } else {
                    bytesOut.restart();
                    if (!sizePrefixDisabled) {
                        bytesOut.writeInt(0); // we don't know the final size
                        // yet but write this here for
                        // now.
                    }
                    bytesOut.writeByte(type);
                    dsm.looseMarshal(this, c, bytesOut);
                    sequence = bytesOut.toBuffer();

                    if (!sizePrefixDisabled) {
                        size = sequence.getLength() - 4;
                        int pos = sequence.offset;
                        sequence.offset = 0;
                        BufferEditor.big(sequence).writeInt(size);
                        sequence.offset = pos;
                    }
                }

            } else {
                bytesOut.restart(5);
                bytesOut.writeInt(size);
                bytesOut.writeByte(NULL_TYPE);
                sequence = bytesOut.toBuffer();
            }

            // if( ma!=null ) {
            // ma.setCachedMarshalledForm(this, sequence);
            // }
        }
        return sequence;
    }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:78,代码来源:OpenWireFormat.java


注:本文中的org.fusesource.hawtbuf.Buffer.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。