Package org.infinispan.protostream.impl
Class TagWriterImpl
- java.lang.Object
-
- org.infinispan.protostream.impl.TagWriterImpl
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ProtobufTagMarshaller.OperationContext
,ProtobufTagMarshaller.WriteContext
,RawProtoStreamWriter
,TagWriter
public final class TagWriterImpl extends Object implements TagWriter, ProtobufTagMarshaller.WriteContext
- Since:
- 3.0
- Author:
- [email protected]
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TagWriterImpl.EncoderImpl
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Invoke after done with writer, this implies a flush if necessary It is necessary to invoke this on a writer returned fromTagWriter.subWriter(int, boolean)
to actually push the dataint
depth()
void
flush()
Object
getParam(Object key)
org.infinispan.protostream.impl.ProtoStreamWriterImpl
getProtoStreamWriter()
Deprecated.this will be removed in 5.0 together withMessageMarshaller
SerializationContextImpl
getSerializationContext()
Provides access to theImmutableSerializationContext
.TagWriter
getWriter()
int
getWrittenBytes()
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx)
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, byte[] buf)
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, byte[] buf, int offset, int length)
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, OutputStream output)
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, OutputStream output, int bufferSize)
Deprecated.since 4.6.3 Please usenewInstance(ImmutableSerializationContext, OutputStream)
with ainstead
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, ByteBuffer byteBuffer)
static TagWriterImpl
newInstance(ImmutableSerializationContext serCtx, Encoder encoder)
static TagWriterImpl
newInstanceNoBuffer(ImmutableSerializationContext ctx, OutputStream out)
static TagWriterImpl
newNestedInstance(ProtobufTagMarshaller.WriteContext parent, byte[] buf)
static TagWriterImpl
newNestedInstance(ProtobufTagMarshaller.WriteContext parent, OutputStream output)
void
setParam(Object key, Object value)
ProtobufTagMarshaller.WriteContext
subWriter(int number, boolean nested)
Used to write a sub message that can be optimized by implementation.void
writeBool(int number, boolean value)
void
writeBytes(int number, byte[] value, int offset, int length)
void
writeBytes(int number, ByteBuffer value)
Write field tag and all remaining bytes from current buffer position.void
writeFixed32(int number, int value)
void
writeFixed64(int number, long value)
void
writeInt64(int number, long value)
static void
writePositiveFixedVarint(byte[] array, int pos, int length)
static void
writePositiveFixedVarint(ByteBuffer buf, int pos, int length)
void
writeRawByte(byte value)
void
writeRawBytes(byte[] value, int offset, int length)
void
writeRawBytes(ByteBuffer value)
Write all remaining bytes from current buffer position.void
writeString(int number, String value)
void
writeUInt32(int number, int value)
void
writeUInt64(int number, long value)
void
writeVarint32(int value)
void
writeVarint64(long value)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.protostream.RawProtoStreamWriter
writeUInt32NoTag, writeUInt64NoTag
-
Methods inherited from interface org.infinispan.protostream.TagWriter
writeBytes, writeDouble, writeEnum, writeFloat, writeInt32, writeSFixed32, writeSFixed64, writeSInt32, writeSInt64, writeTag, writeTag
-
-
-
-
Method Detail
-
newNestedInstance
public static TagWriterImpl newNestedInstance(ProtobufTagMarshaller.WriteContext parent, OutputStream output)
-
newNestedInstance
public static TagWriterImpl newNestedInstance(ProtobufTagMarshaller.WriteContext parent, byte[] buf)
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, OutputStream output)
-
newInstance
@Deprecated public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, OutputStream output, int bufferSize)
Deprecated.since 4.6.3 Please usenewInstance(ImmutableSerializationContext, OutputStream)
with ainstead
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, byte[] buf)
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, byte[] buf, int offset, int length)
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, ByteBuffer byteBuffer)
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx)
-
newInstanceNoBuffer
public static TagWriterImpl newInstanceNoBuffer(ImmutableSerializationContext ctx, OutputStream out)
-
newInstance
public static TagWriterImpl newInstance(ImmutableSerializationContext serCtx, Encoder encoder)
-
getWrittenBytes
public int getWrittenBytes()
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceRawProtoStreamWriter
- Specified by:
flush
in interfaceTagWriter
- Throws:
IOException
-
close
public void close() throws IOException
Description copied from interface:TagWriter
Invoke after done with writer, this implies a flush if necessary It is necessary to invoke this on a writer returned fromTagWriter.subWriter(int, boolean)
to actually push the data- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceTagWriter
- Throws:
IOException
-
writeVarint32
public void writeVarint32(int value) throws IOException
- Specified by:
writeVarint32
in interfaceRawProtoStreamWriter
- Specified by:
writeVarint32
in interfaceTagWriter
- Throws:
IOException
-
writeVarint64
public void writeVarint64(long value) throws IOException
- Specified by:
writeVarint64
in interfaceRawProtoStreamWriter
- Specified by:
writeVarint64
in interfaceTagWriter
- Throws:
IOException
-
writeString
public void writeString(int number, String value) throws IOException
- Specified by:
writeString
in interfaceRawProtoStreamWriter
- Specified by:
writeString
in interfaceTagWriter
- Throws:
IOException
-
writeUInt32
public void writeUInt32(int number, int value) throws IOException
- Specified by:
writeUInt32
in interfaceRawProtoStreamWriter
- Specified by:
writeUInt32
in interfaceTagWriter
- Throws:
IOException
-
writeFixed32
public void writeFixed32(int number, int value) throws IOException
- Specified by:
writeFixed32
in interfaceRawProtoStreamWriter
- Specified by:
writeFixed32
in interfaceTagWriter
- Throws:
IOException
-
writeInt64
public void writeInt64(int number, long value) throws IOException
- Specified by:
writeInt64
in interfaceRawProtoStreamWriter
- Specified by:
writeInt64
in interfaceTagWriter
- Throws:
IOException
-
writeUInt64
public void writeUInt64(int number, long value) throws IOException
- Specified by:
writeUInt64
in interfaceRawProtoStreamWriter
- Specified by:
writeUInt64
in interfaceTagWriter
- Throws:
IOException
-
writeFixed64
public void writeFixed64(int number, long value) throws IOException
- Specified by:
writeFixed64
in interfaceRawProtoStreamWriter
- Specified by:
writeFixed64
in interfaceTagWriter
- Throws:
IOException
-
writeBool
public void writeBool(int number, boolean value) throws IOException
- Specified by:
writeBool
in interfaceRawProtoStreamWriter
- Specified by:
writeBool
in interfaceTagWriter
- Throws:
IOException
-
writeBytes
public void writeBytes(int number, ByteBuffer value) throws IOException
Description copied from interface:RawProtoStreamWriter
Write field tag and all remaining bytes from current buffer position.- Specified by:
writeBytes
in interfaceRawProtoStreamWriter
- Specified by:
writeBytes
in interfaceTagWriter
- Throws:
IOException
-
writeBytes
public void writeBytes(int number, byte[] value, int offset, int length) throws IOException
- Specified by:
writeBytes
in interfaceRawProtoStreamWriter
- Specified by:
writeBytes
in interfaceTagWriter
- Throws:
IOException
-
subWriter
public ProtobufTagMarshaller.WriteContext subWriter(int number, boolean nested) throws IOException
Description copied from interface:TagWriter
Used to write a sub message that can be optimized by implementation. When the sub writer is complete, flush should be invoked to ensure bytes are written and close should be invoked to free any resources related to the context (note close will flush as well)- Specified by:
subWriter
in interfaceTagWriter
- Parameters:
number
- the message number of the sub messagenested
- whether this is a nested message or a new one- Returns:
- a write context for a sub message
- Throws:
IOException
- exception if there is an issue
-
writeRawByte
public void writeRawByte(byte value) throws IOException
- Specified by:
writeRawByte
in interfaceRawProtoStreamWriter
- Throws:
IOException
-
writeRawBytes
public void writeRawBytes(byte[] value, int offset, int length) throws IOException
- Specified by:
writeRawBytes
in interfaceRawProtoStreamWriter
- Specified by:
writeRawBytes
in interfaceTagWriter
- Throws:
IOException
-
writeRawBytes
public void writeRawBytes(ByteBuffer value) throws IOException
Description copied from interface:RawProtoStreamWriter
Write all remaining bytes from current buffer position.- Specified by:
writeRawBytes
in interfaceRawProtoStreamWriter
- Throws:
IOException
-
getSerializationContext
public SerializationContextImpl getSerializationContext()
Description copied from interface:ProtobufTagMarshaller.OperationContext
Provides access to theImmutableSerializationContext
.- Specified by:
getSerializationContext
in interfaceProtobufTagMarshaller.OperationContext
-
getParam
public Object getParam(Object key)
- Specified by:
getParam
in interfaceProtobufTagMarshaller.OperationContext
-
setParam
public void setParam(Object key, Object value)
- Specified by:
setParam
in interfaceProtobufTagMarshaller.OperationContext
-
getWriter
public TagWriter getWriter()
- Specified by:
getWriter
in interfaceProtobufTagMarshaller.WriteContext
-
depth
public int depth()
- Specified by:
depth
in interfaceProtobufTagMarshaller.WriteContext
-
getProtoStreamWriter
@Deprecated public org.infinispan.protostream.impl.ProtoStreamWriterImpl getProtoStreamWriter()
Deprecated.this will be removed in 5.0 together withMessageMarshaller
-
writePositiveFixedVarint
public static void writePositiveFixedVarint(byte[] array, int pos, int length)
-
writePositiveFixedVarint
public static void writePositiveFixedVarint(ByteBuffer buf, int pos, int length)
-
-