com.tangosol.io.pof.reflect.PofValue Maven / Gradle / Ivy
Show all versions of coherence Show documentation
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
package com.tangosol.io.pof.reflect;
import com.tangosol.io.ReadBuffer;
import com.tangosol.io.pof.PofConstants;
import com.tangosol.io.pof.PofContext;
import com.tangosol.util.Binary;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
/**
* PofValue represents the POF data structure in a POF stream, or any
* sub-structure or value thereof.
*
* @see PofValueParser#parse(ReadBuffer, PofContext)
*
* @author as 2009.02.12
* @since Coherence 3.5
*/
public interface PofValue
{
/**
* Obtain the POF type identifier for this value.
*
* @return POF type identifier for this value
*/
public int getTypeId();
/**
* Return the root of the hierarchy this value belongs to.
*
* @return the root value
*/
public PofValue getRoot();
/**
* Return the parent of this value.
*
* @return the parent value, or null if this is root value
*/
public PofValue getParent();
/**
* Locate a child PofValue contained within this PofValue.
*
* Note: the returned PofValue could represent a non-existent (null) value.
*
* @param nIndex index of the child value
*
* @return the child PofValue
*
* @throws PofNavigationException if this value is a "terminal" or the child
* value cannot be located for any other reason
*/
public PofValue getChild(int nIndex);
/**
* 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 {@link #getValue(int)}
* or {@link #getValue(Class)}.
*
* @return the deserialized value
*/
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
* clz parameter must not be null.
*
* @param clz the required class of the returned value or null if the class
* is to be inferred from the serialized state
*
* @return the deserialized value
*
* @throws ClassCastException if the value is incompatible with the
* specified class
*/
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
* type must be explicitly specified with the nType parameter.
*
* @param nType the required POF type of the returned value or
* {@link PofConstants#T_UNKNOWN} if the type is to be
* inferred from the serialized state
*
* @return the deserialized value
*
* @throws ClassCastException if the value is incompatible with the
* specified type
*/
public Object getValue(int nType);
/**
* Update this PofValue.
*
* The changes made using this method will be immediately reflected in the
* result of {@link #getValue()} method, but will not be applied to the
* underlying POF stream until the {@link #applyChanges()} method is invoked
* on the root PofValue.
*
* @param oValue new deserialized value for this PofValue
*/
public void setValue(Object oValue);
/**
* 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.
*
* @return new Binary object that contains modified PofValue
*
* @throws UnsupportedOperationException if called on a non-root PofValue
*/
public Binary applyChanges();
/**
* Return a buffer containing changes made to this PofValue in the format
* defined by the {@link com.tangosol.io.BinaryDeltaCompressor}.
*
* Note: this method can only be called on the root PofValue
*
* @return a buffer containing changes made to this PofValue
*
* @throws UnsupportedOperationException if called on a non-root PofValue
*/
public ReadBuffer getChanges();
/**
* Return the boolean which this PofValue represents.
*
* @return the boolean value
*/
public boolean getBoolean();
/**
* Return the byte which this PofValue represents.
*
* @return the byte value
*/
public byte getByte();
/**
* Return the char which this PofValue represents.
*
* @return the char value
*/
public char getChar();
/**
* Return the short which this PofValue represents.
*
* @return the short value
*/
public short getShort();
/**
* Return the int which this PofValue represents.
*
* @return the int value
*/
public int getInt();
/**
* Return the long which this PofValue represents.
*
* @return the long value
*/
public long getLong();
/**
* Return the float which this PofValue represents.
*
* @return the float value
*/
public float getFloat();
/**
* Return the double which this PofValue represents.
*
* @return the double value
*/
public double getDouble();
/**
* Return the boolean[] which this PofValue represents.
*
* @return the boolean[] value
*/
public boolean[] getBooleanArray();
/**
* Return the byte[] which this PofValue represents.
*
* @return the byte[] value
*/
public byte[] getByteArray();
/**
* Return the char[] which this PofValue represents.
*
* @return the char[] value
*/
public char[] getCharArray();
/**
* Return the short[] which this PofValue represents.
*
* @return the short[] value
*/
public short[] getShortArray();
/**
* Return the int[] which this PofValue represents.
*
* @return the int[] value
*/
public int[] getIntArray();
/**
* Return the long[] which this PofValue represents.
*
* @return the long[] value
*/
public long[] getLongArray();
/**
* Return the float[] which this PofValue represents.
*
* @return the float[] value
*/
public float[] getFloatArray();
/**
* Return the double[] which this PofValue represents.
*
* @return the double[] value
*/
public double[] getDoubleArray();
/**
* Return the BigInteger which this PofValue represents.
*
* @return the BigInteger value
*/
public BigInteger getBigInteger();
/**
* Return the BigDecimal which this PofValue represents.
*
* @return the BigDecimal value
*/
public BigDecimal getBigDecimal();
/**
* Return the String which this PofValue represents.
*
* @return the String value
*/
public String getString();
/**
* Return the Date which this PofValue represents.
*
* @return the Date value
*/
public Date getDate();
/**
* Return the Object[] which this PofValue represents.
*
* @return the Object[] value
*/
public Object[] getObjectArray();
/**
* Return the Collection which this PofValue represents.
*
* @param coll the optional Collection to use to store the values
*
* @return the Collection value
*/
public Collection getCollection(Collection coll);
/**
* Return the Map which this PofValue represents.
*
* @param map the optional Map to use to store the values
*
* @return the Map value
*/
public Map getMap(Map map);
}