Interface Visitor


public interface Visitor
The Visitor interface represents an object that is used to visit each XML element during serialization. For the deserialization process each XML element is visited before control is returned to the serializer. This allows a visitor implementation to perform some operation based on the node that is being deserialized. Typically a visitor is used to edit the node, for example it may remove or insert attributes.

In effect this can act much like a transformer that sits between a Strategy implementation and the core serializer. It enables interception and manipulation of the node so that the resulting XML document can be customized in a way that can not be performed by the underlying strategy.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    read(Type type, NodeMap<InputNode> node)
    This is used to intercept an XML element before it is read by the underlying Strategy implementation.
    void
    write(Type type, NodeMap<OutputNode> node)
    This is used to intercept an XML element after it is written by the underlying Strategy implementation.
  • Method Details

    • read

      void read(Type type, NodeMap<InputNode> node) throws Exception
      This is used to intercept an XML element before it is read by the underlying Strategy implementation. When a node is intercepted it can be manipulated in such a way that its semantics change. For example, this could be used to change the way a "class" attribute is represented, which would allow the XML to appear in a language neutral format.
      Parameters:
      type - this is the type that represents the element
      node - this is the XML element to be intercepted
      Throws:
      Exception
    • write

      void write(Type type, NodeMap<OutputNode> node) throws Exception
      This is used to intercept an XML element after it is written by the underlying Strategy implementation. When a node is intercepted it can be manipulated in such a way that its semantics change. For example, this could be used to change the way a "class" attribute is represented, which would allow the XML to appear in a language neutral format.
      Parameters:
      type - this is the type that represents the element
      node - this is the XML element to be intercepted
      Throws:
      Exception