Class ClassTransform
java.lang.Object
org.simpleframework.xml.transform.ClassTransform
The
ClassTransform
object is used to transform class
values to and from string representations, which will be inserted
in the generated XML document as the value place holder. The
value must be readable and writable in the same format. Fields
and methods annotated with the XML attribute annotation will use
this to persist and retrieve the value to and from the XML source.
@Attribute private Class target;As well as the XML attribute values using transforms, fields and methods annotated with the XML element annotation will use this. Aside from the obvious difference, the element annotation has an advantage over the attribute annotation in that it can maintain any references using the
CycleStrategy
object.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
This is the string that represents the class for a boolean.private static final String
This is the string that represents the class for a byte.private static final String
This is the string that represents the class for a character.private static final String
This is the string that represents the class for a double.private static final String
This is the string that represents the class for a float.private static final String
This is the string that represents the class for an integer.private static final String
This is the string that represents the class for a long.private static final String
This is the string that represents the class for a short.private static final String
This is the string that represents the class for a void. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ClassLoader
This is used to acquire the caller class loader for this object.private static ClassLoader
This is used to acquire the thread context class loader.This method is used to convert the string value given to an appropriate representation.private Class
readPrimitive
(String target) This method is used to convert the string value given to an appropriate representation.This method is used to convert the provided value into an XML usable format.
-
Field Details
-
INTEGER
This is the string that represents the class for an integer.- See Also:
-
DOUBLE
This is the string that represents the class for a double.- See Also:
-
FLOAT
This is the string that represents the class for a float.- See Also:
-
BOOLEAN
This is the string that represents the class for a boolean.- See Also:
-
SHORT
This is the string that represents the class for a short.- See Also:
-
CHARACTER
This is the string that represents the class for a character.- See Also:
-
LONG
This is the string that represents the class for a long.- See Also:
-
BYTE
This is the string that represents the class for a byte.- See Also:
-
VOID
This is the string that represents the class for a void.- See Also:
-
-
Constructor Details
-
ClassTransform
ClassTransform()
-
-
Method Details
-
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. -
readPrimitive
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:
target
- this is the string representation of the class- 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. -
getCallerClassLoader
This is used to acquire the caller class loader for this object. Typically this is only used if the thread context class loader is set to null. This ensures that there is at least some class loader available to the strategy to load the class.- Returns:
- this returns the loader that loaded this class
-
getClassLoader
This is used to acquire the thread context class loader. This is the default class loader used by the cycle strategy. When using the thread context class loader the caller can switch the class loader in use, which allows class loading customization.- Returns:
- this returns the loader used by the calling thread
-