Package org.simpleframework.xml.core
Class PrimitiveScanner
- java.lang.Object
-
- org.simpleframework.xml.core.PrimitiveScanner
-
class PrimitiveScanner extends java.lang.Object implements Scanner
ThePrimitiveScannerperforms the reflective inspection of a class and builds a map of attributes and elements for each annotated field. This acts as a cachable container for reflection actions performed on a specific type. When scanning the provided class this inserts the scanned field as aLabelin to a map so that it can be retrieved by name. Annotations classified as attributes have theAttributeannotation, all other annotated fields are stored as elements.- See Also:
Schema
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPrimitiveScanner.EmptySectionTheEmptySectionobject creates a section for used with primitives that has no values.
-
Constructor Summary
Constructors Constructor Description PrimitiveScanner(Detail detail)Constructor for thePrimitiveScannerobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CallergetCaller(Context context)This method is used to return theCallerfor this class.FunctiongetCommit()This method is used to retrieve the schema class commit method during the deserialization process.FunctiongetComplete()This method is used to retrieve the schema class completion method.DecoratorgetDecorator()This is used to acquire theDecoratorfor this.InstantiatorgetInstantiator()This is used to acquire the instantiator for the type.java.lang.StringgetName()This returns the name of the class processed by this scanner.OrdergetOrder()This is used to acquire theOrderannotation for the class schema.ParameterMapgetParameters()This returns a map of all parameters that exist.FunctiongetPersist()This method is used to retrieve the schema class persistence method.FunctiongetReplace()This method is used to retrieve the schema class replacement method.FunctiongetResolve()This method is used to retrieve the schema class replacement method.VersiongetRevision()This is theVersionfor the scanned class.SectiongetSection()This is used to create aSectiongiven the context used for serialization.SignaturegetSignature()This is used to acquire the default signature for the class.java.util.List<Signature>getSignatures()This returns the signatures for the type.LabelgetText()This returns theLabelthat represents the text annotation for the scanned class.java.lang.ClassgetType()This is used to acquire the type that this scanner scans for annotations to be used in a schema.FunctiongetValidate()This method is used to retrieve the schema class validation method during the deserialization process.LabelgetVersion()This returns theLabelthat represents the version annotation for the scanned class.booleanisEmpty()This is used to determine whether the scanned class represents a primitive type.booleanisPrimitive()This is used to determine whether the scanned class represents a primitive type.booleanisStrict()This method is used to determine whether strict mappings are required.
-
-
-
Constructor Detail
-
PrimitiveScanner
public PrimitiveScanner(Detail detail)
Constructor for thePrimitiveScannerobject. This is used to represent primitives or other types that do not have and XML annotations present.- Parameters:
detail- this contains the details for the class scanned
-
-
Method Detail
-
getSignature
public Signature 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.- Specified by:
getSignaturein interfaceScanner- Returns:
- this returns the default signature if it exists
-
getSignatures
public java.util.List<Signature> 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.- Specified by:
getSignaturesin interfaceScanner- Returns:
- this returns the list of signatures for the type
-
getParameters
public ParameterMap 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.- Specified by:
getParametersin interfaceScanner- Returns:
- this returns a map of all parameters within the type
-
getInstantiator
public Instantiator getInstantiator()
This is used to acquire the instantiator for the type. This is used to create object instances based on the constructors that have been annotated. If no constructors have been annotated then this can be used to create default no argument instances.- Specified by:
getInstantiatorin interfaceScanner- Returns:
- this instantiator responsible for creating instances
-
getType
public java.lang.Class getType()
This is used to acquire the type that this scanner scans for annotations to be used in a schema. Exposing the class that this represents allows the schema it creates to be known.
-
getDecorator
public Decorator getDecorator()
This is used to acquire theDecoratorfor 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.- Specified by:
getDecoratorin interfaceScanner- Returns:
- this returns the decorator associated with this
-
getCaller
public Caller getCaller(Context context)
This method is used to return theCallerfor this class. The caller is a means to deliver invocations to the object for the persister callback methods. It aggregates all of the persister callback methods in to a single object.
-
getSection
public Section getSection()
This is used to create aSectiongiven the context used for serialization. A section is an XML structure that contains all the elements and attributes defined for the class. Each section is a tree like structure defining exactly where each attribute an element is located within the source XML.- Specified by:
getSectionin interfaceScanner- Returns:
- this will return a section for serialization
-
getRevision
public Version getRevision()
This is theVersionfor the scanned class. It allows the deserialization process to be configured such that if the version is different from the schema class none of the fields and methods are required and unmatched elements and attributes will be ignored.- Specified by:
getRevisionin interfaceScanner- Returns:
- this returns the version of the class that is scanned
-
getOrder
public Order getOrder()
This is used to acquire theOrderannotation for the class schema. The order annotation defines the order that the elements and attributes should appear within the document. Providing order in this manner makes the resulting XML more predictable. If no order is provided, appearance is random.
-
getVersion
public Label getVersion()
This returns theLabelthat represents the version annotation for the scanned class. Only a single version can exist within the class if more than one exists an exception is thrown. This will read only floating point types such as double.- Specified by:
getVersionin interfaceScanner- Returns:
- this returns the label used for reading the version
-
getText
public Label getText()
This returns theLabelthat represents the text annotation for the scanned class. Only a single text annotation can be used per class, so this returns only a single label rather than aLabelMapobject. Also if this is not null then the elements label map must be empty.
-
getName
public java.lang.String getName()
This returns the name of the class processed by this scanner. The name is either the name as specified in the last foundRootannotation, or if a name was not specified within the discovered root then the Java Bean class name of the last class annotated with a root annotation.
-
getCommit
public Function getCommit()
This method is used to retrieve the schema class commit method during the deserialization process. The commit method must be marked with theCommitannotation 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.
-
getValidate
public Function getValidate()
This method is used to retrieve the schema class validation method during the deserialization process. The validation method must be marked with theValidateannotation so that when the object is deserialized the persister has a chance to invoke that method so that object can validate its field values.- Specified by:
getValidatein interfaceScanner- Returns:
- this returns the validate method for the schema class
-
getPersist
public Function 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 nessecary preparation before the serialization of the object proceeds. The persist method must be marked with thePersistannotation.- Specified by:
getPersistin interfaceScanner- Returns:
- this returns the persist method for the schema class
-
getComplete
public Function 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 theCompleteannotation.- Specified by:
getCompletein interfaceScanner- Returns:
- returns the complete method for the schema class
-
getReplace
public Function 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 theReplaceannotation.- Specified by:
getReplacein interfaceScanner- Returns:
- returns the replace method for the schema class
-
getResolve
public Function 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 theReplaceannotation.- Specified by:
getResolvein interfaceScanner- Returns:
- returns the replace method for the schema class
-
isPrimitive
public boolean isPrimitive()
This is used to determine whether the scanned class represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.- Specified by:
isPrimitivein interfaceScanner- Returns:
- this returns true if no XML annotations were found
-
isEmpty
public boolean isEmpty()
This is used to determine whether the scanned class represents a primitive type. A primitive type is a type that contains no XML annotations and so cannot be serialized with an XML form. Instead primitives a serialized using transformations.
-
isStrict
public boolean isStrict()
This method is used to determine whether strict mappings are required. Strict mapping means that all labels in the class schema must match the XML elements and attributes in the source XML document. When strict mapping is disabled, then XML elements and attributes that do not exist in the schema class will be ignored without breaking the parser.
-
-