Show / Hide Table of Contents

Class PofStreamWriter.UserTypeWriter

The UserTypeWriter implementation is a contextually-aware IPofWriter whose purpose is to write the properties of a value of a specified user type.

Inheritance
object
PofStreamWriter
PofStreamWriter.UserTypeWriter
Implements
IPofWriter
Inherited Members
PofStreamWriter.PofContext
PofStreamWriter.PofHandler
PofStreamWriter.IsReferenceEnabled()
PofStreamWriter.WriteBoolean(int, bool)
PofStreamWriter.WriteByte(int, byte)
PofStreamWriter.WriteChar(int, char)
PofStreamWriter.WriteInt16(int, short)
PofStreamWriter.WriteInt32(int, int)
PofStreamWriter.WriteInt64(int, long)
PofStreamWriter.WriteRawInt128(int, RawInt128)
PofStreamWriter.WriteSingle(int, float)
PofStreamWriter.WriteDouble(int, double)
PofStreamWriter.WriteBooleanArray(int, bool[])
PofStreamWriter.WriteByteArray(int, byte[])
PofStreamWriter.WriteCharArray(int, char[])
PofStreamWriter.WriteInt16Array(int, short[])
PofStreamWriter.WriteInt32Array(int, int[])
PofStreamWriter.WriteInt64Array(int, long[])
PofStreamWriter.WriteSingleArray(int, float[])
PofStreamWriter.WriteDoubleArray(int, double[])
PofStreamWriter.WriteDecimal(int, decimal)
PofStreamWriter.WriteString(int, string)
PofStreamWriter.WriteDate(int, DateTime)
PofStreamWriter.WriteDateTime(int, DateTime)
PofStreamWriter.WriteLocalDateTime(int, DateTime)
PofStreamWriter.WriteUniversalDateTime(int, DateTime)
PofStreamWriter.WriteRawDateTime(int, RawDateTime)
PofStreamWriter.WriteRawTime(int, RawTime)
PofStreamWriter.WriteTime(int, DateTime)
PofStreamWriter.WriteLocalTime(int, DateTime)
PofStreamWriter.WriteUniversalTime(int, DateTime)
PofStreamWriter.WriteRawYearMonthInterval(int, RawYearMonthInterval)
PofStreamWriter.WriteTimeInterval(int, TimeSpan)
PofStreamWriter.WriteDayTimeInterval(int, TimeSpan)
PofStreamWriter.WriteUserType(int, object)
PofStreamWriter.WriteBinary(int, Binary)
PofStreamWriter.WriteArray(int, Array)
PofStreamWriter.WriteArray(int, Array, Type)
PofStreamWriter.WriteCollection(int, ICollection)
PofStreamWriter.WriteCollection(int, ICollection, Type)
PofStreamWriter.WriteLongArray(int, ILongArray)
PofStreamWriter.WriteLongArray(int, ILongArray, Type)
PofStreamWriter.WriteDictionary(int, IDictionary)
PofStreamWriter.WriteDictionary(int, IDictionary, Type)
PofStreamWriter.WriteDictionary(int, IDictionary, Type, Type)
PofStreamWriter.WriteCollection<T>(int, ICollection<T>)
PofStreamWriter.WriteDictionary<TKey, TValue>(int, IDictionary<TKey, TValue>)
PofStreamWriter.AssertEqual(Type, Type)
PofStreamWriter.m_writer
PofStreamWriter.m_ctx
PofStreamWriter.m_evolvable
PofStreamWriter.m_handler
PofStreamWriter.m_refs
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.IO.Pof
Assembly: Coherence.dll
Syntax
public class PofStreamWriter.UserTypeWriter : PofStreamWriter, IPofWriter
Remarks

The "contextual awareness" refers to the fact that the UserTypeWriter maintains state about the type identifier, the PofWriter's property index position within the user type value, and an IPofContext that may differ from the IPofContext that provided the IPofSerializer which is using this UserTypeWriter to serialize a user type.

Constructors

UserTypeWriter(DataWriter, IPofContext, int, int)

Construct a UserTypeWriter for writing the property values of a user type.

Declaration
public UserTypeWriter(DataWriter writer, IPofContext ctx, int typeId, int index)
Parameters
Type Name Description
DataWriter writer

The DataWriter object to write to; must not be null.

IPofContext ctx

The IPofContext to use for writing the user type property values within the user type that this writer will be writing.

int typeId

The type identifier of the user type; must be non-negative.

int index

The index of the user type being written.

UserTypeWriter(PofStreamWriter, DataWriter, IPofContext, int, int)

Construct a UserTypeWriter for writing the property values of a user type.

Declaration
public UserTypeWriter(PofStreamWriter parent, DataWriter writer, IPofContext ctx, int typeId, int index)
Parameters
Type Name Description
PofStreamWriter parent

the containing PofBufferWriter

DataWriter writer

The DataWriter object to write to; must not be null.

IPofContext ctx

The IPofContext to use for writing the user type property values within the user type that this writer will be writing.

int typeId

The type identifier of the user type; must be non-negative.

int index

The index of the user type being written.

UserTypeWriter(PofStreamWriter, WritingPofHandler, IPofContext, int, int)

Construct a UserTypeWriter for writing the property values of a user type.

Declaration
public UserTypeWriter(PofStreamWriter parent, WritingPofHandler handler, IPofContext ctx, int typeId, int index)
Parameters
Type Name Description
PofStreamWriter parent

the containing PofBufferWriter

WritingPofHandler handler

The WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument).

IPofContext ctx

The IPofContext to use for writing the user type property values within the user type that this writer will be writing.

int typeId

The type identifier of the user type; must be non-negative.

int index

The index of the user type being written.

UserTypeWriter(PofStreamWriter, WritingPofHandler, IPofContext, int, int, int)

Construct a UserTypeWriter for writing the property values of a user type.

Declaration
public UserTypeWriter(PofStreamWriter parent, WritingPofHandler handler, IPofContext ctx, int typeId, int index, int id)
Parameters
Type Name Description
PofStreamWriter parent

the containing PofBufferWriter

WritingPofHandler handler

The WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument).

IPofContext ctx

The IPofContext to use for writing the user type property values within the user type that this writer will be writing.

int typeId

The type identifier of the user type; must be non-negative.

int index

The index of the user type being written.

int id

the identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream

UserTypeWriter(WritingPofHandler, IPofContext, int, int)

Construct a UserTypeWriter for writing the property values of a user type.

Declaration
public UserTypeWriter(WritingPofHandler handler, IPofContext ctx, int typeId, int index)
Parameters
Type Name Description
WritingPofHandler handler

The WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument).

IPofContext ctx

The IPofContext to use for writing the user type property values within the user type that this writer will be writing.

int typeId

The type identifier of the user type; must be non-negative.

int index

The index of the user type being written.

Fields

m_complex

The Complex value that corresponds to the user type that is being written.

Declaration
protected WritingPofHandler.Complex m_complex
Field Value
Type Description
WritingPofHandler.Complex

m_id

The identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream

Declaration
protected int m_id
Field Value
Type Description
int

m_isUserTypeBegin

true if the type and version identifier of the user type was written to the POF stream.

Declaration
protected bool m_isUserTypeBegin
Field Value
Type Description
bool

m_isUserTypeEnd

true if the user type was written to the POF stream.

Declaration
protected bool m_isUserTypeEnd
Field Value
Type Description
bool

m_prevProp

The index of the last property written to the POF stream or -1 if the first property has yet to be written.

Declaration
protected int m_prevProp
Field Value
Type Description
int

m_prop

The index of the user type being written.

Declaration
protected int m_prop
Field Value
Type Description
int

m_typeId

The type identifier of the user type that is being written.

Declaration
protected int m_typeId
Field Value
Type Description
int

m_versionId

The version identifier of the user type that is being written.

Declaration
protected int m_versionId
Field Value
Type Description
int

m_writerNested

The currently open nested writer, if any.

Declaration
protected PofStreamWriter.UserTypeWriter m_writerNested
Field Value
Type Description
PofStreamWriter.UserTypeWriter

Properties

IsEvolvable

Gets the flag that indicate if the object to be written is either evolvable or part of an evolvable object.

Declaration
protected override bool IsEvolvable { get; }
Property Value
Type Description
bool

True iff the object to be written is IEvolvable.

Overrides
PofStreamWriter.IsEvolvable

UserTypeId

Gets the user type that is currently being written.

Declaration
public override int UserTypeId { get; }
Property Value
Type Description
int

The user type information, or -1 if the PofStreamWriter is not currently writing a user type.

Overrides
PofStreamWriter.UserTypeId

VersionId

Gets or sets the version identifier of the user type that is currently being written.

Declaration
public override int VersionId { get; set; }
Property Value
Type Description
int

The integer version ID of the user type; always non-negative.

Overrides
PofStreamWriter.VersionId
Exceptions
Type Condition
ArgumentException

If the given version ID is negative.

InvalidOperationException

If no user type is being written.

WriterParent

If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.

Declaration
public PofStreamWriter WriterParent { get; }
Property Value
Type Description
PofStreamWriter

Methods

BeginProperty(int)

Report that a POF property is about to be written to the POF stream.

Declaration
protected override void BeginProperty(int index)
Parameters
Type Name Description
int index

The index of the property being written.

Overrides
PofStreamWriter.BeginProperty(int)
Remarks

This method call will be followed by one or more separate calls to a "write" method and the property extent will then be terminated by a call to EndProperty(int).

Exceptions
Type Condition
ArgumentException

If the property index is invalid; or is less than or equal to the index of the previous property written to the POF stream.

IOException

If an I/O error occurs.

CloseNested()

Notify the UserTypeWriter that it is being "closed". This notification allows the UserTypeWriter to write any remaining data that it has pending to write.

Declaration
public void CloseNested()

CreateNestedPofWriter(int)

Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type. The returned PofWriter is only valid from the time that it is returned until the next call is made to this PofWriter.

Declaration
public override IPofWriter CreateNestedPofWriter(int iProp)
Parameters
Type Name Description
int iProp

the property index

Returns
Type Description
IPofWriter

a PofWriter whose contents are nested into a single property of this PofWriter

Overrides
PofStreamWriter.CreateNestedPofWriter(int)
Exceptions
Type Condition
ArgumentException

if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream

InvalidOperationException

if no user type is being written

IOException

if an I/O error occurs

CreateNestedPofWriter(int, int)

Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type. The returned PofWriter is only valid from the time that it is returned until the next call is made to this PofWriter.

Declaration
public override IPofWriter CreateNestedPofWriter(int iProp, int nTypeId)
Parameters
Type Name Description
int iProp

the property index

int nTypeId

the type identifier of the nested property

Returns
Type Description
IPofWriter

a PofWriter whose contents are nested into a single property of this PofWriter

Overrides
PofStreamWriter.CreateNestedPofWriter(int, int)
Exceptions
Type Condition
ArgumentException

if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream

InvalidOperationException

if no user type is being written

IOException

if an I/O error occurs

EnableReference()

Ensure that reference support (necessary for cyclic dependencies) is enabled.

Declaration
public override void EnableReference()
Overrides
PofStreamWriter.EnableReference()

EndProperty(int)

Signifies the termination of the current POF property.

Declaration
protected override void EndProperty(int index)
Parameters
Type Name Description
int index

The index of the current property.

Overrides
PofStreamWriter.EndProperty(int)

OnException(Exception)

Called when an unexpected exception is caught while writing to the POF stream.

Declaration
protected override void OnException(Exception e)
Parameters
Type Name Description
Exception e

The exception.

Overrides
PofStreamWriter.OnException(Exception)
Remarks

If the given exception wraps an IOException, the IOException is unwrapped and rethrown; otherwise the given exception is rethrown.

Exceptions
Type Condition
IOException

The wrapped IOException, if the given exception is a wrapped IOException.

WriteObject(int, object)

Write an Object property to the POF stream.

Declaration
public override void WriteObject(int index, object o)
Parameters
Type Name Description
int index

The property index.

object o

The Object property value to write.

Overrides
PofStreamWriter.WriteObject(int, object)
Remarks

The given object must be an instance (or an array of instances) of one of the following:

  • Boolean
  • Byte
  • Char
  • Int16
  • Int32
  • Int64
  • Single
  • Double
  • String
  • DateTime
  • TimeSpan
  • ICollection
  • ILongArray
  • RawTime
  • RawDateTime
  • RawYearMonthInterval
  • IPortableObject

Otherwise, an IPofSerializer for the object must be obtainable from the IPofContext associated with this IPofWriter.

Exceptions
Type Condition
ArgumentException

If the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream, or if the given property cannot be encoded into a POF stream.

IOException

If an I/O error occurs.

WriteRemainder(Binary)

Write the remaining properties to the POF stream, terminating the writing of the currrent user type.

Declaration
public override void WriteRemainder(Binary properties)
Parameters
Type Name Description
Binary properties

A Byte[] object containing zero or more indexed properties in binary POF encoded form; may be null.

Overrides
PofStreamWriter.WriteRemainder(Binary)
Remarks

As part of writing out a user type, this method must be called by the IPofSerializer that is writing out the user type, or the POF stream will be corrupted.

Calling this method terminates the current user type by writing a -1 to the POF stream after the last indexed property. Subsequent calls to the various WriteXYZ methods of this interface will fail after this method is called.

Exceptions
Type Condition
InvalidOperationException

If no user type is being written.

IOException

If an I/O error occurs.

WriteUserTypeInfo()

Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.

Declaration
protected virtual void WriteUserTypeInfo()
Exceptions
Type Condition
IOException

On I/O error.

Implements

IPofWriter
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.