Package org.simpleframework.xml.core
Class ParameterContact<T extends java.lang.annotation.Annotation>
- java.lang.Object
-
- org.simpleframework.xml.core.ParameterContact<T>
-
- Direct Known Subclasses:
AttributeParameter.Contact
,ElementArrayParameter.Contact
,ElementListParameter.Contact
,ElementListUnionParameter.Contact
,ElementMapParameter.Contact
,ElementMapUnionParameter.Contact
,ElementParameter.Contact
,ElementUnionParameter.Contact
,TextParameter.Contact
abstract class ParameterContact<T extends java.lang.annotation.Annotation> extends java.lang.Object implements Contact
TheParameterContact
object is used to represent a contact that is provided so that aLabel
can be used to determine a consistent name for the parameter. Unlike field and method contacts this is essentially an adapter that is used so that the parameter name can be determined in a similar way to a method or field.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.reflect.Constructor
factory
This is the constructor the parameter was declared within.protected int
index
This is the index of the parameter within the constructor.protected T
label
This is the annotation used to label the parameter.protected java.lang.annotation.Annotation[]
labels
This is used to hold the annotations for this parameter.protected java.lang.Class
owner
This represents the class that this parameter was declared in.
-
Constructor Summary
Constructors Constructor Description ParameterContact(T label, java.lang.reflect.Constructor factory, int index)
Constructor for theParameterContact
object.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.Object source)
This is used to get the value from the specified object using the point of contact.java.lang.annotation.Annotation
getAnnotation()
This is the annotation associated with the point of contact.<A extends java.lang.annotation.Annotation>
AgetAnnotation(java.lang.Class<A> type)
This is the annotation associated with the point of contact.java.lang.Class
getDeclaringClass()
This is the class that declares the contact.java.lang.Class
getDependent()
This provides the dependent class for the contact.java.lang.Class[]
getDependents()
This provides the dependent classes for the contact.abstract java.lang.String
getName()
This represents the name of the parameter.java.lang.Class
getType()
This will provide the contact type.boolean
isReadOnly()
This is used to determine if the annotated contact is for a read only variable.void
set(java.lang.Object source, java.lang.Object value)
This is used to set the value on the specified object through this contact.java.lang.String
toString()
This is used to provide a textual representation of the parameter.
-
-
-
Field Detail
-
labels
protected final java.lang.annotation.Annotation[] labels
This is used to hold the annotations for this parameter.
-
factory
protected final java.lang.reflect.Constructor factory
This is the constructor the parameter was declared within.
-
owner
protected final java.lang.Class owner
This represents the class that this parameter was declared in.
-
index
protected final int index
This is the index of the parameter within the constructor.
-
label
protected final T extends java.lang.annotation.Annotation label
This is the annotation used to label the parameter.
-
-
Constructor Detail
-
ParameterContact
public ParameterContact(T label, java.lang.reflect.Constructor factory, int index)
Constructor for theParameterContact
object. This is used to create a contact that can be used to determine a consistent name for the parameter. It requires the annotation, the constructor, and the parameter declaration index.- Parameters:
label
- this is the annotation used for the parameterfactory
- this is the constructor that is representedindex
- this is the index for the parameter
-
-
Method Detail
-
getAnnotation
public java.lang.annotation.Annotation getAnnotation()
This is the annotation associated with the point of contact. This will be an XML annotation that describes how the contact should be serialized and deserialized from the object.- Specified by:
getAnnotation
in interfaceContact
- Returns:
- this provides the annotation associated with this
-
getType
public java.lang.Class getType()
This will provide the contact type. The contact type is the class that is to be set and get on the object. Typically the type will be a serializable object or a primitive type.
-
getDependent
public java.lang.Class getDependent()
This provides the dependent class for the contact. This will typically represent a generic type for the actual type. For contacts that use aCollection
type this will be the generic type parameter for that collection.- Specified by:
getDependent
in interfaceContact
- Returns:
- this returns the dependent type for the contact
-
getDependents
public java.lang.Class[] getDependents()
This provides the dependent classes for the contact. This will typically represent a generic types for the actual type. For contacts that use aMap
type this will be the generic type parameter for that map type declaration.- Specified by:
getDependents
in interfaceContact
- Returns:
- this returns the dependent types for the contact
-
getDeclaringClass
public java.lang.Class getDeclaringClass()
This is the class that declares the contact. The declaring class is where the parameter has been defined. Typically this will not be a class rather than an interface.- Specified by:
getDeclaringClass
in interfaceContact
- Returns:
- the class this parameter is declared within
-
get
public java.lang.Object get(java.lang.Object source)
This is used to get the value from the specified object using the point of contact. Typically the value is retrieved from the specified object by invoking a get method of by acquiring the value from a field within the specified object.
-
set
public void set(java.lang.Object source, java.lang.Object value)
This is used to set the value on the specified object through this contact. Depending on the type of contact this will set the value given, typically this will be done by invoking a method or setting the value on the object field.
-
getAnnotation
public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> type)
This is the annotation associated with the point of contact. This will be an XML annotation that describes how the contact should be serialized and deserialized from the object.- Specified by:
getAnnotation
in interfaceType
- Parameters:
type
- this is the type of the annotation to acquire- Returns:
- this provides the annotation associated with this
-
isReadOnly
public boolean isReadOnly()
This is used to determine if the annotated contact is for a read only variable. A read only variable is a field that can be set from within the constructor such as a blank final variable. It can also be a method with no set counterpart.- Specified by:
isReadOnly
in interfaceContact
- Returns:
- this returns true if the contact is a constant one
-
toString
public java.lang.String toString()
This is used to provide a textual representation of the parameter. Providing a string describing the parameter is useful for debugging and for exception messages.
-
getName
public abstract java.lang.String getName()
This represents the name of the parameter. Because the name of the parameter does not exist at runtime the name must be taken directly from the annotation and the parameter type. Each XML annotation must provide their own unique way of providing a name for the parameter contact.
-
-