Package org.simpleframework.xml.core
Class Support
java.lang.Object
org.simpleframework.xml.core.Support
- All Implemented Interfaces:
Filter
The
Support
object is used to provide support to the
serialization engine for processing and transforming strings. This
contains a Transformer
which will create objects from
strings and will also reverse this process converting an object
to a string. This is used in the conversion of primitive types.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DetailExtractor
This is used to extract the defaults for a specific class.private final DetailExtractor
This is used to extract the details for a specific class.private final Filter
This is the filter used to transform the template variables.private final Format
This is the format used by this persistence support object.private final InstanceFactory
This is the factory that is used to create the scanners.private final LabelExtractor
This is used to extract the labels for a specific contact.private final Matcher
This is the matcher used to acquire the transform objects.private final ScannerFactory
This will perform the scanning of types are provide scanners.private final Transformer
This is the transformer used to transform objects to text. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
getClassName
(Class type) This returns the name of the class specified.This is used to get aDetail
object describing a class and its annotations.getDetail
(Class type, DefaultType access) This is used to acquire a list ofContact
objects that represent the annotated fields in a type.getFields
(Class type, DefaultType access) This is used to acquire a list ofContact
objects that represent the annotated fields in a type.This is used to acquire theFormat
for this.getInstance
(Class type) This will create anInstance
that can be used to instantiate objects of the specified class.getInstance
(Value value) This will create anInstance
that can be used to instantiate objects of the specified class.getLabel
(Contact contact, Annotation label) Creates aLabel
using the provided contact and XML annotation.getLabels
(Contact contact, Annotation label) Creates aList
using the provided contact and XML annotation.getMethods
(Class type) This is used to acquire a list ofContact
objects that represent the annotated methods in a type.getMethods
(Class type, DefaultType access) This is used to acquire a list ofContact
objects that represent the annotated methods in a type.This is used to acquire the name of the specified type using theRoot
annotation for the class.static Class
getPrimitive
(Class type) This method is used to convert a primitive type to its object counterpart.getScanner
(Class type) This creates aScanner
object that can be used to examine the fields within the XML class schema.getStyle()
This is used to acquire theStyle
for the format.getTransform
(Class type) This is used to match aTransform
using the type specified.static boolean
isAssignable
(Class expect, Class actual) This is used to determine if two objects are assignable to each other.boolean
isContainer
(Class type) This is used to determine if the type in question is a container of some kind.static boolean
This is used to determine if the type specified is a floating point type.boolean
isPrimitive
(Class type) This is used to determine whether the scanned class represents a primitive type.This method is used to convert the string value given to an appropriate representation.Replaces the text provided with some property.boolean
This method is used to determine if the type specified can be transformed.This method is used to convert the provided value into an XML usable format.
-
Field Details
-
instances
This is the factory that is used to create the scanners. -
scanners
This will perform the scanning of types are provide scanners. -
defaults
This is used to extract the defaults for a specific class. -
details
This is used to extract the details for a specific class. -
labels
This is used to extract the labels for a specific contact. -
transform
This is the transformer used to transform objects to text. -
matcher
This is the matcher used to acquire the transform objects. -
filter
This is the filter used to transform the template variables. -
format
This is the format used by this persistence support object.
-
-
Constructor Details
-
Support
public Support()Constructor for theSupport
object. This will create a support object with a default matcher and default platform filter. This ensures it contains enough information to process a template and transform basic primitive types. -
Support
Constructor for theSupport
object. This will create a support object with a default matcher and the filter provided. This ensures it contains enough information to process a template and transform basic primitive types.- Parameters:
filter
- this is the filter to use with this support
-
Support
Constructor for theSupport
object. This will create a support object with the matcher and filter provided. This allows the user to override the transformations that are used to convert types to strings and back again.- Parameters:
filter
- this is the filter to use with this supportmatcher
- this is the matcher used for transformations
-
Support
Constructor for theSupport
object. This will create a support object with the matcher and filter provided. This allows the user to override the transformations that are used to convert types to strings and back again.- Parameters:
filter
- this is the filter to use with this supportmatcher
- this is the matcher used for transformationsformat
- this contains all the formatting for the XML
-
-
Method Details
-
replace
Replaces the text provided with some property. This method acts much like a the get method of theMap
object, in that it uses the provided text as a key to some value. However it can also be used to evaluate expressions and output the result for inclusion in the generated XML. -
getStyle
This is used to acquire theStyle
for the format. This requires that the style is not null, if a null style is returned from the format this will break serialization.- Returns:
- this returns the style used for this format object
-
getFormat
This is used to acquire theFormat
for this. The format should never be null and contains information that relates to the indentation that is to be used with XML elements.- Returns:
- this returns the format to be used for serialization
-
getInstance
This will create anInstance
that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.- Parameters:
value
- this contains information on the object instance- Returns:
- this will return an object for instantiating objects
-
getInstance
This will create anInstance
that can be used to instantiate objects of the specified class. This leverages an internal constructor cache to ensure creation is quicker.- Parameters:
type
- this is the type that is to be instantiated- Returns:
- this will return an object for instantiating objects
-
getTransform
This is used to match aTransform
using the type specified. If no transform can be acquired then this returns a null value indicating that no transform could be found.- Parameters:
type
- this is the type to acquire the transform for- Returns:
- returns a transform for processing the type given
- Throws:
Exception
-
getLabel
Creates aLabel
using the provided contact and XML annotation. The label produced contains all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the label instantiated for the contact
- Throws:
Exception
-
getLabels
Creates aList
using the provided contact and XML annotation. The labels produced contain all information related to an object member. It knows the name of the XML entity, as well as whether it is required. Once created the converter can transform an XML node into Java object and vice versa.- Parameters:
contact
- this is contact that the label is produced forlabel
- represents the XML annotation for the contact- Returns:
- returns the list of labels associated with the contact
- Throws:
Exception
-
getDetail
This is used to get aDetail
object describing a class and its annotations. Any detail retrieved from this will be cached to increase the performance of future accesses.- Parameters:
type
- this is the type to acquire the detail for- Returns:
- an object describing the type and its annotations
-
getDetail
-
getFields
This is used to acquire a list ofContact
objects that represent the annotated fields in a type. The entire class hierarchy is scanned for annotated fields. Caching of the contact list is done to increase performance.- Parameters:
type
- this is the type to scan for annotated fields- Returns:
- this returns a list of the annotated fields
- Throws:
Exception
-
getFields
This is used to acquire a list ofContact
objects that represent the annotated fields in a type. The entire class hierarchy is scanned for annotated fields. Caching of the contact list is done to increase performance.- Parameters:
type
- this is the type to scan for annotated fieldsaccess
- this is the access type to use for the fields- Returns:
- this returns a list of the annotated fields
- Throws:
Exception
-
getMethods
This is used to acquire a list ofContact
objects that represent the annotated methods in a type. The entire class hierarchy is scanned for annotated methods. Caching of the contact list is done to increase performance.- Parameters:
type
- this is the type to scan for annotated methods- Returns:
- this returns a list of the annotated methods
- Throws:
Exception
-
getMethods
This is used to acquire a list ofContact
objects that represent the annotated methods in a type. The entire class hierarchy is scanned for annotated methods. Caching of the contact list is done to increase performance.- Parameters:
type
- this is the type to scan for annotated methodsaccess
- this is the access type used for the methods- Returns:
- this returns a list of the annotated methods
- Throws:
Exception
-
getScanner
This creates aScanner
object that can be used to examine the fields within the XML class schema. The scanner maintains information when a field from within the scanner is visited, this allows the serialization and deserialization process to determine if all required XML annotations are used.- Parameters:
type
- the schema class the scanner is created for- Returns:
- a scanner that can maintains information on the type
- Throws:
Exception
-
read
This method is used to convert the string value given to an appropriate representation. This is used when an object is being deserialized from the XML document and the value for the string representation is required.- Parameters:
value
- this is the string representation of the valuetype
- this is the type to convert the string value to- Returns:
- this returns an appropriate instanced to be used
- Throws:
Exception
-
write
This method is used to convert the provided value into an XML usable format. This is used in the serialization process when there is a need to convert a field value in to a string so that that value can be written as a valid XML entity.- Parameters:
value
- this is the value to be converted to a stringtype
- this is the type to convert to a string value- Returns:
- this is the string representation of the given value
- Throws:
Exception
-
valid
This method is used to determine if the type specified can be transformed. This will use theMatcher
to find a suitable transform, if one exists then this returns true, if not then this returns false. This is used during serialization to determine how to convert a field or method parameter.- Parameters:
type
- the type to determine whether its transformable- Returns:
- true if the type specified can be transformed by this
- Throws:
Exception
-
getName
This is used to acquire the name of the specified type using theRoot
annotation for the class. This will use either the name explicitly provided by the annotation or it will use the name of the class that the annotation was placed on if there is no explicit name for the root.- Parameters:
type
- this is the type to acquire the root name for- Returns:
- this returns the name of the type from the root
- Throws:
Exception
- if the class contains an illegal schema
-
getClassName
This returns the name of the class specified. If there is a root annotation on the type, then this is ignored in favour of the actual class name. This is typically used when the type is a primitive or if there is noRoot
annotation present.- Parameters:
type
- this is the type to acquire the root name for- Returns:
- this returns the name of the type from the root
- Throws:
Exception
-
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.- Parameters:
type
- this is the type to determine if it is primitive- Returns:
- this returns true if no XML annotations were found
- Throws:
Exception
-
isContainer
This is used to determine if the type in question is a container of some kind. A container is a Java collection object of an array of objects. Containers are treated as special objects in the case of default serialization as we do not want to apply default annotations when we can use them to better effect.- Parameters:
type
- this is the type to determine if it is a container- Returns:
- this returns true if the type represents a container
-
isFloat
This is used to determine if the type specified is a floating point type. Types that are floating point are the double and float primitives as well as the java types for this primitives.- Parameters:
type
- this is the type to determine if it is a float- Returns:
- this returns true if the type is a floating point
- Throws:
Exception
-
isAssignable
This is used to determine if two objects are assignable to each other. To be sure that its is possible to inject primitive values in to a constructor the primitives are wrapped in their counterpart objects, this allows proper assignment checking.- Parameters:
expect
- this is the expected value of the objectactual
- this is the type in the declaration- Returns:
- this returns true if the types can be assigned
-
getPrimitive
This method is used to convert a primitive type to its object counterpart. Conversion to an object counterpart is useful when there is a need to mask the difference between types.- Parameters:
type
- this is the primitive type to convert to an object- Returns:
- this returns the primitive type as its object type
-