Class Reference

java.lang.Object
org.simpleframework.xml.convert.Reference
All Implemented Interfaces:
Value

class Reference extends Object implements Value
The Reference object represents a value that holds an object instance. If an object instance is to be provided from a Strategy implementation it must be wrapped in a value object. The value object can then provide the details of the instance and the actual object instance to the serializer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Class
    This is the actual type of the reference that is represented.
    private Object
    This represents the object instance that this represents.
    private Value
    This represents the original value returned from a strategy.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Reference(Value value, Object data, Class actual)
    Constructor for a Reference object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This will return the length of an array reference.
    This is the type of the object instance this represents.
    This returns the actual object instance that is held by this reference object.
    boolean
    This will always return true as this Value object will always contain an object instance.
    void
    This is used to set the value of the object.

    Methods inherited from class java.lang.Object

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

    • value

      private Value value
      This represents the original value returned from a strategy.
    • data

      private Object data
      This represents the object instance that this represents.
    • actual

      private Class actual
      This is the actual type of the reference that is represented.
  • Constructor Details

    • Reference

      public Reference(Value value, Object data, Class actual)
      Constructor for a Reference object. To create this a value and an object instance is required. The value provided may be null, but the instance should be a valid object instance to be used by the serializer.
      Parameters:
      value - this is the original value from a strategy
      data - this is the object instance that is wrapped
      actual - this is the overriding type of the reference
  • Method Details

    • getLength

      public int getLength()
      This will return the length of an array reference. Because the value will represent the value itself the length is never used, as no instance needs to be created.
      Specified by:
      getLength in interface Value
      Returns:
      this will always return zero for a reference
    • 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
    • getValue

      public Object getValue()
      This returns the actual object instance that is held by this reference object.
      Specified by:
      getValue in interface Value
      Returns:
      an instance of the type this object represents
    • isReference

      public boolean isReference()
      This will always return true as this Value object will always contain an object instance. Returning true from this method tells the serializer that there is no need to actually perform any further deserialization.
      Specified by:
      isReference in interface Value
      Returns:
      this always returns true as this will be a reference
    • setValue

      public void setValue(Object data)
      This is used to set the value of the object. If the internal Value is not null then the internal value will have the instance set also.
      Specified by:
      setValue in interface Value
      Parameters:
      data - this is the object instance that is to be set