Package org.simpleframework.xml.core
Class Introspector
- java.lang.Object
-
- org.simpleframework.xml.core.Introspector
-
class Introspector extends java.lang.ObjectTheIntrospectorobject is used to determine the details to use for an annotated field or method using both the field an annotation details. This allows defaults to be picked up from the method or field type if that have not been explicitly overridden in the annotation.
-
-
Field Summary
Fields Modifier and Type Field Description private ContactcontactThis is the field or method contact that has been annotated.private FormatformatThis is the format used to style the paths created.private LabellabelThis is the label used to expose the annotation details.private java.lang.annotation.AnnotationmarkerThis is the actual annotation from the specified contact.
-
Constructor Summary
Constructors Constructor Description Introspector(Contact contact, Label label, Format format)Constructor for theIntrospectorobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContactgetContact()This is used to acquire theContactfor this.private java.lang.StringgetDefault()This is used to acquire the name for an element by firstly checking for an override in the annotation.TypegetDependent()This returns the dependent type for the annotation.java.lang.StringgetEntry()This method is used to get the entry name of a label using the type of the label.ExpressiongetExpression()This method is used to return an XPath expression that is used to represent the position of a label.java.lang.StringgetName()This is used to determine the name of the XML element that the annotated field or method represents.private java.lang.StringgetName(java.lang.Class type)This is used to acquire the name of the specified type using theRootannotation for the class.java.lang.StringgetPath()This is used to acquire the path of the element or attribute that is used by the class schema.private java.lang.StringgetRoot(java.lang.Class type)This will acquire the name of theRootannotation for the specified class.private java.lang.StringgetRoot(java.lang.Class<?> real, java.lang.Class<?> type)This will acquire the name of theRootannotation for the specified class.booleanisEmpty(java.lang.String value)This method is used to determine if a root annotation value is an empty value.java.lang.StringtoString()This method is used to construct a string that describes the signature of an XML annotated field or method.
-
-
-
Field Detail
-
marker
private final java.lang.annotation.Annotation marker
This is the actual annotation from the specified contact.
-
contact
private final Contact contact
This is the field or method contact that has been annotated.
-
format
private final Format format
This is the format used to style the paths created.
-
label
private final Label label
This is the label used to expose the annotation details.
-
-
Constructor Detail
-
Introspector
public Introspector(Contact contact, Label label, Format format)
Constructor for theIntrospectorobject. This is used to create an object that will use information available within the field and annotation to determine exactly what the name of the XML element is to be and the type to use.- Parameters:
contact- this is the method or field contact usedlabel- this is the annotation on the contact objectformat- this is used to style the paths created
-
-
Method Detail
-
getContact
public Contact getContact()
This is used to acquire theContactfor this. The contact is the actual method or field that has been annotated and is used to set or get information from the object instance.- Returns:
- the method or field that this signature represents
-
getDependent
public Type getDependent() throws java.lang.Exception
This returns the dependent type for the annotation. This type is the type other than the annotated field or method type that the label depends on. For theElementListthis can be the generic parameter to an annotated collection type.- Returns:
- this is the type that the annotation depends on
- Throws:
java.lang.Exception
-
getEntry
public java.lang.String getEntry() throws java.lang.ExceptionThis method is used to get the entry name of a label using the type of the label. This ensures that if there is no entry XML element name declared by the annotation that a suitable name can be calculated from the annotated type.- Returns:
- this returns a suitable XML entry element name
- Throws:
java.lang.Exception
-
getName
private java.lang.String getName(java.lang.Class type) throws java.lang.ExceptionThis is used to acquire the name of the specified type using theRootannotation for the class. This will use either the name explicitly provided by the annotation or it will use the name of the class that the annotation was placed on if there is no explicit name for the root.- Parameters:
type- this is the type to acquire the root name for- Returns:
- this returns the name of the type from the root
- Throws:
java.lang.Exception- if the class contains an illegal schema
-
getRoot
private java.lang.String getRoot(java.lang.Class type)
This will acquire the name of theRootannotation for the specified class. This will traverse the inheritance hierarchy looking for the root annotation, when it is found it is used to acquire a name for the XML element it represents.- Parameters:
type- this is the type to acquire the root name with- Returns:
- the root name for the specified type if it exists
-
getRoot
private java.lang.String getRoot(java.lang.Class<?> real, java.lang.Class<?> type)This will acquire the name of theRootannotation for the specified class. This will traverse the inheritance hierarchy looking for the root annotation, when it is found it is used to acquire a name for the XML element it represents.- Parameters:
real- the actual type of the object being searchedtype- this is the type to acquire the root name with- Returns:
- the root name for the specified type if it exists
-
getName
public java.lang.String getName() throws java.lang.ExceptionThis is used to determine the name of the XML element that the annotated field or method represents. This will determine based on the annotation attributes and the dependent type required what the name of the XML element this represents is.- Returns:
- this returns the name of the XML element expected
- Throws:
java.lang.Exception
-
getDefault
private java.lang.String getDefault() throws java.lang.ExceptionThis is used to acquire the name for an element by firstly checking for an override in the annotation. If one exists then this is returned if not then the name of the field or method contact is returned.- Returns:
- this returns the XML element name to be used
- Throws:
java.lang.Exception
-
getExpression
public Expression getExpression() throws java.lang.Exception
This method is used to return an XPath expression that is used to represent the position of a label. If there is no XPath expression associated with this then an empty path is returned. This will never return a null expression.- Returns:
- the XPath expression identifying the location
- Throws:
java.lang.Exception
-
getPath
public java.lang.String getPath() throws java.lang.ExceptionThis is used to acquire the path of the element or attribute that is used by the class schema. The path is determined by acquiring the XPath expression and appending the name of the label to form a fully qualified path.- Returns:
- returns the path that is used for the XML property
- Throws:
java.lang.Exception
-
isEmpty
public boolean isEmpty(java.lang.String value)
This method is used to determine if a root annotation value is an empty value. Rather than determining if a string is empty be comparing it to an empty string this method allows for the value an empty string represents to be changed in future.- Parameters:
value- this is the value to determine if it is empty- Returns:
- true if the string value specified is an empty value
-
toString
public java.lang.String toString()
This method is used to construct a string that describes the signature of an XML annotated field or method. This will use theContactobject and the annotation used for that contact to construct a string that has sufficient information such that it can be used in error reporting.- Overrides:
toStringin classjava.lang.Object- Returns:
- returns a string used to represent this signature
-
-