Package org.simpleframework.xml.core
Class ClassScanner
java.lang.Object
org.simpleframework.xml.core.ClassScanner
The
ClassScanner
performs the reflective inspection
of a class and extracts all the class level annotations. This will
also extract the methods that are annotated. This ensures that the
callback methods can be invoked during the deserialization process.
Also, this will read the namespace annotations that are used.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function
This function acts as a pointer to the types commit process.private Function
This function acts as a pointer to the types complete process.private NamespaceDecorator
This is the namespace decorator associated with this scanner.private Order
This is the order annotation that has been scanned from the type.private Function
This function acts as a pointer to the types persist process.private Function
This function is used as a pointer to the replacement method.private Function
This function is used as a pointer to the resolution method.private Root
This is the root annotation that has been scanned from the type.private ConstructorScanner
This is the scanner that is used to acquire the constructors.private Support
This object contains various support functions for the class.private Function
This function acts as a pointer to the types validate process. -
Constructor Summary
ConstructorsConstructorDescriptionClassScanner
(Detail detail, Support support) Constructor for theClassScanner
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
This method is used to check the provided method to determine if it contains theCommit
annotation.private void
This is used to set the primary namespace for nodes that will be decorated by the namespace decorator.private void
This method is used to check the provided method to determine if it contains theComplete
annotation.private void
definition
(Detail detail) This method is used to extract theRoot
annotation and theOrder
annotation from the detail provided.This method is used to retrieve the schema class commit method during the deserialization process.This method is used to retrieve the schema class completion method.This is used to acquire theDecorator
for this.private Function
getFunction
(Method method) This is used to acquire aFunction
object for the method provided.getOrder()
This returns the order annotation used to determine the order of serialization of attributes and elements.This returns a map of all parameters that exist.This method is used to retrieve the schema class persistence method.This method is used to retrieve the schema class replacement method.This method is used to retrieve the schema class replacement method.getRoot()
This returns the root of the class processed by this scanner.This is used to acquire the default signature for the class.This returns the signatures for the type.This method is used to retrieve the schema class validation method during the deserialization process.private boolean
isContextual
(Method method) This is used to determine whether the annotated method takes a contextual object.private void
This is used to scan the specified class for methods so that the persister callback annotations can be collected.private void
method
(MethodDetail detail) Scans the provided method for a persister callback method.private void
This is used to acquire the namespace annotations that apply to the scanned class.private void
This method is used to check the provided method to determine if it contains thePersist
annotation.private void
This method is used to check the provided method to determine if it contains theReplace
annotation.private void
This method is used to check the provided method to determine if it contains theResolve
annotation.private void
Scan the fields and methods such that the given class is scanned first then all super classes up to the rootObject
.private void
This method is used to check the provided method to determine if it contains theValidate
annotation.
-
Field Details
-
decorator
This is the namespace decorator associated with this scanner. -
scanner
This is the scanner that is used to acquire the constructors. -
commit
This function acts as a pointer to the types commit process. -
validate
This function acts as a pointer to the types validate process. -
persist
This function acts as a pointer to the types persist process. -
complete
This function acts as a pointer to the types complete process. -
replace
This function is used as a pointer to the replacement method. -
resolve
This function is used as a pointer to the resolution method. -
support
This object contains various support functions for the class. -
root
This is the root annotation that has been scanned from the type. -
order
This is the order annotation that has been scanned from the type.
-
-
Constructor Details
-
ClassScanner
Constructor for theClassScanner
object. This is used to scan the provided class for annotations that are used to build a schema for an XML file to follow.- Parameters:
detail
- this contains the details for the class scannedsupport
- this contains various support functions- Throws:
Exception
-
-
Method Details
-
getSignature
This is used to acquire the default signature for the class. The default signature is the signature for the no argument constructor for the type. If there is no default constructor for the type then this will return null.- Returns:
- this returns the default signature if it exists
-
getSignatures
This returns the signatures for the type. All constructors are represented as a signature and returned. More signatures than constructors will be returned if a constructor is annotated with a union annotation.- Returns:
- this returns the list of signatures for the type
-
getParameters
This returns a map of all parameters that exist. This is used to validate all the parameters against the field and method annotations that exist within the class.- Returns:
- this returns a map of all parameters within the type
-
getDecorator
This is used to acquire theDecorator
for this. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.- Returns:
- this returns the decorator associated with this
-
getOrder
This returns the order annotation used to determine the order of serialization of attributes and elements. The order is a class level annotation that can be used only once per class XML schema. If none exists then this will return null. of the class processed by this scanner.- Returns:
- this returns the name of the object being scanned
-
getRoot
This returns the root of the class processed by this scanner. The root determines the type of deserialization that is to be performed and also contains the name of the root element.- Returns:
- this returns the name of the object being scanned
-
getCommit
This method is used to retrieve the schema class commit method during the deserialization process. The commit method must be marked with theCommit
annotation so that when the object is deserialized the persister has a chance to invoke the method so that the object can build further data structures.- Returns:
- this returns the commit method for the schema class
-
getValidate
This method is used to retrieve the schema class validation method during the deserialization process. The validation method must be marked with theValidate
annotation so that when the object is deserialized the persister has a chance to invoke that method so that object can validate its field values.- Returns:
- this returns the validate method for the schema class
-
getPersist
This method is used to retrieve the schema class persistence method. This is invoked during the serialization process to get the object a chance to perform an necessary preparation before the serialization of the object proceeds. The persist method must be marked with thePersist
annotation.- Returns:
- this returns the persist method for the schema class
-
getComplete
This method is used to retrieve the schema class completion method. This is invoked after the serialization process has completed and gives the object a chance to restore its state if the persist method required some alteration or locking. This is marked with theComplete
annotation.- Returns:
- returns the complete method for the schema class
-
getReplace
This method is used to retrieve the schema class replacement method. The replacement method is used to substitute an object that has been deserialized with another object. This allows a seamless delegation mechanism to be implemented. This is marked with theReplace
annotation.- Returns:
- returns the replace method for the schema class
-
getResolve
This method is used to retrieve the schema class replacement method. The replacement method is used to substitute an object that has been deserialized with another object. This allows a seamless delegation mechanism to be implemented. This is marked with theReplace
annotation.- Returns:
- returns the replace method for the schema class
-
scan
Scan the fields and methods such that the given class is scanned first then all super classes up to the rootObject
. All fields and methods from the most specialized classes override fields and methods from higher up the inheritance hierarchy. This means that annotated details can be overridden.- Parameters:
detail
- contains the methods and fields to be examined- Throws:
Exception
-
definition
This method is used to extract theRoot
annotation and theOrder
annotation from the detail provided. These annotation are taken from the first definition encountered from the most specialized class up through the base classes.- Parameters:
detail
- this detail object used to acquire the annotations- Throws:
Exception
-
namespace
This is used to acquire the namespace annotations that apply to the scanned class. Namespace annotations are added only if they have not already been extracted from a more specialized class. When scanned all the namespace definitions are used to qualify the XML that is produced from serializing the class.- Parameters:
type
- this is the type to extract the annotations from- Throws:
Exception
-
commit
This is used to set the primary namespace for nodes that will be decorated by the namespace decorator. If no namespace is set using this method then this decorator will leave the namespace reference unchanged and only add namespaces for scoping.- Parameters:
detail
- the detail object that contains the namespace
-
method
This is used to scan the specified class for methods so that the persister callback annotations can be collected. These annotations help object implementations to validate the data that is injected into the instance during deserialization.- Parameters:
detail
- this is a detail from within the class hierarchy- Throws:
Exception
-
method
Scans the provided method for a persister callback method. If the method contains an method annotated as a callback that method is stored so that it can be invoked by the persister during the serialization and deserialization process.- Parameters:
detail
- the method to scan for callback annotations
-
replace
This method is used to check the provided method to determine if it contains theReplace
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
resolve
This method is used to check the provided method to determine if it contains theResolve
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
commit
This method is used to check the provided method to determine if it contains theCommit
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
validate
This method is used to check the provided method to determine if it contains theValidate
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
persist
This method is used to check the provided method to determine if it contains thePersist
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
complete
This method is used to check the provided method to determine if it contains theComplete
annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.- Parameters:
method
- this is the method checked for the annotation
-
getFunction
This is used to acquire aFunction
object for the method provided. The function returned will allow the callback method to be invoked when given the context and target object.- Parameters:
method
- this is the method that is to be invoked- Returns:
- this returns the function that is to be invoked
-
isContextual
This is used to determine whether the annotated method takes a contextual object. If the method takes aMap
then this returns true, otherwise it returns false.- Parameters:
method
- this is the method to check the parameters of- Returns:
- this returns true if the method takes a map object
-