io.protostuff.Output.writeByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(128)

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

Output.writeByteArray介绍

[英]Writes a byte array field.
[中]写入字节数组字段。

代码示例

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

@Override
public void writeByteArray(int fieldNumber, byte[] value, boolean repeated) throws IOException
{
  output.writeByteArray(fieldNumber, value, repeated);
}

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

/**
 * Writes the bytes to the {@link Output}.
 */
public static void writeTo(Output output, ByteString bs, int fieldNumber,
    boolean repeated) throws IOException
{
  output.writeByteArray(fieldNumber, bs.bytes, repeated);
}

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

@Override
public void writeTo(Output output, int number, byte[] value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value, repeated);
}

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

@Override
public void writeTo(Output output, int number, byte[] value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value, repeated);
}

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

@Override
public void writeTo(Output output, int number, byte[] value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value, repeated);
}

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

@Override
public void writeTo(Output output, int number, BigInteger value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value.toByteArray(), repeated);
}

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

@Override
public void writeTo(Output output, int number, BigInteger value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value.toByteArray(), repeated);
}

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

@Override
public void writeTo(Output output, int number, BigInteger value,
    boolean repeated) throws IOException
{
  output.writeByteArray(number, value.toByteArray(), repeated);
}

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

@Override
public void writeTo(Output output, int number, short[] value,
    boolean repeated) throws IOException
{
  writes++;
  byte[] buffer = new byte[value.length * 2];
  for (int i = 0, offset = 0; i < value.length; i++)
  {
    short s = value[i];
    buffer[offset++] = (byte) ((s >>> 8) & 0xFF);
    buffer[offset++] = (byte) ((s >>> 0) & 0xFF);
  }
  output.writeByteArray(number, buffer, repeated);
}

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

static void writeHasBar(Output output, int fieldNumber, HasBar hasBar, boolean repeated)
    throws IOException
{
  ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
  ObjectOutputStream oos = new ObjectOutputStream(baos);
  try
  {
    oos.writeObject(hasBar);
    output.writeByteArray(fieldNumber, baos.toByteArray(), repeated);
  }
  finally
  {
    oos.close();
  }
}

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

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
    boolean repeated) throws IOException
{
  if (utf8String)
    output.writeString(fieldNumber, readString(), repeated);
  else
    output.writeByteArray(fieldNumber, readByteArray(), repeated);
}

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

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated)
    throws IOException
{
  if (utf8String)
  {
    output.writeString(fieldNumber, readString(), repeated);
  }
  else
  {
    output.writeByteArray(fieldNumber, readByteArray(), repeated);
  }
}

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

@Override
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
    boolean repeated) throws IOException
{
  if (utf8String)
    output.writeString(fieldNumber, readString(), repeated);
  else
    output.writeByteArray(fieldNumber, readByteArray(), repeated);
}

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    BigInteger[] array = (BigInteger[]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      BigInteger v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeByteArray(ID_ARRAY_DATA, v.toByteArray(), true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    BigInteger[] array = (BigInteger[]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      BigInteger v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeByteArray(ID_ARRAY_DATA, v.toByteArray(), true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    byte[][] array = (byte[][]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      byte[] v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeByteArray(ID_ARRAY_DATA, v, true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
  public void writeTo(Output output, Object value) throws IOException
  {
    byte[][] array = (byte[][]) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);
    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
      byte[] v = array[i];
      if (v != null)
      {
        if (nullCount != 0)
        {
          output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
          nullCount = 0;
        }
        output.writeByteArray(ID_ARRAY_DATA, v, true);
      }
      else if (allowNullArrayElement)
      {
        nullCount++;
      }
    }
    // if last element is null
    if (nullCount != 0)
      output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
  }
}

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

@Override
public void writeTo(Output output, PojoWithBiggerByteArray message) throws IOException
{
  output.writeInt32(1, message.id, false);
  output.writeByteArray(2, message.b, false);
  output.writeInt64(3, message.ts, false);
}

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

@Override
public void writeTo(Output output, int number, Object value, boolean repeated) throws IOException {
 output.writeByteArray(number, JsonUtils.writeValueAsBytes(value), false);
}

代码示例来源:origin: dremio/dremio-oss

public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.GeneralRPCProtos.CompleteRpcMessage message) throws java.io.IOException
{
  if(message.hasHeader())
    output.writeObject(1, message.getHeader(), com.dremio.exec.proto.SchemaGeneralRPCProtos.RpcHeader.WRITE, false);
  if(message.hasProtobufBody())
    output.writeByteArray(2, message.getProtobufBody().toByteArray(), false);
  if(message.hasRawBody())
    output.writeByteArray(3, message.getRawBody().toByteArray(), false);
}
public boolean isInitialized(com.dremio.exec.proto.GeneralRPCProtos.CompleteRpcMessage message)

相关文章