Package io.protostuff
Class XmlXOutput
- java.lang.Object
-
- io.protostuff.WriteSession
-
- io.protostuff.XmlXOutput
-
- All Implemented Interfaces:
Output,StatefulOutput
public final class XmlXOutput extends WriteSession implements Output, StatefulOutput
Optimized xml output. The string values are not escaped (its assumed are no xml control chars or that they've been validated and xml-escaped on input).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.protostuff.WriteSession
WriteSession.FlushHandler
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static byteEND_TAG(package private) static byte[]FALSEprivate Schema<?>schema(package private) static byteSLASH(package private) static byte[]START_SLASH_TAG(package private) static byteSTART_TAG(package private) static byte[]TRUE-
Fields inherited from class io.protostuff.WriteSession
flushHandler, head, nextBufferSize, out, sink, size, tail
-
-
Constructor Summary
Constructors Constructor Description XmlXOutput(LinkedBuffer head, Schema<?> schema)XmlXOutput(LinkedBuffer head, java.io.OutputStream out, Schema<?> schema)XmlXOutput(LinkedBuffer head, java.io.OutputStream out, WriteSession.FlushHandler flushHandler, int nextBufferSize, Schema<?> schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlXOutputclear()The buffer will be cleared (tail will point to the head) and the size will be reset to zero.voidupdateLast(Schema<?> schema, Schema<?> lastSchema)Updates the schema iflastSchemawas indeed the last schema used.XmlXOutputuse(Schema<?> schema)Before serializing a message/object tied to a schema, this should be called.private voidwriteB64(java.lang.String name, byte[] value, int offset, int length, boolean repeated)voidwriteBool(int fieldNumber, boolean value, boolean repeated)Writes a boolean field.voidwriteByteArray(int fieldNumber, byte[] value, boolean repeated)Writes a byte array field.voidwriteByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated)Writes a binary or a pre-encoded utf8 string.voidwriteBytes(int fieldNumber, ByteString value, boolean repeated)Writes a ByteString(wraps byte array) field.voidwriteBytes(int fieldNumber, java.nio.ByteBuffer value, boolean repeated)Writes a ByteBuffer field.voidwriteDouble(int fieldNumber, double value, boolean repeated)Writes a double field.voidwriteEnum(int fieldNumber, int value, boolean repeated)Writes a enum(its number) field.voidwriteFixed32(int fieldNumber, int value, boolean repeated)Writes a fixed int(4 bytes) field.voidwriteFixed64(int fieldNumber, long value, boolean repeated)Writes a fixed long(8 bytes) field.voidwriteFloat(int fieldNumber, float value, boolean repeated)Writes a float field.voidwriteInt32(int fieldNumber, int value, boolean repeated)Writes a variable int field.voidwriteInt64(int fieldNumber, long value, boolean repeated)Writes a variable long field.<T> voidwriteObject(int fieldNumber, T value, Schema<T> schema, boolean repeated)Writes an object(using its schema) field.voidwriteSFixed32(int fieldNumber, int value, boolean repeated)Writes a signed+fixed int(4 bytes) field.voidwriteSFixed64(int fieldNumber, long value, boolean repeated)Writes a signed+fixed long(8 bytes) field.voidwriteSInt32(int fieldNumber, int value, boolean repeated)Writes a signed int field.voidwriteSInt64(int fieldNumber, long value, boolean repeated)Writes a signed long field.voidwriteString(int fieldNumber, java.lang.CharSequence value, boolean repeated)Writes a String field.voidwriteUInt32(int fieldNumber, int value, boolean repeated)Writes an unsigned int field.voidwriteUInt64(int fieldNumber, long value, boolean repeated)Writes an unsigned long field.-
Methods inherited from class io.protostuff.WriteSession
flush, flush, flush, getSize, reset, toByteArray
-
-
-
-
Field Detail
-
START_TAG
static final byte START_TAG
- See Also:
- Constant Field Values
-
END_TAG
static final byte END_TAG
- See Also:
- Constant Field Values
-
SLASH
static final byte SLASH
- See Also:
- Constant Field Values
-
START_SLASH_TAG
static final byte[] START_SLASH_TAG
-
TRUE
static final byte[] TRUE
-
FALSE
static final byte[] FALSE
-
schema
private Schema<?> schema
-
-
Constructor Detail
-
XmlXOutput
public XmlXOutput(LinkedBuffer head, Schema<?> schema)
-
XmlXOutput
public XmlXOutput(LinkedBuffer head, java.io.OutputStream out, WriteSession.FlushHandler flushHandler, int nextBufferSize, Schema<?> schema)
-
XmlXOutput
public XmlXOutput(LinkedBuffer head, java.io.OutputStream out, Schema<?> schema)
-
-
Method Detail
-
clear
public XmlXOutput clear()
Description copied from class:WriteSessionThe buffer will be cleared (tail will point to the head) and the size will be reset to zero.- Overrides:
clearin classWriteSession
-
use
public XmlXOutput use(Schema<?> schema)
Before serializing a message/object tied to a schema, this should be called.
-
updateLast
public void updateLast(Schema<?> schema, Schema<?> lastSchema)
Description copied from interface:StatefulOutputUpdates the schema iflastSchemawas indeed the last schema used.- Specified by:
updateLastin interfaceStatefulOutput
-
writeBool
public void writeBool(int fieldNumber, boolean value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a boolean field.
-
writeDouble
public void writeDouble(int fieldNumber, double value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a double field.- Specified by:
writeDoublein interfaceOutput- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(int fieldNumber, float value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a float field.- Specified by:
writeFloatin interfaceOutput- Throws:
java.io.IOException
-
writeEnum
public void writeEnum(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a enum(its number) field.
-
writeFixed32
public void writeFixed32(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a fixed int(4 bytes) field.- Specified by:
writeFixed32in interfaceOutput- Throws:
java.io.IOException
-
writeInt32
public void writeInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a variable int field.- Specified by:
writeInt32in interfaceOutput- Throws:
java.io.IOException
-
writeSFixed32
public void writeSFixed32(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a signed+fixed int(4 bytes) field.- Specified by:
writeSFixed32in interfaceOutput- Throws:
java.io.IOException
-
writeUInt32
public void writeUInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites an unsigned int field.- Specified by:
writeUInt32in interfaceOutput- Throws:
java.io.IOException
-
writeSInt32
public void writeSInt32(int fieldNumber, int value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a signed int field.- Specified by:
writeSInt32in interfaceOutput- Throws:
java.io.IOException
-
writeFixed64
public void writeFixed64(int fieldNumber, long value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a fixed long(8 bytes) field.- Specified by:
writeFixed64in interfaceOutput- Throws:
java.io.IOException
-
writeInt64
public void writeInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a variable long field.- Specified by:
writeInt64in interfaceOutput- Throws:
java.io.IOException
-
writeSFixed64
public void writeSFixed64(int fieldNumber, long value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a signed+fixed long(8 bytes) field.- Specified by:
writeSFixed64in interfaceOutput- Throws:
java.io.IOException
-
writeSInt64
public void writeSInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a signed long field.- Specified by:
writeSInt64in interfaceOutput- Throws:
java.io.IOException
-
writeUInt64
public void writeUInt64(int fieldNumber, long value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites an unsigned long field.- Specified by:
writeUInt64in interfaceOutput- Throws:
java.io.IOException
-
writeString
public void writeString(int fieldNumber, java.lang.CharSequence value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a String field.- Specified by:
writeStringin interfaceOutput- Throws:
java.io.IOException
-
writeByteRange
public void writeByteRange(boolean utf8String, int fieldNumber, byte[] value, int offset, int length, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a binary or a pre-encoded utf8 string.- Specified by:
writeByteRangein interfaceOutput- Throws:
java.io.IOException
-
writeB64
private void writeB64(java.lang.String name, byte[] value, int offset, int length, boolean repeated) throws java.io.IOException- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(int fieldNumber, ByteString value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a ByteString(wraps byte array) field.- Specified by:
writeBytesin interfaceOutput- Throws:
java.io.IOException
-
writeByteArray
public void writeByteArray(int fieldNumber, byte[] value, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites a byte array field.- Specified by:
writeByteArrayin interfaceOutput- Throws:
java.io.IOException
-
writeObject
public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws java.io.IOExceptionDescription copied from interface:OutputWrites an object(using its schema) field.- Specified by:
writeObjectin interfaceOutput- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(int fieldNumber, java.nio.ByteBuffer value, boolean repeated) throws java.io.IOExceptionWrites a ByteBuffer field.- Specified by:
writeBytesin interfaceOutput- Throws:
java.io.IOException
-
-