Output

fm.serializer.Output

Generic Output trait to be implemented by Serialization Implementations

There are 3 classes of outputs:

  • RAW
  • NESTED
  • FIELD

RAW Raw output is what you get if you serialize something by itself. Depending on the serialization implementation it will probably have an implicit length determined by the length of an Array[Byte], String, InputStream, etc. The starting point for serializing something it usually invoking one of the writeRawXXX(...) methods. The writeRawXXX(...) methods should be implemented by all serialization implementations.

NESTED Nested output is what we use when something is serialized as part of something else and may or may not be different than RAW output depending on the serialization implementation. For example, when serializing a collection each element would be serialized using the writeNestedXXX(...) methods. The nested format might have additional length information compared to the RAW format since there is no implicit length. For example, in protocol buffers a string/object/collection is prefixed with its length. Most serialization implementations can probably write optional length information followed by calling the corresponding writeRawXXX(...) method.

Another way to think about nested output is what we should be able to deserialize a NESTED value that is in the middle of an array of bytes (or a string or whatever). This means we need to know when to stop reading the value. For something like Protocol Buffers we will be prepending the length for string/object/repeated field or have a marker bit for varints to know when to stop. For something like JSON we will hit a double-quote (for strings) for a comma or closing brace (for all other types).

FIELD Field output is used when writing fields of an object. In addition to the value we are serializing it contains the name/number of the field in the object. Most implementations will probably write out the field name/number information followed by a call to the corresponding writeNestedXXX(...) method. Some implementations, such as Protocol Buffers, writes out the type of the field as part of the name/number which is why there isn't just a writeFieldName(...) which the framework would call automatically followed by the appropriate writeNestedXXX(...).

NOTE - Reading field output (via Input) is broken into a readFieldNumber() call to get the name/number of the field followed by calls to readNestedXXX().

Things are broken out this way to mainly support more complex formats (like Protocol Buffers). For something like a JSON implementation the RAW and NESTED formats will probably be the same. The way in which we write out JSON fields as part of an object will also be the same no matter what the type is unlike something like Protocol Buffers which needs to encode the type of field as part of the name/number of the field.

Attributes

Graph
Supertypes
trait RawOutput
trait NestedOutput
trait FieldOutput
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Value members

Inherited methods

def allowStringMap: Boolean

Attributes

Inherited from:
RawOutput
def writeFieldBigDecimal(number: Int, name: String, value: BigDecimal): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldBigInteger(number: Int, name: String, value: BigInteger): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldBool(number: Int, name: String, value: Boolean): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldByteArray(number: Int, name: String, value: Array[Byte]): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldCollection[T](number: Int, name: String, col: T)(f: (NestedOutput, T) => Unit): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldDouble(number: Int, name: String, value: Double): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldFixedInt(number: Int, name: String, value: Int): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldFixedLong(number: Int, name: String, value: Long): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldFloat(number: Int, name: String, value: Float): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldInt(number: Int, name: String, value: Int): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldLong(number: Int, name: String, value: Long): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldNull(number: Int, name: String): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldObject[T](number: Int, name: String, obj: T)(f: (FieldOutput, T) => Unit): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldSignedInt(number: Int, name: String, value: Int): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldSignedLong(number: Int, name: String, value: Long): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldString(number: Int, name: String, value: String): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldUnsignedInt(number: Int, name: String, value: Int): Unit

Attributes

Inherited from:
FieldOutput
def writeFieldUnsignedLong(number: Int, name: String, value: Long): Unit

Attributes

Inherited from:
FieldOutput
def writeNestedBigDecimal(value: BigDecimal): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedBigInteger(value: BigInteger): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedBool(value: Boolean): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedByteArray(value: Array[Byte]): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedCollection[T](col: T)(f: (NestedOutput, T) => Unit): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedDouble(value: Double): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedFixedInt(value: Int): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedFixedLong(value: Long): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedFloat(value: Float): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedInt(value: Int): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedLong(value: Long): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedObject[T](obj: T)(f: (FieldOutput, T) => Unit): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedSignedInt(value: Int): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedSignedLong(value: Long): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedString(value: String): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedUnsignedInt(value: Int): Unit

Attributes

Inherited from:
NestedOutput
def writeNestedUnsignedLong(value: Long): Unit

Attributes

Inherited from:
NestedOutput
def writeRawBigDecimal(value: BigDecimal): Unit

Attributes

Inherited from:
RawOutput
def writeRawBigInteger(value: BigInteger): Unit

Attributes

Inherited from:
RawOutput
def writeRawBool(value: Boolean): Unit

Attributes

Inherited from:
RawOutput
def writeRawByteArray(value: Array[Byte]): Unit

Attributes

Inherited from:
RawOutput
def writeRawCollection[T](col: T)(f: (NestedOutput, T) => Unit): Unit

Write out a RAW collection. This method will wrap the collection in whatever leading/trailing "stuff" is needed (e.g. length prefixing, leading/trailing chars, etc...). The method that you pass in should use the Output instance to make repeated calls to a single write

Write out a RAW collection. This method will wrap the collection in whatever leading/trailing "stuff" is needed (e.g. length prefixing, leading/trailing chars, etc...). The method that you pass in should use the Output instance to make repeated calls to a single write

Attributes

Inherited from:
RawOutput
def writeRawDouble(value: Double): Unit

Attributes

Inherited from:
RawOutput
def writeRawFixedInt(value: Int): Unit

Attributes

Inherited from:
RawOutput
def writeRawFixedLong(value: Long): Unit

Attributes

Inherited from:
RawOutput
def writeRawFloat(value: Float): Unit

Attributes

Inherited from:
RawOutput
def writeRawInt(value: Int): Unit

Attributes

Inherited from:
RawOutput
def writeRawLong(value: Long): Unit

Attributes

Inherited from:
RawOutput
def writeRawObject[T](obj: T)(f: (FieldOutput, T) => Unit): Unit

For writing objects. Note: that the obj is passed in for null handling by the implementation. If the object is not null then the function f will be called so the caller can write out the fields

For writing objects. Note: that the obj is passed in for null handling by the implementation. If the object is not null then the function f will be called so the caller can write out the fields

Attributes

Inherited from:
RawOutput
def writeRawSignedInt(value: Int): Unit

Attributes

Inherited from:
RawOutput
def writeRawSignedLong(value: Long): Unit

Attributes

Inherited from:
RawOutput
def writeRawString(value: String): Unit

Attributes

Inherited from:
RawOutput
def writeRawUnsignedInt(value: Int): Unit

Attributes

Inherited from:
RawOutput
def writeRawUnsignedLong(value: Long): Unit

Attributes

Inherited from:
RawOutput