Class AbstractPofValue

    • Field Detail

      • m_arrayRefs

        protected LongArray m_arrayRefs
        Lazily-constructed mapping of identities to references.
      • m_nType

        protected int m_nType
        POF type identifer of this value.
      • m_oValue

        protected Object m_oValue
        Deserialized representation of this value.
    • 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 stream
        bufValue - buffer containing POF representation of this value
        ctx - POF context to use when reading or writing properties
        of - offset of this value from the beginning of POF stream
        nType - POF type identifier for this value
    • Method Detail

      • getTypeId

        public int getTypeId()
        Obtain the POF type identifier for this value.
        Specified by:
        getTypeId in interface PofValue
        Returns:
        POF type identifier for this value
      • getRoot

        public PofValue getRoot()
        Return the root of the hierarchy this value belongs to.
        Specified by:
        getRoot in interface PofValue
        Returns:
        the root value
      • getParent

        public PofValue getParent()
        Return the parent of this value.
        Specified by:
        getParent in interface PofValue
        Returns:
        the parent value, or null if this is root 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) or PofValue.getValue(Class).

        Specified by:
        getValue in interface PofValue
        Returns:
        the deserialized value
      • 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.

        Specified by:
        getValue in interface PofValue
        Parameters:
        clz - the required class of the returned value or null if the class is to be inferred from the serialized state
        Returns:
        the deserialized value
      • 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 interface PofValue
        Parameters:
        nType - the required POF type of the returned value or PofConstants.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 the PofValue.applyChanges() method is invoked on the root PofValue.

        Specified by:
        setValue in interface PofValue
        Parameters:
        oValue - new deserialized value for this 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 interface PofValue
        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 the BinaryDeltaCompressor.

        Note: this method can only be called on the root PofValue

        Specified by:
        getChanges in interface PofValue
        Returns:
        a buffer containing changes made to this PofValue
      • getBoolean

        public boolean getBoolean()
        Return the boolean which this PofValue represents.
        Specified by:
        getBoolean in interface PofValue
        Returns:
        the boolean value
      • getByte

        public byte getByte()
        Return the byte which this PofValue represents.
        Specified by:
        getByte in interface PofValue
        Returns:
        the byte value
      • getChar

        public char getChar()
        Return the char which this PofValue represents.
        Specified by:
        getChar in interface PofValue
        Returns:
        the char value
      • getShort

        public short getShort()
        Return the short which this PofValue represents.
        Specified by:
        getShort in interface PofValue
        Returns:
        the short value
      • getInt

        public int getInt()
        Return the int which this PofValue represents.
        Specified by:
        getInt in interface PofValue
        Returns:
        the int value
      • getLong

        public long getLong()
        Return the long which this PofValue represents.
        Specified by:
        getLong in interface PofValue
        Returns:
        the long value
      • getFloat

        public float getFloat()
        Return the float which this PofValue represents.
        Specified by:
        getFloat in interface PofValue
        Returns:
        the float value
      • getDouble

        public double getDouble()
        Return the double which this PofValue represents.
        Specified by:
        getDouble in interface PofValue
        Returns:
        the double value
      • getBooleanArray

        public boolean[] getBooleanArray()
        Return the boolean[] which this PofValue represents.
        Specified by:
        getBooleanArray in interface PofValue
        Returns:
        the boolean[] value
      • getByteArray

        public byte[] getByteArray()
        Return the byte[] which this PofValue represents.
        Specified by:
        getByteArray in interface PofValue
        Returns:
        the byte[] value
      • getCharArray

        public char[] getCharArray()
        Return the char[] which this PofValue represents.
        Specified by:
        getCharArray in interface PofValue
        Returns:
        the char[] value
      • getShortArray

        public short[] getShortArray()
        Return the short[] which this PofValue represents.
        Specified by:
        getShortArray in interface PofValue
        Returns:
        the short[] value
      • getIntArray

        public int[] getIntArray()
        Return the int[] which this PofValue represents.
        Specified by:
        getIntArray in interface PofValue
        Returns:
        the int[] value
      • getLongArray

        public long[] getLongArray()
        Return the long[] which this PofValue represents.
        Specified by:
        getLongArray in interface PofValue
        Returns:
        the long[] value
      • getFloatArray

        public float[] getFloatArray()
        Return the float[] which this PofValue represents.
        Specified by:
        getFloatArray in interface PofValue
        Returns:
        the float[] value
      • getDoubleArray

        public double[] getDoubleArray()
        Return the double[] which this PofValue represents.
        Specified by:
        getDoubleArray in interface PofValue
        Returns:
        the double[] value
      • getBigInteger

        public BigInteger getBigInteger()
        Return the BigInteger which this PofValue represents.
        Specified by:
        getBigInteger in interface PofValue
        Returns:
        the BigInteger value
      • getBigDecimal

        public BigDecimal getBigDecimal()
        Return the BigDecimal which this PofValue represents.
        Specified by:
        getBigDecimal in interface PofValue
        Returns:
        the BigDecimal value
      • getString

        public String getString()
        Return the String which this PofValue represents.
        Specified by:
        getString in interface PofValue
        Returns:
        the String value
      • getDate

        public Date getDate()
        Return the Date which this PofValue represents.
        Specified by:
        getDate in interface PofValue
        Returns:
        the Date value
      • getObjectArray

        public Object[] getObjectArray()
        Return the Object[] which this PofValue represents.
        Specified by:
        getObjectArray in interface PofValue
        Returns:
        the Object[] value
      • getCollection

        public Collection getCollection​(Collection coll)
        Return the Collection which this PofValue represents.
        Specified by:
        getCollection in interface PofValue
        Parameters:
        coll - the optional Collection to use to store the values
        Returns:
        the Collection value
      • getMap

        public Map getMap​(Map map)
        Return the Map which this PofValue represents.
        Specified by:
        getMap in interface PofValue
        Parameters:
        map - the optional Map to use to store the values
        Returns:
        the Map 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 object
        oValue - 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 mask
        bufDeco - 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