Package org.simpleframework.xml.core
Class MethodContact
- java.lang.Object
-
- org.simpleframework.xml.core.MethodContact
-
class MethodContact extends java.lang.Object implements Contact
TheMethodContact
object is acts as a contact that can set and get data to and from an object using methods. This requires a get method and a set method that share the same class type for the return and parameter respectively.- See Also:
MethodScanner
-
-
Field Summary
Fields Modifier and Type Field Description private MethodPart
get
This is the get method which is used to get the value.private java.lang.Class
item
This is the dependent type as taken from the get method.private java.lang.Class[]
items
This is the dependent types as taken from the get method.private java.lang.annotation.Annotation
label
This is the label that marks both the set and get methods.private java.lang.String
name
This represents the name of the method for this contact.private java.lang.Class
owner
This represents the declaring class for this method.private MethodPart
set
This is the set method which is used to set the value.private java.lang.Class
type
This is the type associated with this point of contact.
-
Constructor Summary
Constructors Constructor Description MethodContact(MethodPart get)
Constructor for theMethodContact
object.MethodContact(MethodPart get, MethodPart set)
Constructor for theMethodContact
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.Object source)
This is used to get the specified value on the provided object.java.lang.annotation.Annotation
getAnnotation()
This is the annotation associated with the point of contact.<T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<T> 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.java.lang.String
getName()
This is used to acquire the name of the method.MethodPart
getRead()
This returns the get part of the method.java.lang.Class
getType()
This will provide the contact type.MethodPart
getWrite()
This returns the set part of the method.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 specified value on the provided object.java.lang.String
toString()
This is used to describe the contact as it exists within the owning class.
-
-
-
Field Detail
-
label
private java.lang.annotation.Annotation label
This is the label that marks both the set and get methods.
-
set
private MethodPart set
This is the set method which is used to set the value.
-
get
private MethodPart get
This is the get method which is used to get the value.
-
items
private java.lang.Class[] items
This is the dependent types as taken from the get method.
-
owner
private java.lang.Class owner
This represents the declaring class for this method.
-
item
private java.lang.Class item
This is the dependent type as taken from the get method.
-
type
private java.lang.Class type
This is the type associated with this point of contact.
-
name
private java.lang.String name
This represents the name of the method for this contact.
-
-
Constructor Detail
-
MethodContact
public MethodContact(MethodPart get)
Constructor for theMethodContact
object. This is used to compose a point of contact that makes use of a get and set method on a class. The specified methods will be invoked during the serialization process to get and set values.- Parameters:
get
- this forms the get method for the object
-
MethodContact
public MethodContact(MethodPart get, MethodPart set)
Constructor for theMethodContact
object. This is used to compose a point of contact that makes use of a get and set method on a class. The specified methods will be invoked during the serialization process to get and set values.- Parameters:
get
- this forms the get method for the objectset
- this forms the get method for the object
-
-
Method Detail
-
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
-
getRead
public MethodPart getRead()
This returns the get part of the method. Acquiring separate parts of the method ensures that method parts can be inherited easily between types as overriding either part of a property.- Returns:
- this returns the get part of the method contact
-
getWrite
public MethodPart getWrite()
This returns the set part of the method. Acquiring separate parts of the method ensures that method parts can be inherited easily between types as overriding either part of a property.- Returns:
- this returns the set part of the method contact
-
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
-
getAnnotation
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> 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
-
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. This represents the return type for the get and the parameter for the set.
-
getDependent
public java.lang.Class getDependent()
This provides the dependent class for the contact. This will actually 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 type for the contact
-
getDeclaringClass
public java.lang.Class getDeclaringClass()
This is the class that declares the contact. The declaring class is where the method represented has been defined. This will typically be a class rather than an interface.- Specified by:
getDeclaringClass
in interfaceContact
- Returns:
- this returns the class the contact is declared within
-
getName
public java.lang.String getName()
This is used to acquire the name of the method. This returns the name of the method without the get, set or is prefix that represents the Java Bean method type. Also this decapitalizes the resulting name. The result is used to represent the XML attribute of element within the class schema represented.
-
set
public void set(java.lang.Object source, java.lang.Object value) throws java.lang.Exception
This is used to set the specified value on the provided object. The value provided must be an instance of the contact class so that it can be set without a runtime class compatibility error.
-
get
public java.lang.Object get(java.lang.Object source) throws java.lang.Exception
This is used to get the specified value on the provided object. The value returned from this method will be an instance of the contact class type. If the returned object is of a different type then the serialization process will fail.
-
toString
public java.lang.String toString()
This is used to describe the contact as it exists within the owning class. It is used to provide error messages that can be used to debug issues that occur when processing a contact. The string provided contains both the set and get methods.
-
-