Package com.tangosol.io.pof
Class PofBufferWriter.UserTypeWriter
java.lang.Object
com.tangosol.util.Base
com.tangosol.io.pof.PofHelper
com.tangosol.io.pof.PofBufferWriter
com.tangosol.io.pof.PofBufferWriter.UserTypeWriter
- All Implemented Interfaces:
PofConstants
,PofWriter
- Enclosing class:
PofBufferWriter
The UserTypeWriter implementation is a contextually-aware PofWriter
whose purpose is to write the properties of a value of a specified user
type. 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 a
PofContext that may differ from the PofContext that provided the
PofSerializer which is using this UserTypeWriter to serialize a user
type.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.io.pof.PofBufferWriter
PofBufferWriter.ReferenceLibrary, PofBufferWriter.UserTypeWriter
Nested classes/interfaces inherited from class com.tangosol.io.pof.PofHelper
PofHelper.ReadableEntrySetMap, PofHelper.WriteableEntrySetMap
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Field Summary
Modifier and TypeFieldDescriptionprotected WritingPofHandler.Complex
The Complex value that corresponds to the user type that is being written.protected boolean
True iff the type and version identifier of the user type was written to the POF stream.protected boolean
True iff the user type was written to the POF stream.protected int
The index of the last property written to the POF stream or -1 if the first property has yet to be written.protected int
The index of the user type being written.protected int
The identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF streamprotected int
The type identifier of the user type that is being written.protected int
The version identifier of the user type that is being written.protected PofBufferWriter.UserTypeWriter
The currently open nested writer, if any.Fields inherited from class com.tangosol.io.pof.PofBufferWriter
m_ctx, m_fEvolvable, m_handler, m_out, m_refs
Fields inherited from class com.tangosol.io.pof.PofHelper
BIGDECIMAL_ZERO, BIGINTEGER_MAX_LONG, BIGINTEGER_MIN_LONG, BINARY_EMPTY, BOOLEAN_ARRAY_EMPTY, BYTE_ARRAY_EMPTY, CHAR_ARRAY_EMPTY, COLLECTION_EMPTY, DOUBLE_ARRAY_EMPTY, FLOAT_ARRAY_EMPTY, INT_ARRAY_EMPTY, LONG_ARRAY_EMPTY, OBJECT_ARRAY_EMPTY, SHORT_ARRAY_EMPTY
Fields inherited from class com.tangosol.util.Base
LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
Fields inherited from interface com.tangosol.io.pof.PofConstants
J_BIG_DECIMAL, J_BIG_INTEGER, J_BINARY, J_BOOLEAN, J_BOOLEAN_ARRAY, J_BYTE, J_BYTE_ARRAY, J_CHAR_ARRAY, J_CHARACTER, J_COLLECTION, J_DATE, J_DATETIME, J_DOUBLE, J_DOUBLE_ARRAY, J_FLOAT, J_FLOAT_ARRAY, J_INT_ARRAY, J_INTEGER, J_LOCAL_DATE, J_LOCAL_DATETIME, J_LOCAL_TIME, J_LONG, J_LONG_ARRAY, J_MAP, J_NULL, J_OBJECT_ARRAY, J_OFFSET_DATETIME, J_OFFSET_TIME, J_QUAD, J_RAW_DATE, J_RAW_DATETIME, J_RAW_DAY_TIME_INTERVAL, J_RAW_TIME, J_RAW_TIME_INTERVAL, J_RAW_YEAR_MONTH_INTERVAL, J_SHORT, J_SHORT_ARRAY, J_SPARSE_ARRAY, J_STRING, J_TIME, J_TIMESTAMP, J_USER_TYPE, J_ZONED_DATETIME, MAX_DECIMAL128_SCALE, MAX_DECIMAL128_UNSCALED, MAX_DECIMAL32_SCALE, MAX_DECIMAL32_UNSCALED, MAX_DECIMAL64_SCALE, MAX_DECIMAL64_UNSCALED, MIN_DECIMAL128_SCALE, MIN_DECIMAL32_SCALE, MIN_DECIMAL64_SCALE, T_ARRAY, T_BOOLEAN, T_CHAR, T_CHAR_STRING, T_COLLECTION, T_DATE, T_DATETIME, T_DAY_TIME_INTERVAL, T_DECIMAL128, T_DECIMAL32, T_DECIMAL64, T_FLOAT128, T_FLOAT32, T_FLOAT64, T_IDENTITY, T_INT128, T_INT16, T_INT32, T_INT64, T_MAP, T_OCTET, T_OCTET_STRING, T_REFERENCE, T_SPARSE_ARRAY, T_TIME, T_TIME_INTERVAL, T_UNIFORM_ARRAY, T_UNIFORM_COLLECTION, T_UNIFORM_KEYS_MAP, T_UNIFORM_MAP, T_UNIFORM_SPARSE_ARRAY, T_UNKNOWN, T_YEAR_MONTH_INTERVAL, V_BOOLEAN_FALSE, V_BOOLEAN_TRUE, V_COLLECTION_EMPTY, V_FP_NAN, V_FP_NEG_INFINITY, V_FP_POS_INFINITY, V_INT_0, V_INT_1, V_INT_10, V_INT_11, V_INT_12, V_INT_13, V_INT_14, V_INT_15, V_INT_16, V_INT_17, V_INT_18, V_INT_19, V_INT_2, V_INT_20, V_INT_21, V_INT_22, V_INT_3, V_INT_4, V_INT_5, V_INT_6, V_INT_7, V_INT_8, V_INT_9, V_INT_NEG_1, V_REFERENCE_NULL, V_STRING_ZERO_LENGTH
-
Constructor Summary
ConstructorDescriptionUserTypeWriter
(PofBufferWriter parent, WritingPofHandler handler, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type.UserTypeWriter
(PofBufferWriter parent, WritingPofHandler handler, PofContext ctx, int nTypeId, int iProp, int nId) Construct a UserTypeWriter for writing the property values of a user type.UserTypeWriter
(PofBufferWriter parent, WriteBuffer.BufferOutput out, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type.UserTypeWriter
(WritingPofHandler handler, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type.UserTypeWriter
(WriteBuffer.BufferOutput out, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
beginProperty
(int iProp) Report that a POF property is about to be written to the POF stream.protected void
Notify the UserTypeWriter that it is being "closed".createNestedPofWriter
(int iProp) Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type.createNestedPofWriter
(int iProp, int nTypeId) Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type.void
Ensure that reference support (necessary for cyclic dependencies) is enabled.protected void
endProperty
(int iProp) Signifies the termination of the current POF property.protected PofBufferWriter
If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.int
Determine the user type that is currently being written.int
Determine the version identifier of the user type that is currently being written.protected boolean
Determine if the object to be written is either Evolvable or part of an Evolvable object.protected void
Called when an unexpected exception is caught while writing to the POF stream.void
setVersionId
(int nVersionId) Set the version identifier of the user type that is currently being written.void
writeRemainder
(Binary binProps) Write the remaining properties to the POF stream, terminating the writing of the current user type.protected void
Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.Methods inherited from class com.tangosol.io.pof.PofBufferWriter
assertEqual, fixNanos, getBufferOutput, getNanos, getPofContext, getPofHandler, isReferenceEnabled, main, setEvolvable, setPofContext, writeBigDecimal, writeBigInteger, writeBinary, writeBoolean, writeBoolean, writeBooleanArray, writeByte, writeByte, writeByteArray, writeChar, writeChar, writeCharArray, writeCollection, writeCollection, writeDate, writeDate, writeDateTime, writeDateTime, writeDateTime, writeDateTimeWithZone, writeDateTimeWithZone, writeDateTimeWithZone, writeDouble, writeDouble, writeDoubleArray, writeFloat, writeFloat, writeFloatArray, writeInt, writeInt, writeIntArray, writeLong, writeLong, writeLongArray, writeLongArray, writeLongArray, writeMap, writeMap, writeMap, writeObject, writeObjectArray, writeObjectArray, writeOptional, writeOptionalDouble, writeOptionalInt, writeOptionalLong, writeRawDate, writeRawDateTime, writeRawDayTimeInterval, writeRawQuad, writeRawTime, writeRawTimeInterval, writeRawYearMonthInterval, writeShort, writeShort, writeShortArray, writeString, writeTime, writeTime, writeTime, writeTimeWithZone, writeTimeWithZone, writeTimeWithZone, writeUserType
Methods inherited from class com.tangosol.io.pof.PofHelper
calcDecimalSize, checkDate, checkDayTimeInterval, checkDecimalRange, checkElementCount, checkReferenceRange, checkTime, checkTimeInterval, checkTimeZone, checkType, checkYearMonthInterval, convertNumber, convertToDate, decodeTinyInt, encodeTinyInt, formatDate, formatTime, formatTime, getJavaTypeId, getPofTypeId, isIntrinsicPofType, readAsBigDecimal, readAsBigInteger, readAsChar, readAsDouble, readAsFloat, readAsInt, readAsLong, readAsQuad, readBigDecimal, readBigInteger, readChar, readLocalDate, readLocalDateTime, readLocalTime, readOffsetDateTime, readOffsetTime, readQuad, readRawDate, readRawTime, resizeArray, skipPackedInts, skipUniformValue, skipValue, writeBigDecimal, writeBigInteger, writeDate, writeTime
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.io.pof.PofWriter
writeDateTimeWithZone
-
Field Details
-
m_nTypeId
protected int m_nTypeIdThe type identifier of the user type that is being written. -
m_nVersionId
protected int m_nVersionIdThe version identifier of the user type that is being written. -
m_iProp
protected int m_iPropThe index of the user type being written. -
m_nId
protected int m_nIdThe identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream -
m_iPrevProp
protected int m_iPrevPropThe index of the last property written to the POF stream or -1 if the first property has yet to be written. -
m_fUserTypeBegin
protected boolean m_fUserTypeBeginTrue iff the type and version identifier of the user type was written to the POF stream. -
m_fUserTypeEnd
protected boolean m_fUserTypeEndTrue iff the user type was written to the POF stream. -
m_complex
The Complex value that corresponds to the user type that is being written. -
m_writerNested
The currently open nested writer, if any.
-
-
Constructor Details
-
UserTypeWriter
Construct a UserTypeWriter for writing the property values of a user type.- Parameters:
out
- the BufferOutput object to write to; must not be nullctx
- the PofContext to use for writing the user type property values within the user type that this writer will be writingnTypeId
- the type identifier of the user type; must be non-negativeiProp
- the index of the user type being written
-
UserTypeWriter
public UserTypeWriter(PofBufferWriter parent, WriteBuffer.BufferOutput out, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type.- Parameters:
parent
- the containing PofBufferWriterout
- the BufferOutput object to write to; must not be nullctx
- the PofContext to use for writing the user type property values within the user type that this writer will be writingnTypeId
- the type identifier of the user type; must be non-negativeiProp
- the index of the user type being written
-
UserTypeWriter
Construct a UserTypeWriter for writing the property values of a user type.- Parameters:
handler
- the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)ctx
- the PofContext to use for writing the user type property values within the user type that this writer will be writingnTypeId
- the type identifier of the user type; must be non-negativeiProp
- the index of the user type being written
-
UserTypeWriter
public UserTypeWriter(PofBufferWriter parent, WritingPofHandler handler, PofContext ctx, int nTypeId, int iProp) Construct a UserTypeWriter for writing the property values of a user type.- Parameters:
parent
- the containing PofBufferWriterhandler
- the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)ctx
- the PofContext to use for writing the user type property values within the user type that this writer will be writingnTypeId
- the type identifier of the user type; must be non-negativeiProp
- the index of the user type being written
-
UserTypeWriter
public UserTypeWriter(PofBufferWriter parent, WritingPofHandler handler, PofContext ctx, int nTypeId, int iProp, int nId) Construct a UserTypeWriter for writing the property values of a user type.- Parameters:
parent
- the containing PofBufferWriterhandler
- the WritingPofHandler used to write user type data (except for the user type id itself, which is passed as a constructor argument)ctx
- the PofContext to use for writing the user type property values within the user type that this writer will be writingnTypeId
- the type identifier of the user type; must be non-negativeiProp
- the index of the user type being writtennId
- the identity of the object to encode, or -1 if the identity shouldn't be encoded in the POF stream
-
-
Method Details
-
getUserTypeId
public int getUserTypeId()Determine the user type that is currently being written.- Specified by:
getUserTypeId
in interfacePofWriter
- Overrides:
getUserTypeId
in classPofBufferWriter
- Returns:
- the user type identifier, or -1 if the PofWriter is not currently writing a user type
-
getVersionId
public int getVersionId()Determine the version identifier of the user type that is currently being written.- Specified by:
getVersionId
in interfacePofWriter
- Overrides:
getVersionId
in classPofBufferWriter
- Returns:
- the integer version ID of the user type; always non-negative
-
setVersionId
public void setVersionId(int nVersionId) Set the version identifier of the user type that is currently being written.- Specified by:
setVersionId
in interfacePofWriter
- Overrides:
setVersionId
in classPofBufferWriter
- Parameters:
nVersionId
- the user type identifier; must be non-negative
-
createNestedPofWriter
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.- Specified by:
createNestedPofWriter
in interfacePofWriter
- Overrides:
createNestedPofWriter
in classPofBufferWriter
- Parameters:
iProp
- the property index- Returns:
- a PofWriter whose contents are nested into a single property of this PofWriter
- Throws:
IOException
- if an I/O error occurs
-
createNestedPofWriter
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.- Specified by:
createNestedPofWriter
in interfacePofWriter
- Overrides:
createNestedPofWriter
in classPofBufferWriter
- Parameters:
iProp
- the property indexnTypeId
- the type identifier of the nested property- Returns:
- a PofWriter whose contents are nested into a single property of this PofWriter
- Throws:
IOException
- if an I/O error occurs
-
writeRemainder
Write the remaining properties to the POF stream, terminating the writing of the current user type. As part of writing out a user type, this method must be called by the PofSerializer 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.
- Specified by:
writeRemainder
in interfacePofWriter
- Overrides:
writeRemainder
in classPofBufferWriter
- Parameters:
binProps
- a Binary object containing zero or more indexed properties in binary POF encoded form; may be null- Throws:
IOException
- if an I/O error occurs
-
getParentWriter
If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.- Overrides:
getParentWriter
in classPofBufferWriter
- Returns:
- the containing writer
-
beginProperty
Report that a POF property is about to be written to the POF stream.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
PofBufferWriter.endProperty(int)
.- Overrides:
beginProperty
in classPofBufferWriter
- Parameters:
iProp
- the index of the property being written- Throws:
IOException
- if an I/O error occurs
-
endProperty
protected void endProperty(int iProp) Signifies the termination of the current POF property.- Overrides:
endProperty
in classPofBufferWriter
- Parameters:
iProp
- the index of the current property
-
closeNested
protected void 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. -
onException
Called when an unexpected exception is caught while writing to the POF stream.If the given exception wraps an IOException, the IOException is unwrapped and rethrown; otherwise the given exception is rethrown.
- Overrides:
onException
in classPofBufferWriter
- Parameters:
e
- the exception- Throws:
IOException
- the wrapped IOException, if the given exception is a wrapped IOException
-
writeUserTypeInfo
Write out the type and version identifiers of the user type to the POF stream, if they haven't already been written.- Throws:
IOException
- on I/O error
-
enableReference
public void enableReference()Ensure that reference support (necessary for cyclic dependencies) is enabled.- Overrides:
enableReference
in classPofBufferWriter
-
isEvolvable
protected boolean isEvolvable()Determine if the object to be written is either Evolvable or part of an Evolvable object.- Overrides:
isEvolvable
in classPofBufferWriter
- Returns:
- true iff the object to be written is Evolvable
-