Class ClassTransform
- java.lang.Object
-
- org.simpleframework.xml.transform.ClassTransform
-
- All Implemented Interfaces:
Transform<java.lang.Class>
class ClassTransform extends java.lang.Object implements Transform<java.lang.Class>
TheClassTransform
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 theCycleStrategy
object.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BOOLEAN
This is the string that represents the class for a boolean.private static java.lang.String
BYTE
This is the string that represents the class for a byte.private static java.lang.String
CHARACTER
This is the string that represents the class for a character.private static java.lang.String
DOUBLE
This is the string that represents the class for a double.private static java.lang.String
FLOAT
This is the string that represents the class for a float.private static java.lang.String
INTEGER
This is the string that represents the class for an integer.private static java.lang.String
LONG
This is the string that represents the class for a long.private static java.lang.String
SHORT
This is the string that represents the class for a short.private static java.lang.String
VOID
This is the string that represents the class for a void.
-
Constructor Summary
Constructors Constructor Description ClassTransform()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.ClassLoader
getCallerClassLoader()
This is used to acquire the caller class loader for this object.private static java.lang.ClassLoader
getClassLoader()
This is used to acquire the thread context class loader.java.lang.Class
read(java.lang.String target)
This method is used to convert the string value given to an appropriate representation.private java.lang.Class
readPrimitive(java.lang.String target)
This method is used to convert the string value given to an appropriate representation.java.lang.String
write(java.lang.Class target)
This method is used to convert the provided value into an XML usable format.
-
-
-
Field Detail
-
INTEGER
private static final java.lang.String INTEGER
This is the string that represents the class for an integer.- See Also:
- Constant Field Values
-
DOUBLE
private static final java.lang.String DOUBLE
This is the string that represents the class for a double.- See Also:
- Constant Field Values
-
FLOAT
private static final java.lang.String FLOAT
This is the string that represents the class for a float.- See Also:
- Constant Field Values
-
BOOLEAN
private static final java.lang.String BOOLEAN
This is the string that represents the class for a boolean.- See Also:
- Constant Field Values
-
SHORT
private static final java.lang.String SHORT
This is the string that represents the class for a short.- See Also:
- Constant Field Values
-
CHARACTER
private static final java.lang.String CHARACTER
This is the string that represents the class for a character.- See Also:
- Constant Field Values
-
LONG
private static final java.lang.String LONG
This is the string that represents the class for a long.- See Also:
- Constant Field Values
-
BYTE
private static final java.lang.String BYTE
This is the string that represents the class for a byte.- See Also:
- Constant Field Values
-
VOID
private static final java.lang.String VOID
This is the string that represents the class for a void.- See Also:
- Constant Field Values
-
-
Method Detail
-
read
public java.lang.Class read(java.lang.String target) throws java.lang.Exception
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
private java.lang.Class readPrimitive(java.lang.String target) throws java.lang.Exception
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:
java.lang.Exception
-
write
public java.lang.String write(java.lang.Class target) throws java.lang.Exception
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
private java.lang.ClassLoader 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
private static java.lang.ClassLoader 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
-
-