Class AbstractPofValue
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.BitHelper
-
- com.tangosol.util.ExternalizableHelper
-
- com.tangosol.io.pof.reflect.AbstractPofValue
-
- All Implemented Interfaces:
PofValue
- Direct Known Subclasses:
ComplexPofValue
,SimplePofValue
public abstract class AbstractPofValue extends ExternalizableHelper implements PofValue
An abstract base class that implements common functionality for all PofValue types.- Since:
- Coherence 3.5
- Author:
- as 2009.02.12
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.ExternalizableHelper
ExternalizableHelper.DecoratedMultiBufferReadBuffer, ExternalizableHelper.DefaultObjectStreamFactory, ExternalizableHelper.FormatAwareCompressor, ExternalizableHelper.IntDecoratedObject, ExternalizableHelper.Shielded, ExternalizableHelper.ShieldedDataOutputStream, ExternalizableHelper.ShieldedInputStream, ExternalizableHelper.ShieldedObjectOutputStream, ExternalizableHelper.ShieldedOutputStream, ExternalizableHelper.SimpleXmlBeanClassCache, ExternalizableHelper.Stats, ExternalizableHelper.XmlBeanClassCache
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected LongArray
m_arrayRefs
Lazily-constructed mapping of identities to references.protected int
m_nType
POF type identifer of this value.protected Object
m_oValue
Deserialized representation of this value.-
Fields inherited from class com.tangosol.util.ExternalizableHelper
BINARY_SIZE, CHUNK_SIZE, CHUNK_THRESHOLD, CONVERTER_FROM_BINARY, CONVERTER_STRIP_INTDECO, CONVERTER_TO_BINARY, DECO_APP_1, DECO_APP_2, DECO_APP_3, DECO_BACKUP, DECO_CUSTOM, DECO_EXPIRY, DECO_ID_MAX, DECO_ID_MIN, DECO_JCACHE, DECO_JCACHE_SYNTHETIC, DECO_MEMCACHED, DECO_PUSHREP, DECO_QUEUE_METADATA, DECO_RSVD_1, DECO_STORE, DECO_TX, DECO_VALUE, DECO_WLS, EMPTY_BINARY_ARRAY, FMT_B_ARRAY, FMT_BIN_DECO, FMT_BIN_EXT_DECO, FMT_BINARY, FMT_BOOLEAN, FMT_BYTE, FMT_DECIMAL, FMT_DOUBLE, FMT_EXT, FMT_FLOAT, FMT_IDO, FMT_INT, FMT_INTEGER, FMT_LONG, FMT_NONE, FMT_NULL, FMT_OBJ_EXT, FMT_OBJ_SER, FMT_OPT, FMT_OPT_DOUBLE, FMT_OPT_INT, FMT_OPT_LONG, FMT_SHORT, FMT_STRING, FMT_UNKNOWN, FMT_XML_BEAN, FMT_XML_SER, FORCE_RESOLVING_STREAMS, LAMBDA_SERIALIZATION, MAX_DECO_HEADER_BYTES, PACKED_INT_SIZE, PACKED_LONG_SIZE, PROPERTY_CONFIG, s_streamfactory, TRINT_DOMAIN_SPAN, TRINT_MAX_VALUE, TRINT_MAX_VARIANCE, USE_POF_STREAMS, USE_XMLBEAN_CLASS_CACHE, XMLBEAN_CLASS_CACHE
-
-
Constructor Summary
Constructors Constructor Description AbstractPofValue(PofValue valueParent, ReadBuffer bufValue, PofContext ctx, int of, int nType)
Construct a PofValue instance wrapping the supplied buffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Binary
applyChanges()
Apply all the changes that were made to this value and return a binary representation of the new value.protected LongArray
ensureReferenceRegistry()
Obtain the registry for identity-reference pairs, creating it if necessary.BigDecimal
getBigDecimal()
Return the BigDecimal which this PofValue represents.BigInteger
getBigInteger()
Return the BigInteger which this PofValue represents.boolean
getBoolean()
Return the boolean which this PofValue represents.boolean[]
getBooleanArray()
Return the boolean[] which this PofValue represents.byte
getByte()
Return the byte which this PofValue represents.byte[]
getByteArray()
Return the byte[] which this PofValue represents.ReadBuffer
getChanges()
Return a buffer containing changes made to this PofValue in the format defined by theBinaryDeltaCompressor
.char
getChar()
Return the char which this PofValue represents.char[]
getCharArray()
Return the char[] which this PofValue represents.Collection
getCollection(Collection coll)
Return the Collection which this PofValue represents.Date
getDate()
Return the Date which this PofValue represents.protected int
getDirtyBytesCount()
Get the estimated number of dirty bytes in this POF value hierarchy.double
getDouble()
Return the double which this PofValue represents.double[]
getDoubleArray()
Return the double[] which this PofValue represents.float
getFloat()
Return the float which this PofValue represents.float[]
getFloatArray()
Return the float[] which this PofValue represents.int
getInt()
Return the int which this PofValue represents.int[]
getIntArray()
Return the int[] which this PofValue represents.long
getLong()
Return the long which this PofValue represents.long[]
getLongArray()
Return the long[] which this PofValue represents.Map
getMap(Map map)
Return the Map which this PofValue represents.Object[]
getObjectArray()
Return the Object[] which this PofValue represents.int
getOffset()
Return the offset of this value from the beginning of POF stream.protected ReadBuffer
getOriginalBuffer()
Get the original buffer the changes should be applied to.PofValue
getParent()
Return the parent of this value.PofContext
getPofContext()
Return the POF context to use for serialization and deserialization.protected int
getPropertyIndex()
PofValue
getRoot()
Return the root of the hierarchy this value belongs to.ReadBuffer
getSerializedValue()
Return this value's serialized form.short
getShort()
Return the short which this PofValue represents.short[]
getShortArray()
Return the short[] which this PofValue represents.int
getSize()
Return the size of the encoded value in bytes.String
getString()
Return the String which this PofValue represents.int
getTypeId()
Obtain the POF type identifier for this value.Object
getValue()
Return the deserialized value which this PofValue represents.Object
getValue(int nType)
Return the deserialized value which this PofValue represents.Object
getValue(Class clz)
Return the deserialized value which this PofValue represents.protected ReadBuffer
getValueBuffer()
Get the raw value buffer.protected void
incrementDirtyBytesCount(int cb)
Increment the counter representing the estimated number of bytes in the original buffer that have been modified.protected void
incrementDirtyValuesCount()
Increment the counter representing the number of values within this POF hierarchy that have been modified.boolean
isDirty()
Return true if this value has been modified, false otherwise.protected boolean
isRoot()
Return true if this instance is the root of the PofValue hierarchy.protected boolean
isUniformEncoded()
Return true if the buffer contains only the value, without the type identifier.protected PofValue
lookupIdentity(int nId)
Look up the specified identity and return the PofValue to which it refers.protected void
registerIdentity(int nId, Object oValue)
Register the passed value with the passed identity.protected void
setDecorations(long nDecoMask, ReadBuffer bufDeco)
Set the decoration mask and decorations for the PofValue.protected void
setDirty()
Set the dirty flag for this value.protected void
setOriginalBuffer(ReadBuffer bufValue)
Set the original buffer the changes should be applied to.protected void
setUniformEncoded()
Specifies that the buffer contains only a value, without a type identifier.void
setValue(Object oValue)
Update this PofValue.-
Methods inherited from class com.tangosol.util.ExternalizableHelper
asBinary, calculatePackedLength, calculatePackedLength, checkObjectInputFilter, checkObjectInputFilter, checkObjectInputFilter, convertUTF, decodeExpiry, decorate, decorate, decorate, decorate, decorate, decorateBinary, encodeExpiry, ensureSerializer, extractIntDecoration, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromBinary, fromByteArray, fromByteArray, getClass, getConfigSerialFilter, getConfigSerialFilterFactory, getDecoration, getDecoration, getDecorations, getDeltaCompressor, getInputStream, getNewObjectInput, getObjectInput, getObjectInputFilter, getObjectOutput, getObjectStreamFactory, getOutputStream, getShieldedOutputStream, getStreamFormat, getUndecorated, getUndecorated, isDecorated, isDecorated, isIntDecorated, isIntDecorated, isPatchCompatible, isPatchCompatible, isResolving, isSerializable, isSerializerCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, isVersionCompatible, loadClass, loadResource, main, makeTrint, readBigDecimal, readBigInteger, readBooleanArray, readBooleanArray, readByteArray, readCharArray, readCharArray, readCollection, readDate, readDoubleArray, readDoubleArray, readExternalizableLite, readExternalizableLite, readFloatArray, readFloatArray, readInt, readInt, readIntArray, readIntArray, readIntArray2d, readLargeBooleanArray, readLargeByteArray, readLargeCharArray, readLargeDoubleArray, readLargeFloatArray, readLargeIntArray, readLargeLongArray, readLargeObjectArray, readLargeStringArray, readLong, readLong, readLongArray, readLongArray, readMap, readMap, readObject, readObject, readObjectArray, readObjectArray, readSafeUTF, readSafeUTF, readSerializable, readSerializable, readStringArray, readStringArray, readTime, readTimestamp, readTrint, readUnsignedTrint, readUTF, readXmlBean, readXmlSerializable, readXmlSerializable, realize, removeIntDecoration, removeIntDecoration, replace, reportIncompatibleSerializers, setObjectStreamFactory, toBinary, toBinary, toBinary, toByteArray, toByteArray, toByteArray, toLiteBinary, toLong, undecorate, undecorate, validateBufferSize, validateLoadArray, validateLoadClass, writeBigDecimal, writeBigInteger, writeBooleanArray, writeByteArray, writeCollection, writeDate, writeDoubleArray, writeExternalizableLite, writeFloatArray, writeInt, writeInt, writeIntArray2d, writeLong, writeLong, writeMap, writeObject, writeSafeUTF, writeSafeUTF, writeSerializable, writeStringArray, writeTime, writeTimestamp, writeTrint, writeTrint, writeUTF, writeXmlBean, writeXmlSerializable
-
Methods inherited from class com.tangosol.util.BitHelper
countBits, countBits, countBits, indexOfLSB, indexOfLSB, indexOfLSB, indexOfMSB, indexOfMSB, indexOfMSB, rotateLeft, rotateLeft, rotateLeft, rotateRight, rotateRight, rotateRight, toBitString, toBitString, toBitString, toBytes, toBytes, toBytes, toBytes, toInt, toInt, toLong
-
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
-
-
-
-
Constructor Detail
-
AbstractPofValue
public AbstractPofValue(PofValue valueParent, ReadBuffer bufValue, PofContext ctx, int of, int nType)
Construct a PofValue instance wrapping the supplied buffer.- Parameters:
valueParent
- parent value within the POF streambufValue
- buffer containing POF representation of this valuectx
- POF context to use when reading or writing propertiesof
- offset of this value from the beginning of POF streamnType
- POF type identifier for this value
-
-
Method Detail
-
getTypeId
public int getTypeId()
Obtain the POF type identifier for this value.
-
getRoot
public PofValue getRoot()
Return the root of the hierarchy this value belongs to.
-
getParent
public PofValue getParent()
Return the parent of this value.
-
getValue
public Object getValue()
Return the deserialized value which this PofValue represents.Note: For primitive types such as int or boolean, the POF type is not stored in the POF stream. Therefore, for primitive types, the type or class must be explicitly specified via
PofValue.getValue(int)
orPofValue.getValue(Class)
.
-
getValue
public Object getValue(Class clz)
Return the deserialized value which this PofValue represents.Note: For primitive types such as int or boolean, the POF type is not stored in the POF stream. Therefore, for primitive types, the clz parameter must not be null.
-
getValue
public Object getValue(int nType)
Return the deserialized value which this PofValue represents.Note: For primitive types such as int or boolean, the POF type is not stored in the POF stream. Therefore, for primitive types, the type must be explicitly specified with the nType parameter.
- Specified by:
getValue
in interfacePofValue
- Parameters:
nType
- the required POF type of the returned value orPofConstants.T_UNKNOWN
if the type is to be inferred from the serialized state- Returns:
- the deserialized value
-
setValue
public void setValue(Object oValue)
Update this PofValue.The changes made using this method will be immediately reflected in the result of
PofValue.getValue()
method, but will not be applied to the underlying POF stream until thePofValue.applyChanges()
method is invoked on the root PofValue.
-
applyChanges
public Binary applyChanges()
Apply all the changes that were made to this value and return a binary representation of the new value.Any format prefixes and/or decorations that were present in the original buffer this value orginated from will be preserved.
Note: this method can only be called on the root PofValue.
- Specified by:
applyChanges
in interfacePofValue
- Returns:
- new Binary object that contains modified PofValue
-
getChanges
public ReadBuffer getChanges()
Return a buffer containing changes made to this PofValue in the format defined by theBinaryDeltaCompressor
.Note: this method can only be called on the root PofValue
- Specified by:
getChanges
in interfacePofValue
- Returns:
- a buffer containing changes made to this PofValue
-
getBoolean
public boolean getBoolean()
Return the boolean which this PofValue represents.- Specified by:
getBoolean
in interfacePofValue
- Returns:
- the boolean value
-
getByte
public byte getByte()
Return the byte which this PofValue represents.
-
getChar
public char getChar()
Return the char which this PofValue represents.
-
getShort
public short getShort()
Return the short which this PofValue represents.
-
getInt
public int getInt()
Return the int which this PofValue represents.
-
getLong
public long getLong()
Return the long which this PofValue represents.
-
getFloat
public float getFloat()
Return the float which this PofValue represents.
-
getDouble
public double getDouble()
Return the double which this PofValue represents.
-
getBooleanArray
public boolean[] getBooleanArray()
Return the boolean[] which this PofValue represents.- Specified by:
getBooleanArray
in interfacePofValue
- Returns:
- the boolean[] value
-
getByteArray
public byte[] getByteArray()
Return the byte[] which this PofValue represents.- Specified by:
getByteArray
in interfacePofValue
- Returns:
- the byte[] value
-
getCharArray
public char[] getCharArray()
Return the char[] which this PofValue represents.- Specified by:
getCharArray
in interfacePofValue
- Returns:
- the char[] value
-
getShortArray
public short[] getShortArray()
Return the short[] which this PofValue represents.- Specified by:
getShortArray
in interfacePofValue
- Returns:
- the short[] value
-
getIntArray
public int[] getIntArray()
Return the int[] which this PofValue represents.- Specified by:
getIntArray
in interfacePofValue
- Returns:
- the int[] value
-
getLongArray
public long[] getLongArray()
Return the long[] which this PofValue represents.- Specified by:
getLongArray
in interfacePofValue
- Returns:
- the long[] value
-
getFloatArray
public float[] getFloatArray()
Return the float[] which this PofValue represents.- Specified by:
getFloatArray
in interfacePofValue
- Returns:
- the float[] value
-
getDoubleArray
public double[] getDoubleArray()
Return the double[] which this PofValue represents.- Specified by:
getDoubleArray
in interfacePofValue
- Returns:
- the double[] value
-
getBigInteger
public BigInteger getBigInteger()
Return the BigInteger which this PofValue represents.- Specified by:
getBigInteger
in interfacePofValue
- Returns:
- the BigInteger value
-
getBigDecimal
public BigDecimal getBigDecimal()
Return the BigDecimal which this PofValue represents.- Specified by:
getBigDecimal
in interfacePofValue
- Returns:
- the BigDecimal value
-
getString
public String getString()
Return the String which this PofValue represents.
-
getDate
public Date getDate()
Return the Date which this PofValue represents.
-
getObjectArray
public Object[] getObjectArray()
Return the Object[] which this PofValue represents.- Specified by:
getObjectArray
in interfacePofValue
- Returns:
- the Object[] value
-
getCollection
public Collection getCollection(Collection coll)
Return the Collection which this PofValue represents.- Specified by:
getCollection
in interfacePofValue
- Parameters:
coll
- the optional Collection to use to store the values- Returns:
- the Collection value
-
getPofContext
public PofContext getPofContext()
Return the POF context to use for serialization and deserialization.- Returns:
- the POF context
-
getOffset
public int getOffset()
Return the offset of this value from the beginning of POF stream.- Returns:
- the offset of this value from the beginning of POF stream
-
getSize
public int getSize()
Return the size of the encoded value in bytes.- Returns:
- the size of the encoded value
-
isDirty
public boolean isDirty()
Return true if this value has been modified, false otherwise.- Returns:
- true if this value has been modified, false otherwise
-
setDirty
protected void setDirty()
Set the dirty flag for this value.
-
getSerializedValue
public ReadBuffer getSerializedValue()
Return this value's serialized form.- Returns:
- this value's serialized form
-
getPropertyIndex
protected int getPropertyIndex()
-
getOriginalBuffer
protected ReadBuffer getOriginalBuffer()
Get the original buffer the changes should be applied to.- Returns:
- buffer containing the original value
-
setOriginalBuffer
protected void setOriginalBuffer(ReadBuffer bufValue)
Set the original buffer the changes should be applied to.- Parameters:
bufValue
- buffer containing the original value
-
ensureReferenceRegistry
protected LongArray ensureReferenceRegistry()
Obtain the registry for identity-reference pairs, creating it if necessary.- Returns:
- the identity-reference registry, never null
-
registerIdentity
protected void registerIdentity(int nId, Object oValue)
Register the passed value with the passed identity.- Parameters:
nId
- the identity within the POF stream of the objectoValue
- the object to associate with the passed identity- Throws:
IllegalArgumentException
- if the specified identity is already registered with a different object
-
lookupIdentity
protected PofValue lookupIdentity(int nId) throws IOException
Look up the specified identity and return the PofValue to which it refers.- Parameters:
nId
- the identity- Returns:
- the object registered under that identity
- Throws:
IOException
- if the requested identity is not registered
-
getValueBuffer
protected ReadBuffer getValueBuffer()
Get the raw value buffer.- Returns:
- buffer containing the raw value
-
setDecorations
protected void setDecorations(long nDecoMask, ReadBuffer bufDeco)
Set the decoration mask and decorations for the PofValue.- Parameters:
nDecoMask
- decoration identifiers bit maskbufDeco
- buffer containing the decorations
-
isRoot
protected boolean isRoot()
Return true if this instance is the root of the PofValue hierarchy.- Returns:
- true if this is the root value
-
isUniformEncoded
protected boolean isUniformEncoded()
Return true if the buffer contains only the value, without the type identifier.- Returns:
- true if the buffer contains only the value
-
setUniformEncoded
protected void setUniformEncoded()
Specifies that the buffer contains only a value, without a type identifier.
-
getDirtyBytesCount
protected int getDirtyBytesCount()
Get the estimated number of dirty bytes in this POF value hierarchy.- Returns:
- the number of dirty bytes
-
incrementDirtyValuesCount
protected void incrementDirtyValuesCount()
Increment the counter representing the number of values within this POF hierarchy that have been modified.
-
incrementDirtyBytesCount
protected void incrementDirtyBytesCount(int cb)
Increment the counter representing the estimated number of bytes in the original buffer that have been modified.- Parameters:
cb
- the number of bytes to increment counter for
-
-