Class OverrideValue

java.lang.Object
org.simpleframework.xml.core.OverrideValue
All Implemented Interfaces:
Value

class OverrideValue extends Object implements Value
The OverrideValue is used to represent a value that contains an override type. Providing a value in this way ensures that should an XML element not contain any data representing the type of object then the type data can be provided.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Class
    This is the type that is used to represent the value.
    private final Value
    This is the value that is used internally for this value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OverrideValue(Value value, Class type)
    Constructor for the OverrideValue object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This returns the length of the array that is to be allocated.
    This is the type of the object instance this represents.
    This method is used to acquire an instance of the type that is defined by this object.
    boolean
    This will return true if the object represents a reference.
    void
    setValue(Object instance)
    This method is used set the value within this object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • value

      private final Value value
      This is the value that is used internally for this value.
    • type

      private final Class type
      This is the type that is used to represent the value.
  • Constructor Details

    • OverrideValue

      public OverrideValue(Value value, Class type)
      Constructor for the OverrideValue object. This will delegate to an internal value instance but will provide the declared type when requested.
      Parameters:
      value - this is the value that this will delegate to
      type - this is the override type for this value
  • Method Details

    • getValue

      public Object getValue()
      This method is used to acquire an instance of the type that is defined by this object. If the value has not been set then this method will return null if this is not a reference.
      Specified by:
      getValue in interface Value
      Returns:
      an instance of the type this object represents
    • setValue

      public void setValue(Object instance)
      This method is used set the value within this object. Once this is set then the getValue method will return the object that has been provided for consistency.
      Specified by:
      setValue in interface Value
      Parameters:
      instance - this is the value to insert as the type
    • getType

      public Class getType()
      This is the type of the object instance this represents. The type returned by this is used to instantiate an object which will be set on this value and the internal graph maintained.
      Specified by:
      getType in interface Value
      Returns:
      the type of the object that must be instantiated
    • getLength

      public int getLength()
      This returns the length of the array that is to be allocated. If this value does not represent an array then this should return zero to indicate that it is not an array object.
      Specified by:
      getLength in interface Value
      Returns:
      this returns the number of elements for the array
    • isReference

      public boolean isReference()
      This will return true if the object represents a reference. A reference will provide a valid instance when this objects getter is invoked. A valid instance can be a null.
      Specified by:
      isReference in interface Value
      Returns:
      this returns true if this represents a reference