Class AbstractDescriptor

    • Field Summary

      • Fields inherited from class org.jdom.Document

        baseURI
    • Method Summary

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

        addContent, addContent, addContent, addContent, clone, cloneContent, detachRootElement, equals, getBaseURI, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getDocType, getParent, getProperty, getRootElement, hashCode, hasRootElement, indexOf, removeContent, removeContent, removeContent, removeContent, setBaseURI, setContent, setContent, setContent, setContent, setDocType, setProperty, setRootElement, toString
      • Methods inherited from interface org.jdom.Parent

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

      • AbstractDescriptor

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

      • getDocument

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

        public List<org.jdom.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.jdom.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.jdom.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.jdom.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.jdom.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.jdom.Element> getNestedElements​(org.jdom.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.jdom.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.jdom.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.jdom.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.jdom.Element getImmediateChild​(org.jdom.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.jdom.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.jdom.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.jdom.Element addElement​(DescriptorTag tag,
                                           org.jdom.Element child,
                                           org.jdom.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.jdom.Element> haystack,
                                          org.jdom.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.jdom.Element element1,
                                      org.jdom.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.jdom.Element element1,
                                      org.jdom.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.jdom.Content> getContentExceptComments​(org.jdom.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.jdom.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.jdom.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.jdom.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