org.littleshoot.mina.common.ByteBuffer.put()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.littleshoot.mina.common.ByteBuffer.put()方法的一些代码示例,展示了ByteBuffer.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.put()方法的具体详情如下:
包路径:org.littleshoot.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:put

ByteBuffer.put介绍

[英]Writes the content of the specified src into this buffer.
[中]将指定src的内容写入此缓冲区。

代码示例

代码示例来源:origin: org.littleshoot/mina-port

/**
 * @see java.nio.ByteBuffer#put(byte[])
 */
public ByteBuffer put(byte[] src) {
  return put(src, 0, src.length);
}

代码示例来源:origin: org.littleshoot/mina-util

/**
 * 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));
  }

代码示例来源:origin: org.littleshoot/mina-port

@Override
  public void write(int b) {
    ByteBuffer.this.put((byte) b);
  }
};

代码示例来源:origin: org.littleshoot/mina-util

/**
 * 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));
  }

代码示例来源:origin: org.littleshoot/mina-util

/**
 * Appends a <code>CR LF</code> to the specified buffer
 * 
 * @param buffer
 *            The buffer
 */
public static void appendCRLF(ByteBuffer buffer)
  {
  buffer.put(CRLF_BYTES);
  }

代码示例来源:origin: org.littleshoot/mina-port

public ByteBuffer put(int index, byte b) {
  buf.put(index, b);
  return this;
}

代码示例来源:origin: org.littleshoot/mina-port

public ByteBuffer put(ByteBuffer src) {
  buf.put(src);
  return this;
}

代码示例来源:origin: org.littleshoot/mina-port

public ByteBuffer put(java.nio.ByteBuffer src) {
  buf.put(src);
  return this;
}

代码示例来源:origin: org.littleshoot/mina-port

/**
 * Writes the content of the specified <tt>src</tt> into this buffer.
 */
public ByteBuffer put(ByteBuffer src) {
  return put(src.buf());
}

代码示例来源:origin: org.littleshoot/sip-stack

/**
 * 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);
  }
}

代码示例来源:origin: org.littleshoot/stun-stack

public void visitIceControlling(final IceControllingAttribute attribute)
  {
  writeHeader(attribute);
  final byte[] tieBreaker = attribute.getTieBreaker();
  LOG.debug("Encoding controlling: {}", tieBreaker);
  m_buf.put(tieBreaker);
  }

代码示例来源:origin: org.littleshoot/stun-stack

public void visitIceControlled(final IceControlledAttribute attribute)
  {
  writeHeader(attribute);
  final byte[] tieBreaker = attribute.getTieBreaker();
  LOG.debug("Encoding controlled: {}", tieBreaker);
  m_buf.put(tieBreaker);
  }

代码示例来源:origin: org.littleshoot/stun-stack

public void visitData(final DataAttribute data)
  {
  writeHeader(data);
  final byte[] dataBytes = data.getData();
  m_buf.put(dataBytes);
  }

代码示例来源:origin: org.littleshoot/mina-port

@Override
public void write(int b) throws IOException {
  ByteBuffer buf = ByteBuffer.allocate(1);
  buf.put((byte) b);
  buf.flip();
  write(buf);
}

代码示例来源:origin: org.littleshoot/mina-util

@Override
public void write(final int b) throws IOException
  {
  final ByteBuffer buf = ByteBuffer.allocate(1);
  buf.put((byte) b);
  buf.flip();
  write(buf);
  }
}

代码示例来源:origin: org.littleshoot/mina-util

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;
  }

代码示例来源:origin: org.littleshoot/mina-util

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;
  }

代码示例来源:origin: org.littleshoot/mina-port

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);
  }
}

代码示例来源:origin: org.littleshoot/mina-port

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);
  }
}

代码示例来源:origin: org.littleshoot/stun-stack

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));
  }

相关文章