本文整理了Java中org.apache.mina.common.ByteBuffer.put()
方法的一些代码示例,展示了ByteBuffer.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.put()
方法的具体详情如下:
包路径:org.apache.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:put
暂无
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( java.nio.ByteBuffer src )
{
buf.put( src );
return this;
}
代码示例来源:origin: org.apache.directory.server/mitosis
private void writeCSNVector( ByteBuffer out, CSNVector csns )
{
Set<String> replicaIds = csns.getReplicaIds();
int nReplicas = replicaIds.size();
out.putInt( nReplicas );
for ( String replicaId:replicaIds )
{
CSN csn = csns.getCSN( replicaId );
try
{
out.putString( replicaId, utf8encoder );
out.put( ( byte ) 0x00 );
out.putLong( csn.getTimestamp() );
out.putInt( csn.getOperationSequence() );
}
catch ( CharacterCodingException e )
{
throw new RuntimeException( e );
}
}
}
代码示例来源:origin: org.reddwarfserver.client/sgs-client
/**
* Prepends the length of the given byte array as a 2-byte {@code short}
* in network byte-order, and passes the result to the {@linkplain
* FilterListener#sendUnfiltered sendUnfiltered} method of the
* given {@code listener}.
*
* @param listener the {@code FilterListener} on which to send the data
* @param message the data to filter and forward to the listener
*/
void filterSend(FilterListener listener, byte[] message) {
ByteBuffer buffer = ByteBuffer.allocate(message.length + 2, false);
buffer.putShort((short) message.length);
buffer.put(message);
buffer.flip();
// Don't worry about the listener throwing an exception, since
// this method has no other side effects.
listener.sendUnfiltered(buffer);
}
}
代码示例来源:origin: org.apache.directory.server/mitosis
public final void encode( IoSession session, Object in, ProtocolEncoderOutput out ) throws Exception
{
BaseMessage m = ( BaseMessage ) in;
ByteBuffer buf = ByteBuffer.allocate( 16 );
buf.setAutoExpand( true );
buf.put( ( byte ) m.getType() );
buf.putInt( m.getSequence() );
buf.putInt( 0 ); // placeholder for body length field
final int bodyStartPos = buf.position();
encodeBody( m, buf );
final int bodyEndPos = buf.position();
final int bodyLength = bodyEndPos - bodyStartPos;
// fill bodyLength
buf.position( bodyStartPos - 4 );
buf.putInt( bodyLength );
buf.position( bodyEndPos );
buf.flip();
out.write( buf );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( byte[] src )
{
buf.put( src );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void write( byte[] b, int off, int len )
{
ByteBuffer.this.put( b, off, len );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( byte[] src, int offset, int length )
{
buf.put( src, offset, length );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
/**
* @see java.nio.ByteBuffer#put(byte[])
*/
public ByteBuffer put( byte[] src )
{
return put( src, 0, src.length );
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( ByteBuffer src )
{
buf.put( src );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( byte b )
{
buf.put( b );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public ByteBuffer put( int index, byte b )
{
buf.put( index, b );
return this;
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void write( int b )
{
ByteBuffer.this.put( (byte)b );
}
};
代码示例来源:origin: org.apache.directory.mina/mina-core
/**
* @see java.nio.ByteBuffer#put(byte[], int, int)
*/
public abstract ByteBuffer put( byte[] src, int offset, int length );
代码示例来源:origin: org.apache.directory.server/mitosis
protected void encodeBody( BaseMessage in, ByteBuffer out )
{
LogEntryMessage m = ( LogEntryMessage ) in;
out.put( operationCodec.encode( m.getOperation() ) );
}
代码示例来源:origin: org.apache.mina/mina-filter-ssl
/**
* Creates a new Mina byte buffer that is a deep copy of the remaining bytes
* in the given buffer (between index buf.position() and buf.limit())
*
* @param src the buffer to copy
* @return the new buffer, ready to read from
*/
public static org.apache.mina.common.ByteBuffer copy(java.nio.ByteBuffer src) {
org.apache.mina.common.ByteBuffer copy = org.apache.mina.common.ByteBuffer
.allocate(src.remaining());
copy.put(src);
copy.flip();
return copy;
}
代码示例来源:origin: alibaba/tair-java-client
public void encode(IoSession session, Object message,
ProtocolEncoderOutput out) throws Exception {
if(!(message instanceof byte[])){
throw new Exception("must send byte[]");
}
byte[] payload=(byte[]) message;
ByteBuffer buf = ByteBuffer.allocate(payload.length, false);
buf.put(payload);
buf.flip();
out.write(buf);
if (isDebugEnabled)
LOGGER.debug(TairUtil.toHex(payload));
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void write( int b ) throws IOException
{
ByteBuffer buf = ByteBuffer.allocate( 1 );
buf.put( ( byte ) b );
buf.flip();
write( buf );
}
}
代码示例来源:origin: org.apache.directory.mina/mina-core
public void write( ByteBuffer src )
{
synchronized( mutex )
{
if( closed )
{
return;
}
if( buf.hasRemaining() )
{
this.buf.compact();
this.buf.put( src );
this.buf.flip();
}
else
{
this.buf.clear();
this.buf.put( src );
this.buf.flip();
mutex.notifyAll();
}
}
}
代码示例来源:origin: org.apache.directory.mina/mina-core
private void storeRemainingInSession(ByteBuffer buf, IoSession session)
{
ByteBuffer remainingBuf = ByteBuffer.allocate( buf.remaining() );
remainingBuf.setAutoExpand( true );
remainingBuf.put( buf );
session.setAttribute( BUFFER, remainingBuf );
}
}
代码示例来源:origin: org.reddwarfserver.client/sgs-client
/**
* Processes network data of arbitrary length and dispatches zero or
* more complete messages to the given {@code listener}. If a partial
* message remains, it is buffered until more data is received.
*
* @param listener the {@code FilterListener} to receive complete messages
* @param buf the data to filter and optionally deliver to the
* {@code FilterListener}
*/
void filterReceive(FilterListener listener, ByteBuffer buf) {
logger.log(Level.FINEST,
"processing {0,number,#} bytes",
buf.remaining());
// Append the new data to the buffer
msgBuf.expand(buf.remaining());
msgBuf.put(buf);
msgBuf.flip();
processReceiveBuffer(listener);
}
内容来源于网络,如有侵权,请联系作者删除!