Class FieldScanner

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Contact>, Collection<Contact>, List<Contact>, RandomAccess, SequencedCollection<Contact>

class FieldScanner extends ContactList
The FieldScanner object is used to scan an class for fields marked with an XML annotation. All fields that contain an XML annotation are added as Contact objects to the list of contacts for the class. This scans the object by checking the class hierarchy, this allows a subclass to override a super class annotated field, although this should be used rarely.
  • Field Details

    • factory

      private final AnnotationFactory factory
      This is used to create the synthetic annotations for fields.
    • done

      private final ContactMap done
      This is used to determine which fields have been scanned.
    • support

      private final Support support
      This object contains various support functions for the class.
  • Constructor Details

    • FieldScanner

      public FieldScanner(Detail detail, Support support) throws Exception
      Constructor for the FieldScanner object. This is used to perform a scan on the specified class in order to find all fields that are labeled with an XML annotation.
      Parameters:
      detail - this contains the details for the class scanned
      support - this contains various support functions
      Throws:
      Exception
  • Method Details

    • scan

      private void scan(Detail detail) throws Exception
      This method is used to scan the class hierarchy for each class in order to extract fields that contain XML annotations. If the field is annotated it is converted to a contact so that it can be used during serialization and deserialization.
      Parameters:
      detail - this contains the details for the class scanned
      Throws:
      Exception
    • extend

      private void extend(Class base, DefaultType access) throws Exception
      This method is used to extend the provided class. Extending a class in this way basically means that the fields that have been scanned in the specific class will be added to this. Doing this improves the performance of classes within a hierarchy.
      Parameters:
      base - the class to inherit scanned fields from
      access - this is the access type used for the super type
      Throws:
      Exception
    • extract

      private void extract(Detail detail)
      This is used to scan the declared fields within the specified class. Each method will be check to determine if it contains an XML element and can be used as a Contact for an entity within the object.
      Parameters:
      detail - this is one of the super classes for the object
    • extract

      private void extract(Detail detail, DefaultType access) throws Exception
      This is used to scan all the fields of the class in order to determine if it should have a default annotation. If the field should have a default XML annotation then it is added to the list of contacts to be used to form the class schema.
      Parameters:
      detail - this is the detail to have its fields scanned
      access - this is the default access type for the class
      Throws:
      Exception
    • scan

      private void scan(Field field, Annotation label, Annotation[] list)
      This reflectively checks the annotation to determine the type of annotation it represents. If it represents an XML schema annotation it is used to create a Contact which can be used to represent the field within the source object.
      Parameters:
      field - the field that the annotation comes from
      label - the annotation used to model the XML schema
      list - this is the list of annotations on the field
    • process

      private void process(Field field, Class type, Annotation[] list) throws Exception
      This method is used to process the field an annotation given. This will check to determine if the field is accessible, if it is not accessible then it is made accessible so that private member fields can be used during the serialization process.
      Parameters:
      field - this is the field to be added as a contact
      type - this is the type to acquire the annotation
      list - this is the list of annotations on the field
      Throws:
      Exception
    • process

      private void process(Field field, Annotation label, Annotation[] list)
      This method is used to process the field an annotation given. This will check to determine if the field is accessible, if it is not accessible then it is made accessible so that private member fields can be used during the serialization process.
      Parameters:
      field - this is the field to be added as a contact
      label - this is the XML annotation used by the field
      list - this is the list of annotations on the field
    • insert

      private void insert(Object key, Contact contact)
      This is used to insert a contact to this contact list. Here if a Text annotation is declared on a field that already has an annotation then the other annotation is given the priority, this is to so text can be processes separately.
      Parameters:
      key - this is the key that uniquely identifies the field
      contact - this is the contact that is to be inserted
    • isText

      private boolean isText(Contact contact)
      This is used to determine if the Text annotation has been declared on the field. If this annotation is used then this will return true, otherwise this returns false.
      Parameters:
      contact - the contact to check for the text annotation
      Returns:
      true if the text annotation was declared on the field
    • remove

      private void remove(Field field, Annotation label)
      This is used to remove a field from the map of processed fields. A field is removed with the Transient annotation is used to indicate that it should not be processed by the scanner. This is required when default types are used.
      Parameters:
      field - this is the field to be removed from the map
      label - this is the label associated with the field
    • build

      private void build()
      This is used to build a list of valid contacts for this scanner. Valid contacts are fields that are either defaulted or those that have an explicit XML annotation. Any field that has been marked as transient will not be considered as valid.
    • isStatic

      private boolean isStatic(Field field)
      This is used to determine if a field is static. If a field is static it should not be considered as a default field. This ensures the default annotation does not pick up static finals.
      Parameters:
      field - this is the field to determine if it is static
      Returns:
      true if the field is static, false otherwise
    • isTransient

      private boolean isTransient(Field field)
      This is used to determine if a field is transient. For default fields that are processed no transient field should be considered. This ensures that the serialization of the object behaves in the same manner as with Java Object Serialization.
      Parameters:
      field - this is the field to check for transience
      Returns:
      this returns true if the field is a transient one