/** * @see java.nio.ByteBuffer#put(byte[]) */ public ByteBuffer put(byte[] src) { return put(src, 0, src.length); }
/** * Puts an unsigned byte into the buffer. * * @param bb The buffer. * @param position The index in the buffer to insert the value. * @param value The value to insert. */ public static void putUnsignedByte(final ByteBuffer bb, final int position, final int value) { bb.put(position, (byte) (value & 0xff)); }
@Override public void write(int b) { ByteBuffer.this.put((byte) b); } };
/** * Puts an unsigned byte into the buffer. * * @param bb The buffer. * @param value The value to insert. */ public static void putUnsignedByte(final ByteBuffer bb, final int value) { bb.put((byte) (value & 0xff)); }
/** * Appends a <code>CR LF</code> to the specified buffer * * @param buffer * The buffer */ public static void appendCRLF(ByteBuffer buffer) { buffer.put(CRLF_BYTES); }
public ByteBuffer put(int index, byte b) { buf.put(index, b); return this; }
public ByteBuffer put(ByteBuffer src) { buf.put(src); return this; }
public ByteBuffer put(java.nio.ByteBuffer src) { buf.put(src); return this; }
/** * Writes the content of the specified <tt>src</tt> into this buffer. */ public ByteBuffer put(ByteBuffer src) { return put(src.buf()); }
/** * Writes the message body bytes, if any, to the specified buffer * * @param message The message. * @param buffer The buffer to write to */ private void encodeBody(final SipMessage message, final ByteBuffer buffer) { final ByteBuffer body = message.getBody(); buffer.put(body); } }
public void visitIceControlling(final IceControllingAttribute attribute) { writeHeader(attribute); final byte[] tieBreaker = attribute.getTieBreaker(); LOG.debug("Encoding controlling: {}", tieBreaker); m_buf.put(tieBreaker); }
public void visitIceControlled(final IceControlledAttribute attribute) { writeHeader(attribute); final byte[] tieBreaker = attribute.getTieBreaker(); LOG.debug("Encoding controlled: {}", tieBreaker); m_buf.put(tieBreaker); }
public void visitData(final DataAttribute data) { writeHeader(data); final byte[] dataBytes = data.getData(); m_buf.put(dataBytes); }
@Override public void write(int b) throws IOException { ByteBuffer buf = ByteBuffer.allocate(1); buf.put((byte) b); buf.flip(); write(buf); }
@Override public void write(final int b) throws IOException { final ByteBuffer buf = ByteBuffer.allocate(1); buf.put((byte) b); buf.flip(); write(buf); } }
private static ByteBuffer createBuffer(final ByteBuffer buffer) { final ByteBuffer data = ByteBuffer.allocate( buffer.limit() - buffer.position()); LOG.trace("Created buffer with capacity: "+data.capacity()); data.put(buffer); data.rewind(); return data; }
private static ByteBuffer createBuffer(final ByteBuffer buffer) { // We calculate this here because the final split buffer will not // necessarily have a size equal to the chunk size -- it will // usually be smaller. final ByteBuffer data = ByteBuffer.allocate( buffer.limit() - buffer.position()); data.put(buffer); data.flip(); return data; }
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); } }
public void append(ByteBuffer in) { if (overflowPosition != 0) { discard(in); } else if (buf.position() > maxLineLength - in.remaining()) { overflowPosition = buf.position(); buf.clear(); discard(in); } else { getBuffer().put(in); } }
private static UUID createTransactionId() { final UUID id = UUID.randomUUID(); final byte[] idBytes = id.getRawBytes(); final ByteBuffer idBuf = ByteBuffer.wrap(idBytes); // Lower the limit to make room for the magic cookie. idBuf.limit(idBytes.length - 4); final ByteBuffer newIdBuf = ByteBuffer.allocate(16); MinaUtils.putUnsignedInt(newIdBuf, MAGIC_COOKIE); newIdBuf.put(idBuf); newIdBuf.flip(); return new UUID(MinaUtils.toByteArray(newIdBuf)); }