Java 类org.apache.mina.filter.codec.CumulativeProtocolDecoder 实例源码

项目:Camel    文件:Mina2VMCustomCodecTest.java   
@Override
public ProtocolDecoder getDecoder(IoSession is) throws Exception {
    return new CumulativeProtocolDecoder() {

        protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
            if (in.remaining() > 0) {
                byte[] buf = new byte[in.remaining()];
                in.get(buf);
                out.write(new String(buf, "US-ASCII"));
                return true;
            } else {
                return false;
            }
        }
    };
}
项目:Camel    文件:MinaVMCustomCodecTest.java   
public ProtocolDecoder getDecoder() throws Exception {
    return new CumulativeProtocolDecoder() {
        protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
            if (in.remaining() > 0) {
                byte[] buf = new byte[in.remaining()];
                in.get(buf);
                out.write(new String(buf, "US-ASCII"));
                return true;
            } else {
                return false;
            }
        }
    };
}
项目:Camel    文件:MinaCustomCodecTest.java   
public ProtocolDecoder getDecoder() throws Exception {
    return new CumulativeProtocolDecoder() {
        protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
            if (in.remaining() > 0) {
                byte[] buf = new byte[in.remaining()];
                in.get(buf);
                out.write(new String(buf, "US-ASCII"));
                return true;
            } else {
                return false;
            }
        }
    };
}