io.protostuff.WriteSink类的使用及代码示例

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

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

WriteSink介绍

[英]The flexible output for outputs that use WriteSession.
[中]针对使用WriteSession的输出的灵活输出。

代码示例

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

static LinkedBuffer writeTag(final String name, final boolean repeated,
    final WriteSink sink, final WriteSession session, LinkedBuffer lb)
    throws IOException
{
  lb = sink.writeStrAscii(name,
      session,
      sink.writeByte(
          EXCLAMATION,
          session,
          lb));
  if (repeated)
    return sink.writeByteArray(EMPTY_ARRAY, session, lb);
  return lb;
}

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

tail = sink.writeByte(
      QUOTE,
      this,
      sink.writeByteArrayB64(
          value, 0, value.length,
          this,
          sink.writeByteArray(
              COMMA_AND_QUOTE,
              this,
tail = sink.writeByte(
    QUOTE,
    this,
    sink.writeByteArrayB64(
        value, 0, value.length,
        this,

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

@Override
public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException
{
  final String name = schema.getFieldName(fieldNumber);
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeStrFromInt(value, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

private void writeB64(String name, byte[] value, int offset, int length,
    boolean repeated) throws IOException
{
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeByteArrayB64(value, offset, length, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

private LinkedBuffer writeByteAndInt(byte b, int v, WriteSession session, LinkedBuffer lb)
    throws IOException
{
  return sink.writeInt32(v, session,
      sink.writeByte(b, session, lb));
}

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

private LinkedBuffer writeByteAndLong(byte b, long v, WriteSession session, LinkedBuffer lb)
    throws IOException
{
  return sink.writeInt64(v, session,
      sink.writeByte(b, session, lb));
}

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

@Override
public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException
{
  final WriteSink sink = this.sink;
  if (lastNumber == fieldNumber)
  {
    // repeated field
    tail = sink.writeByteArray(
        value ? TRUE : FALSE,
        this,
        sink.writeByte(
            COMMA,
            this,
            tail));
    return;
  }
  tail = sink.writeByteArray(
      value ? TRUE : FALSE,
      this,
      writeKey(
          fieldNumber,
          sink,
          repeated ? KEY_SUFFIX_ARRAY : KEY_SUFFIX));
  lastNumber = fieldNumber;
  lastRepeated = repeated;
}

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

@Override
public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException
{
  final String name = schema.getFieldName(fieldNumber);
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeStrFromLong(value, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

@Override
public void writeString(int fieldNumber, CharSequence value, boolean repeated) throws IOException
{
  final String name = schema.getFieldName(fieldNumber);
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeStrUTF8(value, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

@Override
public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException
{
  final String name = schema.getFieldName(fieldNumber);
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeStrFromDouble(value, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

@Override
public void writeFloat(int fieldNumber, float value, boolean repeated) throws IOException
{
  final String name = schema.getFieldName(fieldNumber);
  tail = sink.writeByte(END_TAG, this,
      sink.writeStrAscii(name, this,
          sink.writeByteArray(START_SLASH_TAG, this,
              sink.writeStrFromFloat(value, this,
                  sink.writeByte(END_TAG, this,
                      sink.writeStrAscii(name, this,
                          sink.writeByte(START_TAG, this, tail)))))));
}

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

JsonXOutput writeCommaAndStartObject() throws IOException
{
  tail = sink.writeByteArray(COMMA_AND_START_OBJECT, this, tail);
  return this;
}

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

JsonXOutput writeEndObject() throws IOException
{
  tail = sink.writeByte(END_OBJECT, this, tail);
  return this;
}

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

numBuf[1] = (byte) ((len >>> 8) & 0xFF);
  lb = sink.writeStrFromInt(
      number,
      this,
      sink.writeByteArray(
          numBuf, 0, 2,
          this,
  numBuf[1] = (byte) ((valueLen >>> 8) & 0xFF);
  return sink.writeByteArray(numBuf, 0, 2, this, lb);
numBuf[1] = (byte) ((valueLen >>> 8) & 0xFF);
return sink.writeByteArray(
    numBuf, 0, 2,
    this,
    sink.writeStrUTF8FixedDelimited(
        schema.getFieldName(number),
        true,

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

tail = sink.writeByteArrayB64(
      value,
      this,
      sink.writeByteArray(
          DASH_AND_SPACE,
          this,
tail = sink.writeByteArrayB64(
    value,
    this,

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

@Override
public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException
{
  final WriteSink sink = this.sink;
  if (lastNumber == fieldNumber)
  {
    // repeated field
    tail = sink.writeStrFromLong(
        value,
        this,
        sink.writeByte(
            COMMA,
            this,
            tail));
    return;
  }
  tail = sink.writeStrFromLong(
      value,
      this,
      writeKey(
          fieldNumber,
          sink,
          repeated ? KEY_SUFFIX_ARRAY : KEY_SUFFIX));
  lastNumber = fieldNumber;
  lastRepeated = repeated;
}

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

@Override
public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException
{
  final WriteSink sink = this.sink;
  if (lastNumber == fieldNumber)
  {
    // repeated field
    tail = sink.writeStrFromInt(
        value,
        this,
        sink.writeByte(
            COMMA,
            this,
            tail));
    return;
  }
  tail = sink.writeStrFromInt(
      value,
      this,
      writeKey(
          fieldNumber,
          sink,
          repeated ? KEY_SUFFIX_ARRAY : KEY_SUFFIX));
  lastNumber = fieldNumber;
  lastRepeated = repeated;
}

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

private static LinkedBuffer writeKey(final String name, final int indent,
    final boolean repeated, final WriteSink sink,
    final WriteSession session, LinkedBuffer lb) throws IOException
{
  lb = sink.writeByteArray(
      COLON_AND_SPACE,
      session,
      sink.writeStrAscii(
          name,
          session,
          newLine(
              indent,
              sink,
              session,
              lb)));
  if (repeated)
  {
    return sink.writeByteArray(
        DASH_AND_SPACE,
        session,
        newLine(
            inc(indent, 2),
            sink,
            session,
            lb));
  }
  return lb;
}

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

@Override
public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException
{
  final WriteSink sink = this.sink;
  if (lastNumber == fieldNumber)
  {
    // repeated field
    tail = sink.writeStrFromDouble(
        value,
        this,
        sink.writeByte(
            COMMA,
            this,
            tail));
    return;
  }
  tail = sink.writeStrFromDouble(
      value,
      this,
      writeKey(
          fieldNumber,
          sink,
          repeated ? KEY_SUFFIX_ARRAY : KEY_SUFFIX));
  lastNumber = fieldNumber;
  lastRepeated = repeated;
}

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

@Override
public void writeFloat(int fieldNumber, float value, boolean repeated) throws IOException
{
  final WriteSink sink = this.sink;
  if (lastNumber == fieldNumber)
  {
    // repeated field
    tail = sink.writeStrFromFloat(
        value,
        this,
        sink.writeByte(
            COMMA,
            this,
            tail));
    return;
  }
  tail = sink.writeStrFromFloat(
      value,
      this,
      writeKey(
          fieldNumber,
          sink,
          repeated ? KEY_SUFFIX_ARRAY : KEY_SUFFIX));
  lastNumber = fieldNumber;
  lastRepeated = repeated;
}

相关文章