Class DOMElement

java.lang.Object
org.eclipse.lemminx.dom.DOMNode
org.eclipse.lemminx.dom.DOMElement
All Implemented Interfaces:
DOMRange, Element, Node

public class DOMElement extends DOMNode implements Element
An Element node.
  • Constructor Details

    • DOMElement

      public DOMElement(int start, int end)
  • Method Details

    • getNodeType

      public short getNodeType()
      Specified by:
      getNodeType in interface Node
    • getNodeName

      public String getNodeName()
      Specified by:
      getNodeName in interface Node
    • getTagName

      public String getTagName()
      Specified by:
      getTagName in interface Element
    • hasTagName

      public boolean hasTagName()
      Returns true if the DOM element have a tag name and false otherwise (ex : '<' or '</').
      Returns:
      true if the DOM element have a tag name and false otherwise (ex : '<' or '</').
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface Node
      Overrides:
      getLocalName in class DOMNode
    • getPrefix

      public String getPrefix()
      Specified by:
      getPrefix in interface Node
      Overrides:
      getPrefix in class DOMNode
    • getNamespaceURI

      public String getNamespaceURI()
      Specified by:
      getNamespaceURI in interface Node
      Overrides:
      getNamespaceURI in class DOMNode
    • getNamespaceURI

      public String getNamespaceURI(String prefix)
      Returns the namespace URI for the given prefix and null otherwise.
      Parameters:
      prefix - the prefix.
      Returns:
      the namespace URI for the given prefix and null otherwise.
    • getAllPrefixes

      public Collection<String> getAllPrefixes()
    • getPrefix

      public String getPrefix(String namespaceURI)
      Returns the xmlns prefix from the given namespace URI and null otherwise.
      Parameters:
      namespaceURI - the namespace
      Returns:
      the xmlns prefix from the given namespace URI and null otherwise.
    • isDocumentElement

      public boolean isDocumentElement()
    • isSelfClosed

      public boolean isSelfClosed()
    • endsWith

      public Integer endsWith(char c, int startOffset)
      Will traverse backwards from the start offset returning an offset of the given character if it's found before another character. Whitespace is ignored. Returns null if the character is not found. The initial value for the start offset is not included. So have the offset 1 position after the character you want to start at.
    • isSameTag

      public boolean isSameTag(String tag)
      Returns true if the given tag is the same tag of this element and false otherwise.
      Parameters:
      tag - tag element
      Returns:
      true if the given tag is the same tag of this element and false otherwise.
    • isInStartTag

      public boolean isInStartTag(int offset)
    • isInEndTag

      public boolean isInEndTag(int offset)
    • isInEndTag

      public boolean isInEndTag(int offset, boolean afterBackSlash)
    • isInInsideStartEndTag

      public boolean isInInsideStartEndTag(int offset)
    • getStartTagOpenOffset

      public int getStartTagOpenOffset()
      Returns the start tag open offset and DOMNode.NULL_VALUE if it doesn't exist.
      Returns:
      the start tag open offset and DOMNode.NULL_VALUE if it doesn't exist.
    • getStartTagCloseOffset

      public int getStartTagCloseOffset()
      Returns the start tag close offset and DOMNode.NULL_VALUE if it doesn't exist.
      Returns:
      the start tag close offset and DOMNode.NULL_VALUE if it doesn't exist.
    • getEndTagOpenOffset

      public int getEndTagOpenOffset()
      Returns the end tag open offset and DOMNode.NULL_VALUE if it doesn't exist.
      Returns:
      the end tag open offset and DOMNode.NULL_VALUE if it doesn't exist.
    • getEndTagCloseOffset

      public int getEndTagCloseOffset()
      Returns the end tag close offset and DOMNode.NULL_VALUE if it doesn't exist.
      Returns:
      the end tag close offset and DOMNode.NULL_VALUE if it doesn't exist.
    • hasStartTag

      public boolean hasStartTag()
      Returns true if has a start tag. In our source-oriented DOM, a lone end tag will cause a node to be created in the tree, unlike well-formed-only DOMs.
      Returns:
      true if has a start tag.
    • hasEndTag

      public boolean hasEndTag()
      Returns true if has an end tag. In our source-oriented DOM, sometimes Elements are "ended", even without an explicit end tag in the source.
      Returns:
      true if has an end tag.
    • isStartTagClosed

      public boolean isStartTagClosed()
      If '>' exists in
    • isEndTagClosed

      public boolean isEndTagClosed()
      If '>' exists in
    • getOffsetAfterStartTag

      public int getOffsetAfterStartTag()
      Returns the offset after the start tag name. <foo| >
      Returns:
      the offset after the start tag name.
    • getOffsetBeforeCloseOfStartTag

      public int getOffsetBeforeCloseOfStartTag()
      Returns the offset before the close of start tag name. <foo |> <foo |/>
      Returns:
      the offset before the close of start tag name.
    • isOrphanEndTag

      public boolean isOrphanEndTag()
      Returns true if the given element is an orphan end tag (which has no start tag, eg: ) and false otherwise.
      Returns:
      true if the given element is an orphan end tag (which has no start tag, eg: ) and false otherwise.
    • isOrphanEndTagOf

      public boolean isOrphanEndTagOf(String tagName)
      Returns true if the given element is an orphan end tag (which has no start tag, eg: ) of the given tag name and false otherwise.
      Parameters:
      tagName - the end tag name.
      Returns:
      true if the given element is an orphan end tag (which has no start tag, eg: ) of the given tag name and false otherwise.
    • getUnclosedStartTagCloseOffset

      public int getUnclosedStartTagCloseOffset()
      Returns the offset at which the given unclosed start tag should be closed with an angle bracket
    • getOrphanEndElement

      public DOMElement getOrphanEndElement(int offset, String tagName, boolean anyOrphan)
      Description copied from class: DOMNode
      Returns the orphan end element after the given offset which matches the given tagName and the first orphan end element otherwise and null otherwise. The following sample sample with tagName=bar will returns the <\foo> orphan end element:

      | <\foo>

      Overrides:
      getOrphanEndElement in class DOMNode
      Parameters:
      offset - the offset.
      tagName - the tag name.
      anyOrphan - true if any orphan should be returned and false otherwise.
      Returns:
      the orphan end element after the given offset which matches the given tagName and the first orphan end element otherwise and null otherwise.
    • isClosed

      public boolean isClosed()
      Returns true if element has a closing end tag (eg: ) and false otherwise (eg: ).
      Overrides:
      isClosed in class DOMNode
      Returns:
      true if element has a closing end tag (eg: ) and false otherwise (eg: ).
    • getAttributeNS

      public String getAttributeNS(String namespaceURI, String localName) throws DOMException
      Specified by:
      getAttributeNS in interface Element
      Throws:
      DOMException
    • getAttributeNode

      public DOMAttr getAttributeNode(String name)
      Specified by:
      getAttributeNode in interface Element
      Overrides:
      getAttributeNode in class DOMNode
    • getAttributeNodeNS

      public DOMAttr getAttributeNodeNS(String arg0, String arg1) throws DOMException
      Specified by:
      getAttributeNodeNS in interface Element
      Throws:
      DOMException
    • getElementsByTagName

      public NodeList getElementsByTagName(String arg0)
      Specified by:
      getElementsByTagName in interface Element
    • getElementsByTagNameNS

      public NodeList getElementsByTagNameNS(String arg0, String arg1) throws DOMException
      Specified by:
      getElementsByTagNameNS in interface Element
      Throws:
      DOMException
    • getSchemaTypeInfo

      public TypeInfo getSchemaTypeInfo()
      Specified by:
      getSchemaTypeInfo in interface Element
    • hasAttributeNS

      public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException
      Specified by:
      hasAttributeNS in interface Element
      Throws:
      DOMException
    • removeAttribute

      public void removeAttribute(String arg0) throws DOMException
      Specified by:
      removeAttribute in interface Element
      Throws:
      DOMException
    • removeAttributeNS

      public void removeAttributeNS(String arg0, String arg1) throws DOMException
      Specified by:
      removeAttributeNS in interface Element
      Throws:
      DOMException
    • removeAttributeNode

      public DOMAttr removeAttributeNode(Attr arg0) throws DOMException
      Specified by:
      removeAttributeNode in interface Element
      Throws:
      DOMException
    • setAttributeNS

      public void setAttributeNS(String arg0, String arg1, String arg2) throws DOMException
      Specified by:
      setAttributeNS in interface Element
      Throws:
      DOMException
    • setAttributeNode

      public DOMAttr setAttributeNode(Attr arg0) throws DOMException
      Specified by:
      setAttributeNode in interface Element
      Throws:
      DOMException
    • setAttributeNodeNS

      public DOMAttr setAttributeNodeNS(Attr arg0) throws DOMException
      Specified by:
      setAttributeNodeNS in interface Element
      Throws:
      DOMException
    • setIdAttribute

      public void setIdAttribute(String arg0, boolean arg1) throws DOMException
      Specified by:
      setIdAttribute in interface Element
      Throws:
      DOMException
    • setIdAttributeNS

      public void setIdAttributeNS(String arg0, String arg1, boolean arg2) throws DOMException
      Specified by:
      setIdAttributeNS in interface Element
      Throws:
      DOMException
    • setIdAttributeNode

      public void setIdAttributeNode(Attr arg0, boolean arg1) throws DOMException
      Specified by:
      setIdAttributeNode in interface Element
      Throws:
      DOMException
    • isEmpty

      public boolean isEmpty()
      Returns true if the element is empty and false otherwise.
      Returns:
      true if the element is empty and false otherwise.
    • findTextAt

      public DOMText findTextAt(int offset)
      Returns the DOM text node from the given offset and null otherwise.
      Parameters:
      offset - the offset.
      Returns:
      the DOM text node from the given offset and null otherwise.