Interface ComplexBinding

    • Method Detail

      • initialize

        void initialize​(ElementInstance instance,
                        Node node,
                        MutablePicoContainer context)
        Callback for the binding to initialize itself.

        This method is called when the leading edge of the associated element is reached, before any children have been processed.

        Parameters:
        instance - The element being parsed.
        node - The node in the parse tree representing the element being parsed. It is important to note that at the time this method is called the node contains no child element nodes, only child attribute nodes.
        context - The container to be used as context for child binding.
      • initializeChildContext

        void initializeChildContext​(ElementInstance childInstance,
                                    Node node,
                                    MutablePicoContainer context)
        Initializes the context for a child element.

        This method is called on the leading edge of a child element. It is used to create context for the binding of a child element. It is important to note that each time this method is called, the node parse tree will contain different, ie child nodes for those previous elements parsed.

        Parameters:
        childInstance - The child element instance
        node - The parse node for the parent element.
        context - the context in which the child element will be parsed.
      • parse

        Object parse​(ElementInstance instance,
                     Node node,
                     Object value)
              throws Exception
        Parses a complex element from an instance document into an object representation.

        This method is called when the trailing edge of the associated element is reached.

        Parameters:
        instance - The element being parsed.
        node - The node in the parse tree representing the element being parsed.
        value - The result of the parse from another strategy in the type hierarchy. Could be null if this is the first strategy being executed.
        Returns:
        The parsed object, or null if the component could not be parsed.
        Throws:
        Exception - Strategy objects should not attempt to handle any exceptions.
      • encode

        Element encode​(Object object,
                       Document document,
                       Element value)
                throws Exception
        Performs the encoding of the object into its xml representation.

        Complex objects are encoded as elements in a document. The value parameter is the encoded element, created by the parent binding. For the first binding in the execution chain this is just an empty element ( no children or attributes ). The binding has the choice to return value or to create a new element to return.

        This method may choose to create child elements and attributes for the element. Or as an alternative return the object values for these contructs in getProperty(Object, QName).

        Parameters:
        object - The object being encoded.
        document - The document containing the encoded element.
        value - The object as encoded by the parent binding.
        Returns:
        The element for the objcet being encoded, or null
        Throws:
        Exception
      • getProperty

        Object getProperty​(Object object,
                           QName name)
                    throws Exception
        Returns a property of a particular object which corresponds to the specified name.

        This method should just return null in the event that the object being encoded is an leaf in its object model.

        For multi-values properties ( maxOccurs > 0 ), this method may return an instance of Collection, Iterator, or an array.

        Parameters:
        object - The object being encoded.
        name - The name of the property to obtain.
        Returns:
        The value of the property, or null.
        Throws:
        Exception
      • getProperties

        List<Object[]> getProperties​(Object object,
                                     XSDElementDeclaration element)
                              throws Exception
        Returns a list of properties of the specified object.

        The return list contains a set of tuples (two element object array) which represent the properties of the object. The second value is an object which respresents the value. The first value of the tuple can one of two things:

        1. A QName identifying an element. This name will be used to locate the schema element for the property.
        2. A XSDParticle representing the element itself.

        This method should only be implemented in the case where the encoder can not determine what the properties of the object are from the schema.

        An example would be an object which corresponds to an element in the schema which has a the type xs:anyType. Since the content of this type can be anything the schema has no way to determine what the properties are. So in this case this method must specify the properties manually as a set of name, object tuples.

        In the case of a multi-valued property, this method must return a tuple for each instance of the property, and not a list, iterator, or array containing all of the instances.

        Parameters:
        object - the object being encoded.
        Returns:
        A list of the properties for the object.
        Throws:
        Exception