Class Reference

  • All Implemented Interfaces:
    Value

    class Reference
    extends java.lang.Object
    implements Value
    The Reference object represents an object that is used to provide a reference to an already instantiated value. This is what is used if there is a cycle in the object graph. The getValue method of this object will simply return the object instance that was previously created.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class type
      This is the type of the object that this references.
      private java.lang.Object value
      This is the object instance that has already be created.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reference​(java.lang.Object value, java.lang.Class type)
      Constructor for the Reference object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLength()
      This returns zero as this is a reference and will typically not be used to instantiate anything.
      java.lang.Class getType()
      This returns the type for the object that this references.
      java.lang.Object getValue()
      This is used to acquire a reference to the instance that is taken from the created object graph.
      boolean isReference()
      This always returns true for this object.
      void setValue​(java.lang.Object value)
      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 Detail

      • value

        private java.lang.Object value
        This is the object instance that has already be created.
      • type

        private java.lang.Class type
        This is the type of the object that this references.
    • Constructor Detail

      • Reference

        public Reference​(java.lang.Object value,
                         java.lang.Class type)
        Constructor for the Reference object. This is used to create a value that will produce the specified value when the getValue method is invoked.
        Parameters:
        value - the value for the reference this represents
        type - this is the type value for the instance
    • Method Detail

      • getValue

        public java.lang.Object getValue()
        This is used to acquire a reference to the instance that is taken from the created object graph. This enables any cycles in the graph to be reestablished from the persisted XML.
        Specified by:
        getValue in interface Value
        Returns:
        this returns a reference to the created instance
      • setValue

        public void setValue​(java.lang.Object value)
        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. Typically this will not be set as this represents a reference value.
        Specified by:
        setValue in interface Value
        Parameters:
        value - this is the value to insert as the type
      • getType

        public java.lang.Class getType()
        This returns the type for the object that this references. This will basically return the getClass class from the referenced instance. This is used to ensure that the type this represents is compatible to the object field.
        Specified by:
        getType in interface Value
        Returns:
        this returns the type for the referenced object
      • getLength

        public int getLength()
        This returns zero as this is a reference and will typically not be used to instantiate anything. If the reference is an an array then this can not be used to instantiate it.
        Specified by:
        getLength in interface Value
        Returns:
        this returns zero regardless of the value type
      • isReference

        public boolean isReference()
        This always returns true for this object. This indicates to the deserialization process that there should be not further deserialization of the object from the XML source stream.
        Specified by:
        isReference in interface Value
        Returns:
        because this is a reference this is always true