Class Introspector

java.lang.Object
org.simpleframework.xml.core.Introspector

class Introspector extends Object
The Introspector object 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 final Contact
    This is the field or method contact that has been annotated.
    private final Format
    This is the format used to style the paths created.
    private final Label
    This is the label used to expose the annotation details.
    private final Annotation
    This is the actual annotation from the specified contact.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Introspector(Contact contact, Label label, Format format)
    Constructor for the Introspector object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This is used to acquire the Contact for this.
    private String
    This is used to acquire the name for an element by firstly checking for an override in the annotation.
    This returns the dependent type for the annotation.
    This method is used to get the entry name of a label using the type of the label.
    This method is used to return an XPath expression that is used to represent the position of a label.
    This is used to determine the name of the XML element that the annotated field or method represents.
    private String
    getName(Class type)
    This is used to acquire the name of the specified type using the Root annotation for the class.
    This is used to acquire the path of the element or attribute that is used by the class schema.
    private String
    getRoot(Class type)
    This will acquire the name of the Root annotation for the specified class.
    private String
    getRoot(Class<?> real, Class<?> type)
    This will acquire the name of the Root annotation for the specified class.
    boolean
    isEmpty(String value)
    This method is used to determine if a root annotation value is an empty value.
    This method is used to construct a string that describes the signature of an XML annotated field or method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • marker

      private final 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 Details

    • Introspector

      public Introspector(Contact contact, Label label, Format format)
      Constructor for the Introspector object. 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 used
      label - this is the annotation on the contact object
      format - this is used to style the paths created
  • Method Details

    • getContact

      public Contact getContact()
      This is used to acquire the Contact for 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 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 the ElementList this can be the generic parameter to an annotated collection type.
      Returns:
      this is the type that the annotation depends on
      Throws:
      Exception
    • getEntry

      public String getEntry() throws Exception
      This 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:
      Exception
    • getName

      private String getName(Class type) throws Exception
      This is used to acquire the name of the specified type using the Root annotation 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:
      Exception - if the class contains an illegal schema
    • getRoot

      private String getRoot(Class type)
      This will acquire the name of the Root annotation 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 String getRoot(Class<?> real, Class<?> type)
      This will acquire the name of the Root annotation 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 searched
      type - this is the type to acquire the root name with
      Returns:
      the root name for the specified type if it exists
    • getName

      public String getName() throws Exception
      This 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:
      Exception
    • getDefault

      private String getDefault() throws Exception
      This 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:
      Exception
    • getExpression

      public Expression getExpression() throws 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:
      Exception
    • getPath

      public String getPath() throws Exception
      This 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:
      Exception
    • isEmpty

      public boolean isEmpty(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 String toString()
      This method is used to construct a string that describes the signature of an XML annotated field or method. This will use the Contact object 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:
      toString in class Object
      Returns:
      returns a string used to represent this signature