public ByteBuffer setAutoExpand(boolean autoExpand) { buf.setAutoExpand(autoExpand); return this; }
private Context() { decoder = charset.newDecoder(); buf = ByteBuffer.allocate(80).setAutoExpand(true); }
private Context() { decoder = charset.newDecoder(); buf = ByteBuffer.allocate(80).setAutoExpand(true); }
public IoSessionInputStream() { buf = ByteBuffer.allocate(16); buf.setAutoExpand(true); buf.limit(0); }
public IoSessionInputStream(final IoSession ioSession, final int readTimeout) { m_ioSession = ioSession; m_readTimeout = readTimeout; m_buf = ByteBuffer.allocate(16); m_buf.setAutoExpand(true); m_buf.limit(0); }
public ByteBuffer encode(final SipMessage message) { final ByteBuffer buffer = ByteBuffer.allocate(300); buffer.setAutoExpand(true); final SipMessageVisitor visitor = new EncoderVisitor(buffer); message.accept(visitor); buffer.flip(); return buffer; }
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { if (!(message instanceof Serializable)) { throw new NotSerializableException(); } ByteBuffer buf = ByteBuffer.allocate(64); buf.setAutoExpand(true); buf.putObject(message); int objectSize = buf.position() - 4; if (objectSize > maxObjectSize) { buf.release(); throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')'); } buf.flip(); out.write(buf); } }
public void writeObject(Object obj) throws IOException { ByteBuffer buf = ByteBuffer.allocate(64, false); buf.setAutoExpand(true); buf.putObject(obj); int objectSize = buf.position() - 4; if (objectSize > maxObjectSize) { buf.release(); throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')'); } out.write(buf.array(), 0, buf.position()); buf.release(); }
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER); if (encoder == null) { encoder = charset.newEncoder(); session.setAttribute(ENCODER, encoder); } String value = message.toString(); ByteBuffer buf = ByteBuffer.allocate(value.length()) .setAutoExpand(true); buf.putString(value, encoder); if (buf.position() > maxLineLength) { throw new IllegalArgumentException("Line length: " + buf.position()); } buf.putString(delimiter.getValue(), encoder); buf.flip(); out.write(buf); }
private void storeRemainingInSession(ByteBuffer buf, IoSession session) { ByteBuffer remainingBuf = ByteBuffer.allocate(buf.capacity()); remainingBuf.setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); } }
m_buffer.setAutoExpand(true);
ByteBuffer tmp = ByteBuffer.allocate(2).setAutoExpand(true); tmp.putString(delimiter.getValue(), charset.newEncoder()); tmp.flip();
m_buffer.setAutoExpand(true);