Package io.protostuff

Class KvpOutput

All Implemented Interfaces:
Output

public final class KvpOutput extends WriteSession implements Output
An output for serializing kvp-encoded messages (from a byte array as source). A kvp encoding is a binary encoding w/c contains a key-value sequence. On the wire, a serialized field (key-value) would look like: [key-len][key][value-len][value]

The keys and values are length-delimited (uint16 little endian).

Note that this encoding does not support nested messages. This encoding is mostly useful for headers w/c contain information about the content it carries (see http://projects.unbit.it/uwsgi/wiki/uwsgiProtocol).

  • Field Details

    • numBuf

      final byte[] numBuf
    • numeric

      final boolean numeric
    • schema

      private Schema<?> schema
  • Constructor Details

  • Method Details

    • use

      public KvpOutput use(Schema<?> schema, boolean clearBuffer)
    • writeField

      private LinkedBuffer writeField(int number, LinkedBuffer lb) throws IOException
      Throws:
      IOException
    • writeField

      private LinkedBuffer writeField(int number, int valueLen, LinkedBuffer lb) throws IOException
      Throws:
      IOException
    • writeBool

      public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a boolean field.
      Specified by:
      writeBool in interface Output
      Throws:
      IOException
    • writeByteArray

      public void writeByteArray(int fieldNumber, byte[] value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a byte array field.
      Specified by:
      writeByteArray in interface Output
      Throws:
      IOException
    • writeByteRange

      public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a binary or a pre-encoded utf8 string.
      Specified by:
      writeByteRange in interface Output
      Throws:
      IOException
    • writeBytes

      public void writeBytes(int fieldNumber, ByteString value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a ByteString(wraps byte array) field.
      Specified by:
      writeBytes in interface Output
      Throws:
      IOException
    • writeDouble

      public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a double field.
      Specified by:
      writeDouble in interface Output
      Throws:
      IOException
    • writeEnum

      public void writeEnum(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a enum(its number) field.
      Specified by:
      writeEnum in interface Output
      Throws:
      IOException
    • writeFixed32

      public void writeFixed32(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a fixed int(4 bytes) field.
      Specified by:
      writeFixed32 in interface Output
      Throws:
      IOException
    • writeFixed64

      public void writeFixed64(int fieldNumber, long value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a fixed long(8 bytes) field.
      Specified by:
      writeFixed64 in interface Output
      Throws:
      IOException
    • writeFloat

      public void writeFloat(int fieldNumber, float value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a float field.
      Specified by:
      writeFloat in interface Output
      Throws:
      IOException
    • writeInt32

      public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a variable int field.
      Specified by:
      writeInt32 in interface Output
      Throws:
      IOException
    • writeInt64

      public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a variable long field.
      Specified by:
      writeInt64 in interface Output
      Throws:
      IOException
    • writeObject

      public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes an object(using its schema) field.
      Specified by:
      writeObject in interface Output
      Throws:
      IOException
    • writeSFixed32

      public void writeSFixed32(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a signed+fixed int(4 bytes) field.
      Specified by:
      writeSFixed32 in interface Output
      Throws:
      IOException
    • writeSFixed64

      public void writeSFixed64(int fieldNumber, long value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a signed+fixed long(8 bytes) field.
      Specified by:
      writeSFixed64 in interface Output
      Throws:
      IOException
    • writeSInt32

      public void writeSInt32(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a signed int field.
      Specified by:
      writeSInt32 in interface Output
      Throws:
      IOException
    • writeSInt64

      public void writeSInt64(int fieldNumber, long value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a signed long field.
      Specified by:
      writeSInt64 in interface Output
      Throws:
      IOException
    • writeString

      public void writeString(int fieldNumber, CharSequence value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes a String field.
      Specified by:
      writeString in interface Output
      Throws:
      IOException
    • writeUInt32

      public void writeUInt32(int fieldNumber, int value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes an unsigned int field.
      Specified by:
      writeUInt32 in interface Output
      Throws:
      IOException
    • writeUInt64

      public void writeUInt64(int fieldNumber, long value, boolean repeated) throws IOException
      Description copied from interface: Output
      Writes an unsigned long field.
      Specified by:
      writeUInt64 in interface Output
      Throws:
      IOException
    • writeBytes

      public void writeBytes(int fieldNumber, ByteBuffer value, boolean repeated) throws IOException
      Writes a ByteBuffer field.
      Specified by:
      writeBytes in interface Output
      Throws:
      IOException