Package org.simpleframework.xml.core
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 class
TheFieldKey
object is used to create a key that can store a contact using a field without using the methods ofhashCode
andequals
on the field directly, as these can perform poorly on certain platforms. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ContactMap
This is used to determine which fields have been scanned.private final AnnotationFactory
This is used to create the synthetic annotations for fields.private final Support
This object contains various support functions for the class.Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionFieldScanner
(Detail detail, Support support) Constructor for theFieldScanner
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
build()
This is used to build a list of valid contacts for this scanner.private void
extend
(Class base, DefaultType access) This method is used to extend the provided class.private void
This is used to scan the declared fields within the specified class.private void
extract
(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 void
This is used to insert a contact to this contact list.private boolean
This is used to determine if a field is static.private boolean
This is used to determine if theText
annotation has been declared on the field.private boolean
isTransient
(Field field) This is used to determine if a field is transient.private void
process
(Field field, Annotation label, Annotation[] list) This method is used to process the field an annotation given.private void
process
(Field field, Class type, Annotation[] list) This method is used to process the field an annotation given.private void
remove
(Field field, Annotation label) This is used to remove a field from the map of processed fields.private void
scan
(Field field, Annotation label, Annotation[] list) This reflectively checks the annotation to determine the type of annotation it represents.private void
This method is used to scan the class hierarchy for each class in order to extract fields that contain XML annotations.Methods inherited from class java.util.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, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.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 theFieldScanner
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 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 aContact
for 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 aContact
which 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 aText
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 fieldcontact
- this is the contact that is to be inserted
-
isText
This is used to determine if theText
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
This is used to remove a field from the map of processed fields. A field is removed with theTransient
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 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
-