Class XMLBean

    • Constructor Detail

      • XMLBean

        public XMLBean​(String docPath)
        Creates new XMLBean.
        Parameters:
        docPath - Path of xml-file.
      • XMLBean

        public XMLBean​(URL docname)
        Creates new XMLBean.
        Parameters:
        docname - URL of xml-file.
      • XMLBean

        public XMLBean​(InputStream is)
        Creates new XMLBean from an input stream; XMLBean is read-only!!!
        Parameters:
        is - contents of the XML structure
    • Method Detail

      • findElement

        public org.jdom.Element findElement​(String xpathExpression)
        Finds an element using an XPATH expression
        Parameters:
        xpathExpression - the expression to evaluate
        Returns:
        the found element
      • getRootElement

        public org.jdom.Element getRootElement()
        Returns the root element.
        Returns:
        the root element
      • getChild

        public org.jdom.Element getChild​(String elemname)
        Returns a child element.
        Parameters:
        elemname - Name of the child.
        Returns:
        the child element
      • getChild

        public org.jdom.Element getChild​(String elemname,
                                         String attribute,
                                         String value)
        This method finds a child by name and attribute.
        Parameters:
        elemname - Name of the child.
        attribute - Name of the child attribute.
        value - Value of the attribute.
        Returns:
        Child
      • getText

        public String getText​(org.jdom.Element elem)
        This returns the text between a begining and an ending tag.
        Parameters:
        elem - Name of the element.
        Returns:
        Text of the element.
      • getChildText

        public String getChildText​(String elemname,
                                   String childname,
                                   String attribute,
                                   String value)
        This method returns the text of a child element characterized by elementname and attribute.
        Parameters:
        elemname - Name of the element.
        childname - Name of the child.
        attribute - Name of the attribute which must element have.
        value - Value of the attribute.
        Returns:
        Text of the child.
      • getAllChildText

        public String getAllChildText​(String elemname,
                                      String attribute,
                                      String value,
                                      String separator1,
                                      String separator2)
        This method returns the text of all children in the format childname<separator1>childtext<separator2>
        Parameters:
        elemname - Name of the root element
        attribute - Name of the attribute which must root element have
        value - Value of the attribute
        separator1 - string used as first separator
        separator2 - string used as second separator
        Returns:
        the children's text
      • getAttribute

        public org.jdom.Attribute getAttribute​(org.jdom.Element elem,
                                               String attrib)
        Returns an element attribute.
        Parameters:
        elem - Name of the element.
        attrib - Name of the attribute.
        Returns:
        Attribute
      • getAttributeValue

        public String getAttributeValue​(org.jdom.Element elem,
                                        String attrib)
        Returns the value of an elementattribute.
        Parameters:
        elem - Name of the element.
        attrib - Name of the attribute.
        Returns:
        Value of the attribute.
      • setAttributeValue

        public void setAttributeValue​(org.jdom.Element elem,
                                      String attrib,
                                      String value)
        This method set the value of an elementattribute.
        Parameters:
        elem - Name of the element.
        attrib - Attribute of the element.
        value - New value of the attribute.
      • setText

        public void setText​(org.jdom.Element elem,
                            String text)
      • writeXMLDoc

        public boolean writeXMLDoc()
        This method saves the xml-file connected by XMLBean. NOTE: only call this on an XMLBean _NOT_ created from an InputStream!
        Returns:
        true if the file has been completely written
      • getRootChild

        public List getRootChild()
        This method returns all direct children of the root element.
        Returns:
        Childrenlist
      • getAllAttribute

        public List getAllAttribute​(org.jdom.Element elem)
        Returns a list of all attributes from an element.
        Parameters:
        elem - Name of the element.
        Returns:
        Attributelist
      • getAllChildren

        public List getAllChildren​(String elemname)
        Returns a list of all elements with the given element.
        Parameters:
        elemname - name of the element
        Returns:
        list of the children elements
      • getAllChildren

        public List getAllChildren​(String elemname,
                                   String attribute,
                                   String value)
        Returns a list of all children with the specific name and the specific attribute value
        Parameters:
        elemname - name of the element
        attribute - name of the attribute
        value - value of the attribute
        Returns:
        the list of children
      • removeChild

        public boolean removeChild​(String elemname)
        Removes an element.
        Parameters:
        elemname - Tag name of the element.
        Returns:
        true if the deletion has been successful