Package org.simpleframework.xml.strategy
Class Reference
- java.lang.Object
-
- org.simpleframework.xml.strategy.Reference
-
- All Implemented Interfaces:
Value
class Reference extends java.lang.Object implements Value
TheReference
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. ThegetValue
method of this object will simply return the object instance that was previously created.
-
-
Constructor Summary
Constructors Constructor Description Reference(java.lang.Object value, java.lang.Class type)
Constructor for theReference
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.
-
-
-
Constructor Detail
-
Reference
public Reference(java.lang.Object value, java.lang.Class type)
Constructor for theReference
object. This is used to create a value that will produce the specified value when thegetValue
method is invoked.- Parameters:
value
- the value for the reference this representstype
- 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.
-
setValue
public void setValue(java.lang.Object value)
This method is used set the value within this object. Once this is set then thegetValue
method will return the object that has been provided. Typically this will not be set as this represents a reference value.
-
getType
public java.lang.Class getType()
This returns the type for the object that this references. This will basically return thegetClass
class from the referenced instance. This is used to ensure that the type this represents is compatible to the object field.
-
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.
-
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 interfaceValue
- Returns:
- because this is a reference this is always true
-
-