Class Caller

java.lang.Object
org.simpleframework.xml.core.Caller

class Caller extends Object
The Caller 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 final Function
    This is the pointer to the schema class commit function.
    private final Function
    This is the pointer to the schema class complete function.
    private final Context
    This is the context that is used to invoke the functions.
    private final Function
    This is the pointer to the schema class persist function.
    private final Function
    This is the pointer to the schema class replace function.
    private final Function
    This is the pointer to the schema class resolve function.
    private final Function
    This is the pointer to the schema class validation function.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Caller(Scanner schema, Context context)
    Constructor for the Caller object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commit(Object source)
    This method is used to invoke the provided objects commit function during the deserialization process.
    void
    complete(Object source)
    This method is used to invoke the provided objects completion function.
    void
    persist(Object source)
    This method is used to invoke the provided objects persistence function.
    replace(Object source)
    This is used to replace the deserialized object with another instance, perhaps of a different type.
    resolve(Object source)
    This is used to replace the deserialized object with another instance, perhaps of a different type.
    void
    validate(Object source)
    This method is used to invoke the provided objects validation function during the deserialization process.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • Caller

      public Caller(Scanner schema, Context context)
      Constructor for the Caller 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 functions
      context - this is the context used to acquire the session
  • Method Details

    • replace

      public Object replace(Object source) throws 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:
      Exception - if the replacement function cannot complete
    • resolve

      public Object resolve(Object source) throws 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:
      Exception - if the replacement function cannot complete
    • commit

      public void commit(Object source) throws Exception
      This method is used to invoke the provided objects commit function during the deserialization process. The commit function must be marked with the Commit 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:
      Exception - thrown if the commit process cannot complete
    • validate

      public void validate(Object source) throws Exception
      This method is used to invoke the provided objects validation function during the deserialization process. The validation function must be marked with the Validate 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:
      Exception - thrown if the validation process failed
    • persist

      public void persist(Object source) throws 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 the Persist annotation.
      Parameters:
      source - the object that is about to be serialized
      Throws:
      Exception - thrown if the object cannot be persisted
    • complete

      public void complete(Object source) throws 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 the Complete annotation.
      Parameters:
      source - this is the object that has been serialized
      Throws:
      Exception - thrown if the object cannot complete