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
TheReferenceobject 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. ThegetValuemethod 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 theReferenceobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetLength()This returns zero as this is a reference and will typically not be used to instantiate anything.java.lang.ClassgetType()This returns the type for the object that this references.java.lang.ObjectgetValue()This is used to acquire a reference to the instance that is taken from the created object graph.booleanisReference()This always returns true for this object.voidsetValue(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 theReferenceobject. This is used to create a value that will produce the specified value when thegetValuemethod 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 thegetValuemethod 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 thegetClassclass 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:
isReferencein interfaceValue- Returns:
- because this is a reference this is always true
-
-