org.apache.qpid.proton.codec.WritableBuffer.remaining()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(156)

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

WritableBuffer.remaining介绍

暂无

代码示例

代码示例来源:origin: org.apache.qpid/proton

public int remaining()
{
  return _first.remaining()+_second.remaining();
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public int remaining()
{
  return _first.remaining()+_second.remaining();
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

public int remaining()
{
  return _first.remaining()+_second.remaining();
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public int remaining()
{
  return _first.remaining()+_second.remaining();
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public void put(ByteBuffer payload)
{
  int firstRemaining = _first.remaining();
  if(firstRemaining > 0)
  {
    if(firstRemaining >= payload.remaining())
    {
      _first.put(payload);
      return;
    }
    else
    {
      int limit = payload.limit();
      payload.limit(payload.position()+firstRemaining);
      _first.put(payload);
      payload.limit(limit);
    }
  }
  _second.put(payload);
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public void putShort(short s)
{
  int remaining = _first.remaining();
  if(remaining >= 2)
  {
    _first.putShort(s);
  }
  else if(remaining ==0 )
  {
    _second.putShort(s);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[2]);
    wrap.putShort(s);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public void putLong(long l)
{
  int remaining = _first.remaining();
  if(remaining >= 8)
  {
    _first.putLong(l);
  }
  else if(remaining ==0 )
  {
    _second.putLong(l);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[8]);
    wrap.putLong(l);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public void putInt(int i)
{
  int remaining = _first.remaining();
  if(remaining >= 4)
  {
    _first.putInt(i);
  }
  else if(remaining ==0 )
  {
    _second.putInt(i);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[4]);
    wrap.putInt(i);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

public void putShort(short s)
{
  int remaining = _first.remaining();
  if(remaining >= 2)
  {
    _first.putShort(s);
  }
  else if(remaining ==0 )
  {
    _second.putShort(s);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[2]);
    wrap.putShort(s);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public void putShort(short s)
{
  int remaining = _first.remaining();
  if(remaining >= 2)
  {
    _first.putShort(s);
  }
  else if(remaining ==0 )
  {
    _second.putShort(s);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[2]);
    wrap.putShort(s);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public void putLong(long l)
{
  int remaining = _first.remaining();
  if(remaining >= 8)
  {
    _first.putLong(l);
  }
  else if(remaining ==0 )
  {
    _second.putLong(l);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[8]);
    wrap.putLong(l);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public CompositeReadableBuffer get(WritableBuffer target) {
  int length = Math.min(target.remaining(), remaining());
  do {
    final int chunk = Math.min((currentArray.length - currentOffset), length);
    if (chunk == 0) {
      break;  // This buffer is out of data
    }
    target.put(currentArray, currentOffset, chunk);
    currentOffset += chunk;
    position += chunk;
    length -= chunk;
    maybeMoveToNextArray();
  } while (length > 0);
  return this;
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

public void putLong(long l)
{
  int remaining = _first.remaining();
  if(remaining >= 8)
  {
    _first.putLong(l);
  }
  else if(remaining ==0 )
  {
    _second.putLong(l);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[8]);
    wrap.putLong(l);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton

public void putLong(long l)
{
  int remaining = _first.remaining();
  if(remaining >= 8)
  {
    _first.putLong(l);
  }
  else if(remaining ==0 )
  {
    _second.putLong(l);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[8]);
    wrap.putLong(l);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

public void putInt(int i)
{
  int remaining = _first.remaining();
  if(remaining >= 4)
  {
    _first.putInt(i);
  }
  else if(remaining ==0 )
  {
    _second.putInt(i);
  }
  else
  {
    ByteBuffer wrap = ByteBuffer.wrap(new byte[4]);
    wrap.putInt(i);
    wrap.flip();
    put(wrap);
  }
}

代码示例来源:origin: org.apache.qpid/proton-j

int recv(final WritableBuffer buffer)
{
  final int consumed;
  if (_dataBuffer != null && _dataBuffer.hasRemaining())
  {
    consumed = Math.min(buffer.remaining(), _dataBuffer.remaining());
    buffer.put(_dataBuffer);
    _dataBuffer.reclaimRead();
  }
  else
  {
    consumed = 0;
  }
  return (_complete && consumed == 0) ? Transport.END_OF_STREAM : consumed;
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public void put(byte[] src, int offset, int length)
{
  final int firstRemaining = _first.remaining();
  if(firstRemaining > 0)
  {
    if(firstRemaining >= length)
    {
      _first.put(src, offset, length);
      return;
    }
    else
    {
      _first.put(src,offset, firstRemaining);
    }
  }
  _second.put(src, offset+firstRemaining, length-firstRemaining);
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

public void put(byte[] src, int offset, int length)
{
  final int firstRemaining = _first.remaining();
  if(firstRemaining > 0)
  {
    if(firstRemaining >= length)
    {
      _first.put(src, offset, length);
      return;
    }
    else
    {
      _first.put(src,offset, firstRemaining);
    }
  }
  _second.put(src, offset+firstRemaining, length-firstRemaining);
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

public void put(byte[] src, int offset, int length)
{
  final int firstRemaining = _first.remaining();
  if(firstRemaining > 0)
  {
    if(firstRemaining >= length)
    {
      _first.put(src, offset, length);
      return;
    }
    else
    {
      _first.put(src,offset, firstRemaining);
    }
  }
  _second.put(src, offset+firstRemaining, length-firstRemaining);
}

代码示例来源:origin: org.apache.qpid/proton

public void put(byte[] src, int offset, int length)
{
  final int firstRemaining = _first.remaining();
  if(firstRemaining > 0)
  {
    if(firstRemaining >= length)
    {
      _first.put(src, offset, length);
      return;
    }
    else
    {
      _first.put(src,offset, firstRemaining);
    }
  }
  _second.put(src, offset+firstRemaining, length-firstRemaining);
}

相关文章