io.protostuff.ByteString.wrap()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(111)

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

ByteString.wrap介绍

暂无

代码示例

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(parser.parsePayload());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: protostuff/protostuff

/**
 * Read a {@code bytes} field value from the stream.
 */
@Override
public ByteString readBytes() throws IOException
{
  final int size = readRawVarint32();
  if (size == 0)
  {
    return ByteString.EMPTY;
  }
  if (size <= (bufferSize - bufferPos) && size > 0)
  {
    // Fast path: We already have the bytes in a contiguous buffer, so
    // just copy directly from it.
    final ByteString result = ByteString.copyFrom(buffer, bufferPos, size);
    bufferPos += size;
    return result;
  }
  else
  {
    // Slow path: Build a byte array first then copy it.
    // return ByteString.copyFrom(readRawBytes(size));
    return ByteString.wrap(readRawBytes(size));
  }
}

代码示例来源:origin: protostuff/protostuff

public void testCompareVsOther() throws Exception
{
  Baz aBaz = new Baz(1, "hello world", 1238372479L);
  ByteBuffer serForm1 = testObj(aBaz, aBaz);
  deserTest(aBaz, aBaz, serForm1);
  Bar testBar = new Bar(22,
      "some String",
      aBaz,
      Bar.Status.COMPLETED,
      ByteString.wrap("fuck yo test".getBytes()),
      false,
      3.14f,
      2.7182818284,
      599L
      );
  ByteBuffer serForm2 = testObj(testBar, testBar);
  deserTest(testBar, testBar, serForm2);
}

代码示例来源:origin: protostuff/protostuff

public void testCompareVsOther() throws Exception
{
  Baz aBaz = new Baz(1, "hello world", 1238372479L);
  ByteBuffer serForm1 = testObj(aBaz, aBaz);
  deserTest(aBaz, aBaz, serForm1);
  Bar testBar = new Bar(22,
      "some String",
      aBaz,
      Bar.Status.COMPLETED,
      ByteString.wrap("fuck yo test".getBytes()),
      false,
      3.14f,
      2.7182818284,
      599L
      );
  ByteBuffer serForm2 = testObj(testBar, testBar);
  deserTest(testBar, testBar, serForm2);
}

代码示例来源:origin: protostuff/protostuff

public void testBarTooLarge2() throws Exception
{
  Schema<Bar> schema = Bar.getSchema();
  Bar message = new Bar();
  message.setSomeBytes(ByteString.wrap(
      new byte[StringSerializer.THREE_BYTE_LOWER_LIMIT - 1]));
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  int size = optWriteDelimitedTo(out, message, schema, buf());
  int delimSize = ProtobufOutput.computeRawVarint32Size(size);
  byte[] data = out.toByteArray();
  int expectedSize = size + delimSize;
  assertEquals(expectedSize, data.length);
  verifyOptData(data, message, schema, buf());
  ByteArrayInputStream in = new ByteArrayInputStream(data);
  Bar parsedMessage = schema.newMessage();
  boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf(256));
  assertFalse(merged);
}

代码示例来源:origin: protostuff/protostuff

public void testBarTooLarge3() throws Exception
  {
    Schema<Bar> schema = Bar.getSchema();
    Bar message = new Bar();
    message.setSomeBytes(ByteString.wrap(
        new byte[StringSerializer.FOUR_BYTE_LOWER_LIMIT - 1]));

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int size = optWriteDelimitedTo(out, message, schema, buf());
    int delimSize = ProtobufOutput.computeRawVarint32Size(size);
    byte[] data = out.toByteArray();

    int expectedSize = size + delimSize;
    assertEquals(expectedSize, data.length);
    verifyOptData(data, message, schema, buf());

    ByteArrayInputStream in = new ByteArrayInputStream(data);

    Bar parsedMessage = schema.newMessage();
    boolean merged = optMergeDelimitedFrom(in, parsedMessage, schema, buf(256));
    assertFalse(merged);
  }
}

代码示例来源:origin: apache/servicecomb-java-chassis

@Override
public ByteString readBytes() throws IOException {
 return ByteString.wrap(readByteArray());
}

代码示例来源:origin: io.protostuff/protostuff-json

@Override
public ByteString readBytes() throws IOException
{
  return ByteString.wrap(readByteArray());
}

代码示例来源:origin: hank-whu/turbo-rpc

@Override
public ByteString readBytes() throws IOException {
  return ByteString.wrap(readByteArray());
}

相关文章