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

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

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

ByteBuffer.hasRemaining介绍

暂无

代码示例

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

public boolean hasRemaining() {
  return buf.hasRemaining();
}

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

public Map<StunAttributeType, StunAttribute> createAttributes(
  final ByteBuffer body)
  {
  final Map<StunAttributeType, StunAttribute> attributes =
    new ConcurrentHashMap<StunAttributeType, StunAttribute>();
  while (body.hasRemaining())
    {
    addAttribute(attributes, body);
    }
  return attributes;
  }

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

@Override
public int read() {
  if (ByteBuffer.this.hasRemaining()) {
    return ByteBuffer.this.get() & 0xff;
  } else {
    return -1;
  }
}

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

public WriteFuture flush() {
  Queue<ByteBuffer> bufferQueue = this.bufferQueue;
  WriteFuture future = null;
  if (bufferQueue.isEmpty()) {
    return null;
  } else {
    for (;;) {
      ByteBuffer buf = bufferQueue.poll();
      if (buf == null) {
        break;
      }
      // Flush only when the buffer has remaining.
      if (buf.hasRemaining()) {
        future = doFlush(buf);
      }
    }
  }
  return future;
}

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

try
  while (in.hasRemaining())
      if (in.hasRemaining())

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

public void write(final ByteBuffer src)
  {
  m_log.debug("Writing data to input stream...");
  m_rawBytesReceived += src.remaining();
  m_log.debug("Received raw bytes: {}", m_rawBytesReceived);
  synchronized (m_mutex)
    {
    if (m_closed)
      {
      m_log.debug("InputStream closed...");
      return;
      }
    if (m_buf.hasRemaining())
      {
      m_log.debug("Copying buffer data...");
      this.m_buf.compact();
      this.m_buf.put(src);
      this.m_buf.flip();
      m_mutex.notifyAll();
      }
    else
      {
      m_log.debug("Nothing remaining in buffer...");
      this.m_buf.clear();
      this.m_buf.put(src);
      this.m_buf.flip();
      m_mutex.notifyAll();
      }
    }
  }

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

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.littleshoot/mina-util

public void decode(final IoSession session, final ByteBuffer in, 
  final ProtocolDecoderOutput out) throws Exception
  {
  while (in.hasRemaining())
    {
    if (this.m_currentDecoder == null || 
      this.m_currentDecoder.atMessageBoundary())
      {
      if (enoughData(in))
        {
        this.m_currentDecoder = selectDecoder(in);
        }
      else
        {
        // There's not enough data to determine which decoder 
        // to use, so wait until we get more.
        break;
        }
      }
    this.m_currentDecoder.decode(session, in, out);
    }
  }

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

for (;;) {
  CoderResult cr;
  if (hasRemaining()) {
    cr = decoder.decode(buf(), out, true);
  } else {

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

if (!hasRemaining()) {
  return "";
  while (hasRemaining()) {
    if (get() == 0) {
      break;
if (!hasRemaining()) {
  limit(oldLimit);
  position(end);
for (;;) {
  CoderResult cr;
  if (hasRemaining()) {
    cr = decoder.decode(buf(), out, true);
  } else {

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

if (!buf.hasRemaining()) {
    session.increaseWrittenMessages();
for (int i = WRITE_SPIN_COUNT; i > 0; i --) {
  localWrittenBytes = ch.write(buf.buf());
  if (localWrittenBytes != 0 || !buf.hasRemaining()) {
    break;

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

if (!hasRemaining()) {
  return "";
if (!hasRemaining()) {
  limit(oldLimit);
  position(end);
for (;;) {
  CoderResult cr;
  if (hasRemaining()) {
    cr = decoder.decode(buf(), out, true);
  } else {

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

if (!buf.hasRemaining()) {
  session.increaseWrittenMessages();
if (!buf.hasRemaining()) {
  session.increaseWrittenMessages();

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

if (!buf.hasRemaining()) {
      break;
if (buf.hasRemaining()) {
  if (usingSessionBuffer)
    buf.compact();

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

if (!buf.hasRemaining()) {
  session.increaseWrittenMessages();
if (!buf.hasRemaining()) {
  session.increaseWrittenMessages();

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

while (in.hasRemaining())

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

private void releaseWriteBuffers(SocketSessionImpl session) {
  Queue<WriteRequest> writeRequestQueue = session.getWriteRequestQueue();
  WriteRequest req;
  if ((req = writeRequestQueue.poll()) != null) {
    ByteBuffer buf = (ByteBuffer) req.getMessage();
    try {
      buf.release();
    } catch (IllegalStateException e) {
      session.getFilterChain().fireExceptionCaught(session, e);
    } finally {
      // The first unwritten empty buffer must be
      // forwarded to the filter chain.
      if (buf.hasRemaining()) {
        req.getFuture().setWritten(false);
      } else {
        session.getFilterChain().fireMessageSent(session, req);
      }
    }
    // Discard others.
    while ((req = writeRequestQueue.poll()) != null) {
      try {
        ((ByteBuffer) req.getMessage()).release();
      } catch (IllegalStateException e) {
        session.getFilterChain().fireExceptionCaught(session, e);
      } finally {
        req.getFuture().setWritten(false);
      }
    }
  }
}

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

while (in.hasRemaining()) {
  byte b = in.get();
  if (delimBuf.get(matchCount) == b) {

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

while (in.hasRemaining()) {
  byte b = in.get();
  boolean matched = false;

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

int oldLimit = in.limit();
int count = matchCount;
while (in.hasRemaining())

相关文章