Class XMLDocumentUtilityHelper


  • public class XMLDocumentUtilityHelper
    extends Object
    The xml document utility helper, the actual implementor of the DOM manipulation on the low-level.
    Author:
    martin
    • Constructor Detail

      • XMLDocumentUtilityHelper

        public XMLDocumentUtilityHelper​(String nsName,
                                        String nsURL)
        Creates instance.
        Parameters:
        nsName - the namespace name (prefix), null to use default namespace
        nsURL - the namespace URL
    • Method Detail

      • specifyNSattribute

        public void specifyNSattribute​(Element elem)
                                throws XSPFException
        Sets the namespace declaration attribute to the given element.
        Parameters:
        elem -
        Throws:
        XSPFException
      • createNew

        public Element createNew​(Node context,
                                 String elemName)
                          throws XSPFException
        Creates new element of the given name in the given context (any node or the whole document).
        Parameters:
        context -
        elemName -
        Returns:
        Throws:
        XSPFException
      • createChild

        public Element createChild​(Node owner,
                                   String elemName)
                            throws XSPFException
        Creates (and appends) child element of the given owner.
        Parameters:
        owner -
        elemName -
        Returns:
        Throws:
        XSPFException
      • getChildOrNull

        public Element getChildOrNull​(Node owner,
                                      String elemName)
                               throws XSPFException
        Returns the child element of the given owner. Returns null if no such, fails if more.
        Parameters:
        owner -
        elemName -
        Returns:
        Throws:
        XSPFException
      • getOrCreateChild

        public Element getOrCreateChild​(Node owner,
                                        String elemName)
                                 throws XSPFException
        Returns the child element of the given owner. Creates and appends if no such, fails if more.
        Parameters:
        owner -
        elemName -
        Returns:
        Throws:
        XSPFException
      • getChildren

        public java.util.stream.Stream<Element> getChildren​(Node owner,
                                                            String elemName)
                                                     throws XSPFException
        Returns the child elements of the given owner (having given name).
        Parameters:
        owner -
        elemName -
        Returns:
        Throws:
        XSPFException
      • hasChildren

        public boolean hasChildren​(Node owner,
                                   String elemName)
                            throws XSPFException
        Returns true whether the given owner has any child elements having the given name.
        Parameters:
        owner -
        elemName -
        Returns:
        Throws:
        XSPFException
      • getElementValue

        public String getElementValue​(Element elem)
                               throws XSPFException
        Returns the value of the given element's content. Fails if no such.
        Parameters:
        elem -
        Returns:
        Throws:
        XSPFException
      • getElementValueOrNull

        public String getElementValueOrNull​(Element elem)
                                     throws XSPFException
        Returns the value of the given element's content. Returns null if no such.
        Parameters:
        elem -
        Returns:
        Throws:
        XSPFException
      • setElementValue

        public void setElementValue​(Element elem,
                                    String value)
        Sets the value of the given element's content.
        Parameters:
        elem -
        value -
      • getAttrValue

        public String getAttrValue​(Element elem,
                                   String attrName)
                            throws XSPFException
        Returns the value of the given element's attribute. Fails if no such.
        Parameters:
        elem -
        attrName -
        Returns:
        Throws:
        XSPFException
      • getAttrValueOrNull

        public String getAttrValueOrNull​(Element elem,
                                         String attrName)
                                  throws XSPFException
        Returns the value of the given element's attribute. Returns null if no such.
        Parameters:
        elem -
        attrName -
        Returns:
        Throws:
        XSPFException
      • setAttrValue

        public void setAttrValue​(Element elem,
                                 String attrName,
                                 String value)
        Sets the value of the given element's attribute.
        Parameters:
        elem -
        attrName -
        value -
      • clone

        public Element clone​(Element elem)
        Clones the given elment. Returns the clone.
        Parameters:
        elem -
        Returns: