com.thomsonreuters.upa.codec.Buffer.length()方法的使用及代码示例

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

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

Buffer.length介绍

[英]The backing ByteBuffer is initially set along with initial position and length. This method returns the initial length if there was no operation on the backing ByteBuffer that would change the position (such as get or put). If the backing ByteBuffer position has been changed by reading or writing to the buffer, this method returns the change in position, i.e. difference between current position and initial position.
[中]缓冲垫的背衬最初与初始位置和长度一起设置。如果在backing ByteBuffer上没有任何操作会改变位置(如get或put),则此方法返回初始长度。如果通过读取或写入缓冲区更改了backing ByteBuffer位置,则此方法返回位置更改,即当前位置和初始位置之间的差值。

代码示例

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public long calculateEncryptedSize(Buffer unencryptedInput)
{
  // content ((length + sizeof(u32) + sizeof(u32) + 4 (for footer) + 7)*8)/8
  // where +7 and the 8's are for getting to double word alignment
  return (((unencryptedInput.length() + 19) / 8) * 8);
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public String string()
{
  if (_rsslBuffer.length() == 0)
    return DataImpl.EMPTY_STRING;
  else
    return _rsslBuffer.toString();
}

代码示例来源:origin: Refinitiv/Elektron-SDK

/**
 * Address.
 *
 * @param setAddress the set address
 */
void address(Buffer setAddress)
{
  address.data(ByteBuffer.allocate(setAddress.length()));
  setAddress.copy(address);
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public int extractDomainType()
{
  if (MSG_TYPE_POS + MSG_TYPE_SIZE > _buffer.length())
    return CodecReturnCodes.INCOMPLETE_DATA;
  int position = _buffer.data().position();
  byte msgDomain = _buffer.data().get(_buffer.position() + MSG_TYPE_POS);
  _buffer.data().position(position);
  return msgDomain;
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public void sourceName(Buffer sourceName)
{
  _sourceName.data(sourceName.data(), sourceName.position(), sourceName.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public void encodedDataBody(Buffer data)
{
  _dataBuffer.data(data.data(), data.position(), data.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public String name()
{
  if (_rsslElementEntry.name().length() == 0)
    return DataImpl.EMPTY_STRING;
  else
    return _rsslElementEntry.name().toString();
}

代码示例来源:origin: Refinitiv/Elektron-SDK

static int encodeBuffer(EncodeIteratorImpl iter, Buffer data)
{
  assert (iter != null);
  assert (data != null);
  if (iter.isIteratorOverrun(data.length()))
    return CodecReturnCodes.BUFFER_TOO_SMALL;
  iter._writer.write((BufferImpl)data);
  iter._curBufPos = iter._writer.position();
  return CodecReturnCodes.SUCCESS;
}

代码示例来源:origin: Refinitiv/Elektron-SDK

/**
 * Sets encoded data for this service to the user specified
 * buffer. Data and position of encoded data of this service will be set
 * to passed in buffer's data and position. Note that this creates
 * garbage if buffer is backed by String object.
 *
 * @param data the data
 */
public void data(Buffer data)
{
  this.data.data(data.data(), data.position(), data.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public int encode(EncodeIterator iter, Buffer data)
{
  if ((data == null) || (data.length() == 0))
  {
    _encodedData.clear();
    return Encoders.encodeArrayEntry(iter, _encodedData);
  }
  return Encoders.encodeArrayEntry(iter, data);
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void authenticationExtendedResp(Buffer authenticationExtendedResp)
{
  assert (checkHasAuthenticationExtendedResp());
  authenticationExtendedResp.data(authenticationExtendedResp.data(),
                  authenticationExtendedResp.position(),
                  authenticationExtendedResp.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

/**
 * Sets hostName for the server. Note that this creates garbage if
 * buffer is backed by String object.
 * 
 * @param hostName to connect to.
 */
public void hostName(Buffer hostName)
{
  assert (hostName != null) : "hostName can not be null";
  hostName().data(hostName.data(), hostName.position(), hostName.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void userName(Buffer userName)
{
  assert(userName != null) : "userName can not be null";
  userName().data(userName.data(), userName.position(), userName.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void containerOverrunTest_decodeOpaque(Buffer encData, ByteBuffer sampleDataBuf, int dataSize)
{
  assertEquals(dataSize, encData.length());
  sampleDataBuf.limit(dataSize);
  
  ByteBuffer tmpByteBuf = encData.data().duplicate();
  
  tmpByteBuf.position(encData.position());
  tmpByteBuf.limit(encData.position() + encData.length());
  
  assertTrue(tmpByteBuf.equals(sampleDataBuf));
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public int setBufferAndRWFVersion(Buffer buffer, int rwfMajorVersion, int rwfMinorVersion)
{
  assert (buffer != null) : "buffer must be non-null";
  assert (buffer.data() != null) : "byte buffer must be non-null";
  int ret = setReader(rwfMajorVersion, rwfMinorVersion);
  if (ret != CodecReturnCodes.SUCCESS)
    return ret;
  return setBuffer(buffer.data(), ((BufferImpl)buffer).position(), buffer.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void authenticationExtended(Buffer authenticationExtended)
{
  assert (authenticationExtended != null) : "authenticationExtended can not be null";
  assert (checkHasAuthenticationExtended()) : "authenticationExtended flag should be set first";
  authenticationExtended().data(authenticationExtended.data(),
                 authenticationExtended.position(),
                 authenticationExtended.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void instanceId(Buffer instanceId)
{
  assert(checkHasInstanceId()) : "instanceId flag should be set first";
  assert (instanceId != null) : "instanceId can not be null";
  instanceId().data(instanceId.data(), instanceId.position(), instanceId.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

public void position(Buffer position)
  {
    assert(checkHasPosition()) : "position flag should be set first";
    assert (position != null) : "position can not be null";

    position().data(position.data(), position.position(), position.length());
  }
}

代码示例来源:origin: Refinitiv/Elektron-SDK

@Override
public int setBufferAndRWFVersion(Buffer buffer, int rwfMajorVersion, int rwfMinorVersion)
{
  assert (buffer != null) : "buffer must be non-null";
  assert (buffer.data() != null) : "byte buffer must be non-null";
  int ret = setWriter(rwfMajorVersion, rwfMinorVersion);
  if (ret != CodecReturnCodes.SUCCESS)
    return ret;
  _clientBuffer = buffer;
  return setBuffer(buffer.data(), ((BufferImpl)buffer).position(), buffer.length());
}

代码示例来源:origin: Refinitiv/Elektron-SDK

/** Allocates memory in destination buffer and performs buffer copy. */
private void createBufferCopy(Buffer srcBuffer, Buffer destBuffer)
{
  destBuffer.data(ByteBuffer.allocateDirect(srcBuffer.length()));
  assertEquals(CodecReturnCodes.SUCCESS, srcBuffer.copy(destBuffer.data()));
}

相关文章