Package org.simpleframework.xml.core
Class Caller
- java.lang.Object
-
- org.simpleframework.xml.core.Caller
-
class Caller extends java.lang.Object
TheCaller
acts as a means for the schema to invoke the callback methods on an object. This ensures that the correct method is invoked within the schema class. If the annotated method accepts a map then this will provide that map to the method. This also ensures that if specific annotation is not present in the class that no action is taken on a persister callback.
-
-
Field Summary
Fields Modifier and Type Field Description private Function
commit
This is the pointer to the schema class commit function.private Function
complete
This is the pointer to the schema class complete function.private Context
context
This is the context that is used to invoke the functions.private Function
persist
This is the pointer to the schema class persist function.private Function
replace
This is the pointer to the schema class replace function.private Function
resolve
This is the pointer to the schema class resolve function.private Function
validate
This is the pointer to the schema class validation function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commit(java.lang.Object source)
This method is used to invoke the provided objects commit function during the deserialization process.void
complete(java.lang.Object source)
This method is used to invoke the provided objects completion function.void
persist(java.lang.Object source)
This method is used to invoke the provided objects persistence function.java.lang.Object
replace(java.lang.Object source)
This is used to replace the deserialized object with another instance, perhaps of a different type.java.lang.Object
resolve(java.lang.Object source)
This is used to replace the deserialized object with another instance, perhaps of a different type.void
validate(java.lang.Object source)
This method is used to invoke the provided objects validation function during the deserialization process.
-
-
-
Field Detail
-
commit
private final Function commit
This is the pointer to the schema class commit function.
-
validate
private final Function validate
This is the pointer to the schema class validation function.
-
persist
private final Function persist
This is the pointer to the schema class persist function.
-
complete
private final Function complete
This is the pointer to the schema class complete function.
-
replace
private final Function replace
This is the pointer to the schema class replace function.
-
resolve
private final Function resolve
This is the pointer to the schema class resolve function.
-
context
private final Context context
This is the context that is used to invoke the functions.
-
-
Constructor Detail
-
Caller
public Caller(Scanner schema, Context context)
Constructor for theCaller
object. This is used to wrap the schema class such that callbacks from the persister can be dealt with in a seamless manner. This ensures that the correct function and arguments are provided to the functions. element and attribute XML annotations scanned from- Parameters:
schema
- this is the scanner that contains the functionscontext
- this is the context used to acquire the session
-
-
Method Detail
-
replace
public java.lang.Object replace(java.lang.Object source) throws java.lang.Exception
This is used to replace the deserialized object with another instance, perhaps of a different type. This is useful when an XML schema class acts as a reference to another XML document which needs to be loaded externally to create an object of a different type.- Parameters:
source
- the source object to invoke the function on- Returns:
- this returns the object that acts as the replacement
- Throws:
java.lang.Exception
- if the replacement function cannot complete
-
resolve
public java.lang.Object resolve(java.lang.Object source) throws java.lang.Exception
This is used to replace the deserialized object with another instance, perhaps of a different type. This is useful when an XML schema class acts as a reference to another XML document which needs to be loaded externally to create an object of a different type.- Parameters:
source
- the source object to invoke the function on- Returns:
- this returns the object that acts as the replacement
- Throws:
java.lang.Exception
- if the replacement function cannot complete
-
commit
public void commit(java.lang.Object source) throws java.lang.Exception
This method is used to invoke the provided objects commit function during the deserialization process. The commit function must be marked with theCommit
annotation so that when the object is deserialized the persister has a chance to invoke the function so that the object can build further data structures.- Parameters:
source
- this is the object that has just been deserialized- Throws:
java.lang.Exception
- thrown if the commit process cannot complete
-
validate
public void validate(java.lang.Object source) throws java.lang.Exception
This method is used to invoke the provided objects validation function during the deserialization process. The validation function must be marked with theValidate
annotation so that when the object is deserialized the persister has a chance to invoke that function so that object can validate its field values.- Parameters:
source
- this is the object that has just been deserialized- Throws:
java.lang.Exception
- thrown if the validation process failed
-
persist
public void persist(java.lang.Object source) throws java.lang.Exception
This method is used to invoke the provided objects persistence function. 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 function must be marked with thePersist
annotation.- Parameters:
source
- the object that is about to be serialized- Throws:
java.lang.Exception
- thrown if the object cannot be persisted
-
complete
public void complete(java.lang.Object source) throws java.lang.Exception
This method is used to invoke the provided objects completion function. This is invoked after the serialization process has completed and gives the object a chance to restore its state if the persist function required some alteration or locking. This is marked with theComplete
annotation.- Parameters:
source
- this is the object that has been serialized- Throws:
java.lang.Exception
- thrown if the object cannot complete
-
-