Class XPathEngine<XML_FIELD extends Field>


  • public class XPathEngine<XML_FIELD extends Field>
    extends Object
    INTERNAL:

    Purpose: Utility class for creating and removing XML nodes using XPath expressions.

    Since:
    OracleAS TopLink 10g (10.0.3), 03/11/2003 10:21:42
    Author:
    Rick Barkhouse - [email protected]
    • Method Detail

      • getInstance

        public static XPathEngine getInstance()
        Return the XPathEngine singleton.
      • create

        public Node create​(Field xmlField,
                           Node element,
                           CoreAbstractSession session)
                    throws XMLMarshalException
        Create the node path specified by xpathString under element. This method also supports creating attributes and indexed elements using the appropriate XPath syntax ('@' and '[ ]' respectively).
        Parameters:
        xmlField - XMLField containing xpath expression representing the node path to create
        element - Root element under which to create path
        Returns:
        The last XMLNode in the path
        Throws:
        XMLMarshalException - Thrown if passed an invalid XPath string
      • create

        public Node create​(Field xmlField,
                           Node element,
                           Object value,
                           Field lastUpdated,
                           DocumentPreservationPolicy docPresPolicy,
                           CoreAbstractSession session)
                    throws XMLMarshalException
        Create the node path specified by xpathString under element and initialize the leaf node with value. This method also supports creating attributes and integer-indexed elements using the appropriate XPath syntax ('@' and '[ ]' respectively).
        Parameters:
        xmlField - XMLField containing xpath expression representing the node path to create
        element - Root element under which to create path
        value - Initial value for the leaf node (should not be a list)
        Returns:
        The last XMLNode in the path
        Throws:
        XMLMarshalException - Thrown if passed an invalid XPath string
      • createUnownedElement

        public Element createUnownedElement​(Node parent,
                                            Field xmlField)
      • remove

        public NodeList remove​(Field xmlField,
                               Node element)
                        throws XMLMarshalException
        Remove a node. If xpathString points to an indexed element, the element will not be removed, but will instead be reinitialzed (to maintain the index of the collection).
        Parameters:
        xmlField - Field containing XPath query string
        element - Root element at which to begin search
        Returns:
        NodeList containing the nodes that were removed.
        Throws:
        XMLMarshalException - Thrown if passed an invalid XPath string
      • remove

        public NodeList remove​(Field xmlField,
                               Node element,
                               boolean forceRemove)
                        throws XMLMarshalException
        Remove a node.
        Parameters:
        xmlField - Field containing XPath query string
        element - Root element at which to begin search
        forceRemove - If true, then indexed elements will be truly deleted, otherwise they will be reinitialized
        Returns:
        NodeList containing the nodes that were removed.
        Throws:
        XMLMarshalException - Thrown if passed an invalid XPath string
      • replaceValue

        public NodeList replaceValue​(Field xmlField,
                                     Node parent,
                                     Object value,
                                     CoreAbstractSession session)
                              throws XMLMarshalException
        Replace the value of the nodes matching xpathString with value. This method handles elements, indexed elements, and attributes.
        Parameters:
        xmlField - Field containing XPath query string
        parent - Parent element
        value - New value for the node
        Returns:
        NodeList containing the nodes that were replaced.
        Throws:
        XMLMarshalException