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

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

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

ByteBuffer.limit介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) {
    return;

代码示例来源:origin: apache/incubator-dubbo

@Override
public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) {
    return;

代码示例来源:origin: org.apache.directory.mina/mina-core

public ByteBuffer limit( int newLimit )
{
  buf.limit( newLimit );
  return this;
}

代码示例来源:origin: org.apache.directory.mina/mina-core

public int limit()
{
  return buf.limit();
}

代码示例来源:origin: org.apache.directory.mina/mina-core

/**
 * @see java.nio.Buffer#remaining()
 */
public int remaining()
{
  return limit() - position();
}

代码示例来源:origin: org.apache.directory.mina/mina-core

public int hashCode()
{
  int h = 1;
  int p = position();
  for( int i = limit() - 1; i >= p; i -- )
  {
    h = 31 * h + get( i );
  }
  return h;
}

代码示例来源:origin: org.apache.directory.mina/mina-core

public IoSessionInputStream()
{
  buf = ByteBuffer.allocate( 16 );
  buf.setAutoExpand( true );
  buf.limit( 0 );
}

代码示例来源:origin: org.apache.directory.mina/mina-core

public String toString()
{
  StringBuffer buf = new StringBuffer();
  if( isDirect() )
  {
    buf.append( "DirectBuffer" );
  }
  else
  {
    buf.append( "HeapBuffer" );
  }
  buf.append( "[pos=" );
  buf.append( position() );
  buf.append( " lim=" );
  buf.append( limit() );
  buf.append( " cap=" );
  buf.append( capacity() );
  buf.append( ": " );
  buf.append( getHexDump() );
  buf.append( ']' );
  return buf.toString();
}

代码示例来源:origin: org.apache.directory.mina/mina-core

public boolean equals( Object o )
{
  if( !( o instanceof ByteBuffer ) )
  {
    return false;
  }
  ByteBuffer that = (ByteBuffer)o;
  if( this.remaining() != that.remaining() )
  {
    return false;
  }
  int p = this.position();
  for( int i = this.limit() - 1, j = that.limit() - 1; i >= p; i --, j -- )
  {
    byte v1 = this.get( i );
    byte v2 = that.get( j );
    if( v1 != v2 )
    {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.apache.directory.mina/mina-core

int oldLimit = limit();
limit( position() + length );
try
  limit( oldLimit );

代码示例来源:origin: org.apache.directory.server/mitosis

int oldLimit = in.limit();
  in.limit( in.position() + bodyLength );
  in.limit( oldLimit );

代码示例来源:origin: org.apache.directory.mina/mina-core

int oldLimit = in.limit();
while( in.hasRemaining() )
    in.limit( pos - matchCount + oldMatchCount );
    in.position( oldPos );
    buf.clear();
    in.limit( oldLimit );
    in.position( pos );
    oldPos = pos;
in.limit( in.limit() - matchCount + oldMatchCount );
buf.put( in );

代码示例来源:origin: org.apache.directory.mina/mina-core

int oldLimit = in.limit();
while( in.hasRemaining() )
    if( matchCount == delimBuf.limit() )
      in.limit( pos - matchCount + oldMatchCount );
      in.position( oldPos );
      buf.clear();
      in.limit( oldLimit );
      in.position( pos );
      oldPos = pos;
in.limit( in.limit() - matchCount + oldMatchCount );
buf.put( in );

代码示例来源:origin: org.apache.directory.mina/mina-core

private void readSession( DatagramSessionImpl session )
{
  ByteBuffer readBuf = ByteBuffer.allocate( session.getReadBufferSize() );
  try
  {
    int readBytes = session.getChannel().read( readBuf.buf() );
    if( readBytes > 0 )
    {
      readBuf.flip();
      ByteBuffer newBuf = ByteBuffer.allocate( readBuf.limit() );
      newBuf.put( readBuf );
      newBuf.flip();
      session.increaseReadBytes( readBytes );
      ( ( DatagramFilterChain ) session.getFilterChain() ).messageReceived( session, newBuf );
    }
  }
  catch( IOException e )
  {
    ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
  }
  finally
  {
    readBuf.release();
  }
}

代码示例来源:origin: org.apache.directory.mina/mina-core

private void readSession( DatagramSessionImpl session )
{
  ByteBuffer readBuf = ByteBuffer.allocate( session.getReadBufferSize() );
  try
  {
    SocketAddress remoteAddress = session.getChannel().receive(
        readBuf.buf() );
    if( remoteAddress != null )
    {
      readBuf.flip();
      session.setRemoteAddress( remoteAddress );
      ByteBuffer newBuf = ByteBuffer.allocate( readBuf.limit() );
      newBuf.put( readBuf );
      newBuf.flip();
      session.increaseReadBytes( newBuf.remaining() );
      ( ( DatagramFilterChain ) session.getFilterChain() ).messageReceived( session, newBuf );
    }
  }
  catch( IOException e )
  {
    ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
  }
  finally
  {
    readBuf.release();
  }
}

代码示例来源:origin: net.jahhan/dubbo-remoting-mina

public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) return;

代码示例来源:origin: com.alibaba/dubbo-remoting-mina

@Override
public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) return;

代码示例来源:origin: com.alibaba/dubbo

@Override
public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) return;

代码示例来源:origin: remoting/dubbox

public void decode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
  int readable = in.limit();
  if (readable <= 0) return;

代码示例来源:origin: org.reddwarfserver.client/sgs-client

msgBuf.slice().asReadOnlyBuffer().limit(msgLen);

相关文章