Class AbstractDescriptor

    • Field Summary

      • Fields inherited from class org.jdom2.Document

        baseURI
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.jdom2.Element addElement​(DescriptorTag tag, org.jdom2.Element child, org.jdom2.Element parent)
      Adds an element of the specified tag to the descriptor.
      protected void checkElement​(org.jdom2.Element element, DescriptorTag expectedTag)
      Checks an element whether its name matches the specified name.
      protected boolean containsElement​(List<org.jdom2.Element> haystack, org.jdom2.Element needle)
      Checks if haystack contains needle.
      protected org.jdom2.Element createNestedText​(DescriptorTag tag, String text)
      Creates an element that contains nested text.
      protected String getChildText​(org.jdom2.Element parent, String tagName)
      Returns the text value from a child directly under the parent tag.
      protected String getChildText​(org.jdom2.Element parent, DescriptorTag tag)
      Returns the text value from a child directly under the parent tag.
      protected List<org.jdom2.Content> getContentExceptComments​(org.jdom2.Element element)
      Gets the content of an element (excluding comments).
      DescriptorType getDescriptorType()
      Get the descriptor type for this descriptor.
      org.jdom2.Document getDocument()
      Return the representation as a document.
      List<org.jdom2.Element> getElements​(String tagName)
      Returns a list of the elements that match the specified tag.
      List<org.jdom2.Element> getElements​(DescriptorTag tag)
      Returns a list of the elements that match the specified tag.
      protected org.jdom2.Element getImmediateChild​(org.jdom2.Element parent, DescriptorTag tag)
      Gets a certain tag directly under the parent tag.
      protected org.jdom2.Element getInsertionPointFor​(DescriptorTag tag, String parent)
      Returns the node before which the specified tag should be inserted, or null if the node should be inserted at the end of the descriptor.
      protected List<org.jdom2.Element> getNestedElements​(org.jdom2.Element parent, DescriptorTag tag)
      Returns a list of the child elements of the specified element that match the specified tag.
      protected String getNestedText​(org.jdom2.Element parent, DescriptorTag tag)
      Returns the text nested inside a child element of the specified element.
      org.jdom2.Element getTagByIdentifier​(String tagName, String value)
      Get elements of a particular descriptor tag whose identifier matches the passed parameter.
      org.jdom2.Element getTagByIdentifier​(DescriptorTag tag, String value)
      Get elements of a particular descriptor tag whose identifier matches the passed parameter.
      List<org.jdom2.Element> getTags​(String tagName)
      Get tags of a particular type.
      List<org.jdom2.Element> getTags​(DescriptorTag tag)
      Get tags of a particular type.
      protected String getText​(org.jdom2.Element element)
      Returns the text value of an element.
      protected boolean sameContent​(org.jdom2.Element element1, org.jdom2.Element element2)
      Checks if two elements have the same content (excluding comments).
      protected boolean sameElement​(org.jdom2.Element element1, org.jdom2.Element element2)
      Checks if two elements are the same.
      • Methods inherited from class org.jdom2.Document

        addContent, addContent, addContent, addContent, canContainContent, clone, cloneContent, detachRootElement, equals, getBaseURI, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getDocType, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParent, getProperty, getRootElement, hashCode, hasRootElement, indexOf, removeContent, removeContent, removeContent, removeContent, setBaseURI, setContent, setContent, setContent, setContent, setDocType, setProperty, setRootElement, toString
      • Methods inherited from interface org.jdom2.NamespaceAware

        getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced
      • Methods inherited from interface org.jdom2.Parent

        addContent, addContent, addContent, addContent, canContainContent, clone, cloneContent, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getParent, indexOf, removeContent, removeContent, removeContent, removeContent
    • Constructor Detail

      • AbstractDescriptor

        public AbstractDescriptor​(org.jdom2.Element rootElement,
                                  DescriptorType descriptorType)
        Constructor.
        Parameters:
        rootElement - The root element of the document
        descriptorType - The type of the descriptor
    • Method Detail

      • getDocument

        public org.jdom2.Document getDocument()
        Return the representation as a document.
        Specified by:
        getDocument in interface Descriptor
        Specified by:
        getDocument in interface org.jdom2.Parent
        Overrides:
        getDocument in class org.jdom2.Document
        Returns:
        JDOM Document
      • getTags

        public List<org.jdom2.Element> getTags​(DescriptorTag tag)
        Get tags of a particular type.
        Specified by:
        getTags in interface Descriptor
        Parameters:
        tag - type of elements to find
        Returns:
        list of tags
      • getTags

        public List<org.jdom2.Element> getTags​(String tagName)
        Get tags of a particular type.
        Specified by:
        getTags in interface Descriptor
        Parameters:
        tagName - type of elements to find
        Returns:
        list of tags
      • getElements

        public List<org.jdom2.Element> getElements​(DescriptorTag tag)
        Returns a list of the elements that match the specified tag.
        Parameters:
        tag - The descriptor tag of which the elements should be returned
        Returns:
        A list of the elements matching the tag, in the order they occur in the descriptor
      • getElements

        public List<org.jdom2.Element> getElements​(String tagName)
        Returns a list of the elements that match the specified tag.
        Parameters:
        tagName - The name of a descriptor tag of which the elements should be returned
        Returns:
        A list of the elements matching the tag, in the order they occur in the descriptor
      • checkElement

        protected void checkElement​(org.jdom2.Element element,
                                    DescriptorTag expectedTag)
                             throws IllegalArgumentException
        Checks an element whether its name matches the specified name.
        Parameters:
        element - The element to check
        expectedTag - The expected tag name
        Throws:
        IllegalArgumentException - If the element name doesn't match
      • getNestedElements

        protected List<org.jdom2.Element> getNestedElements​(org.jdom2.Element parent,
                                                            DescriptorTag tag)
        Returns a list of the child elements of the specified element that match the specified tag.
        Parameters:
        parent - The element of which the nested elements should be retrieved
        tag - The descriptor tag of which the elements should be returned
        Returns:
        A copy of the list of the elements matching the tag, in the order they occur in the descriptor
      • createNestedText

        protected org.jdom2.Element createNestedText​(DescriptorTag tag,
                                                     String text)
        Creates an element that contains nested text.
        Parameters:
        tag - The tag to create an instance of
        text - The text that should be nested in the element
        Returns:
        The created DOM element
      • getNestedText

        protected String getNestedText​(org.jdom2.Element parent,
                                       DescriptorTag tag)
        Returns the text nested inside a child element of the specified element.
        Parameters:
        parent - The element of which the nested text should be returned
        tag - The descriptor tag in which the text is nested
        Returns:
        The text nested in the element
      • getText

        protected String getText​(org.jdom2.Element element)
        Returns the text value of an element.
        Parameters:
        element - the element of wich the text value should be returned
        Returns:
        the text value of an element
      • getImmediateChild

        protected org.jdom2.Element getImmediateChild​(org.jdom2.Element parent,
                                                      DescriptorTag tag)
        Gets a certain tag directly under the parent tag.
        Parameters:
        parent - the tag to get the cild from
        tag - name of the child tag
        Returns:
        tag directly under the parent tag.
      • getChildText

        protected String getChildText​(org.jdom2.Element parent,
                                      DescriptorTag tag)
        Returns the text value from a child directly under the parent tag.
        Parameters:
        parent - the parent tag to get the child text from
        tag - the name of the child tag
        Returns:
        the text value of a child tag directly under the parent tag
      • getChildText

        protected String getChildText​(org.jdom2.Element parent,
                                      String tagName)
        Returns the text value from a child directly under the parent tag.
        Parameters:
        parent - the parent tag to get the child text from
        tagName - the name of the child tag
        Returns:
        the text value of a child tag directly under the parent tag
      • addElement

        public org.jdom2.Element addElement​(DescriptorTag tag,
                                            org.jdom2.Element child,
                                            org.jdom2.Element parent)
        Adds an element of the specified tag to the descriptor.
        Specified by:
        addElement in interface Descriptor
        Parameters:
        tag - The descriptor tag
        child - The child element to add
        parent - The parent element to add the child to
        Returns:
        the inserted element
      • containsElement

        protected boolean containsElement​(List<org.jdom2.Element> haystack,
                                          org.jdom2.Element needle)
        Checks if haystack contains needle.
        Parameters:
        haystack - List of element to look into.
        needle - Element to look for.
        Returns:
        Whether haystack contains needle.
      • sameElement

        protected boolean sameElement​(org.jdom2.Element element1,
                                      org.jdom2.Element element2)
        Checks if two elements are the same.
        Parameters:
        element1 - First element.
        element2 - Second element.
        Returns:
        Whether element1 and element2 are the same.
      • sameContent

        protected boolean sameContent​(org.jdom2.Element element1,
                                      org.jdom2.Element element2)
        Checks if two elements have the same content (excluding comments).
        Parameters:
        element1 - First element.
        element2 - Second element.
        Returns:
        Whether element1 and element2 have the same content (excluding comments).
      • getContentExceptComments

        protected List<org.jdom2.Content> getContentExceptComments​(org.jdom2.Element element)
        Gets the content of an element (excluding comments).
        Parameters:
        element - Element to get the contents for.
        Returns:
        All content for element (excluding comments).
      • getInsertionPointFor

        protected org.jdom2.Element getInsertionPointFor​(DescriptorTag tag,
                                                         String parent)
        Returns the node before which the specified tag should be inserted, or null if the node should be inserted at the end of the descriptor.
        Parameters:
        tag - The tag that should be inserted
        parent - name of the parent tag
        Returns:
        The node before which the tag can be inserted
      • getTagByIdentifier

        public org.jdom2.Element getTagByIdentifier​(DescriptorTag tag,
                                                    String value)
        Get elements of a particular descriptor tag whose identifier matches the passed parameter.
        Specified by:
        getTagByIdentifier in interface Descriptor
        Parameters:
        tag - tag to search for
        value - value for the identifier to match
        Returns:
        the element that matches
      • getTagByIdentifier

        public org.jdom2.Element getTagByIdentifier​(String tagName,
                                                    String value)
        Get elements of a particular descriptor tag whose identifier matches the passed parameter.
        Specified by:
        getTagByIdentifier in interface Descriptor
        Parameters:
        tagName - Name of the tag to search for
        value - value for the identifier to match
        Returns:
        the element that matches