Class FieldScanner
java.lang.Object
java.util.AbstractCollection<Contact>
java.util.AbstractList<Contact>
java.util.ArrayList<Contact>
org.simpleframework.xml.core.ContactList
org.simpleframework.xml.core.FieldScanner
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<Contact>, Collection<Contact>, List<Contact>, RandomAccess, SequencedCollection<Contact>
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classTheFieldKeyobject is used to create a key that can store a contact using a field without using the methods ofhashCodeandequalson the field directly, as these can perform poorly on certain platforms. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ContactMapThis is used to determine which fields have been scanned.private final AnnotationFactoryThis is used to create the synthetic annotations for fields.private final SupportThis object contains various support functions for the class.Fields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionFieldScanner(Detail detail, Support support) Constructor for theFieldScannerobject. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbuild()This is used to build a list of valid contacts for this scanner.private voidextend(Class base, DefaultType access) This method is used to extend the provided class.private voidThis is used to scan the declared fields within the specified class.private voidextract(Detail detail, DefaultType access) This is used to scan all the fields of the class in order to determine if it should have a default annotation.private voidThis is used to insert a contact to this contact list.private booleanThis is used to determine if a field is static.private booleanThis is used to determine if theTextannotation has been declared on the field.private booleanisTransient(Field field) This is used to determine if a field is transient.private voidprocess(Field field, Annotation label, Annotation[] list) This method is used to process the field an annotation given.private voidprocess(Field field, Class type, Annotation[] list) This method is used to process the field an annotation given.private voidremove(Field field, Annotation label) This is used to remove a field from the map of processed fields.private voidscan(Field field, Annotation label, Annotation[] list) This reflectively checks the annotation to determine the type of annotation it represents.private voidThis method is used to scan the class hierarchy for each class in order to extract fields that contain XML annotations.Methods inherited from class ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAll, toStringMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
containsAll, reversed
-
Field Details
-
factory
This is used to create the synthetic annotations for fields. -
done
This is used to determine which fields have been scanned. -
support
This object contains various support functions for the class.
-
-
Constructor Details
-
FieldScanner
Constructor for theFieldScannerobject. 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 scannedsupport- this contains various support functions- Throws:
Exception
-
-
Method Details
-
scan
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
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 fromaccess- this is the access type used for the super type- Throws:
Exception
-
extract
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 aContactfor an entity within the object.- Parameters:
detail- this is one of the super classes for the object
-
extract
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 scannedaccess- this is the default access type for the class- Throws:
Exception
-
scan
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 aContactwhich can be used to represent the field within the source object.- Parameters:
field- the field that the annotation comes fromlabel- the annotation used to model the XML schemalist- this is the list of annotations on the field
-
process
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 contacttype- this is the type to acquire the annotationlist- this is the list of annotations on the field- Throws:
Exception
-
process
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 contactlabel- this is the XML annotation used by the fieldlist- this is the list of annotations on the field
-
insert
This is used to insert a contact to this contact list. Here if aTextannotation 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 fieldcontact- this is the contact that is to be inserted
-
isText
This is used to determine if theTextannotation 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
This is used to remove a field from the map of processed fields. A field is removed with theTransientannotation 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 maplabel- 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
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
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
-