Class DOMNode

java.lang.Object
org.eclipse.lemminx.dom.DOMNode
All Implemented Interfaces:
DOMRange, Node
Direct Known Subclasses:
DOMAttr, DOMCharacterData, DOMDocument, DOMElement, DTDDeclNode

public abstract class DOMNode extends Object implements Node, DOMRange
DOM node.
  • Field Details

    • NULL_VALUE

      public static final int NULL_VALUE
      Null value used for offset.
      See Also:
    • DTD_ELEMENT_DECL_NODE

      public static final short DTD_ELEMENT_DECL_NODE
      The node is a DTD Element Declaration.
      See Also:
    • DTD_ATT_LIST_NODE

      public static final short DTD_ATT_LIST_NODE
      The node is a DTD Attribute List.
      See Also:
    • DTD_ENTITY_DECL_NODE

      public static final short DTD_ENTITY_DECL_NODE
      The node is a DTD Entity Declaraction.
      See Also:
    • DTD_NOTATION_DECL

      public static final short DTD_NOTATION_DECL
      The node is a DTD Notation Declaraction.
      See Also:
    • DTD_DECL_NODE

      public static final short DTD_DECL_NODE
      The node is a generic DTD Decl Node.
      See Also:
  • Constructor Details

    • DOMNode

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

    • getOwnerDocument

      public DOMDocument getOwnerDocument()
      Returns the owner document and null otherwise.
      Specified by:
      getOwnerDocument in interface DOMRange
      Specified by:
      getOwnerDocument in interface Node
      Returns:
      the owner document and null otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • findNodeBefore

      public DOMNode findNodeBefore(int offset)
      Returns the node before
    • findNodeAt

      public DOMNode findNodeAt(int offset)
    • isIncluded

      public static boolean isIncluded(DOMRange node, int offset)
      Returns true if the node included the given offset and false otherwise.
      Parameters:
      node -
      offset -
      Returns:
      true if the node included the given offset and false otherwise.
    • isIncluded

      public static boolean isIncluded(int start, int end, int offset)
    • findAttrAt

      public DOMAttr findAttrAt(int offset)
    • findAttrAt

      public static DOMAttr findAttrAt(DOMNode node, int offset)
    • findTextAt

      public static DOMText findTextAt(DOMNode node, int offset)
    • findNodeOrAttrAt

      public static DOMNode findNodeOrAttrAt(DOMDocument document, int offset)
    • getAttributeNode

      public DOMAttr getAttributeNode(String name)
    • getAttributeNode

      public DOMAttr getAttributeNode(String prefix, String suffix)
      Returns the attribute that matches the given name. If there is no namespace, set prefix to null.
    • getAttribute

      public String getAttribute(String name)
    • getAttributeAtIndex

      public DOMAttr getAttributeAtIndex(int index)
      Returns the attribute at the given index, the order is how the attributes appear in the document.
      Parameters:
      index - Starting at 0, index of attribute you want
      Returns:
    • hasAttribute

      public boolean hasAttribute(String name)
    • hasAttributes

      public boolean hasAttributes()
      Specified by:
      hasAttributes in interface Node
    • setAttribute

      public void setAttribute(String name, String value)
    • setAttributeNode

      public void setAttributeNode(DOMAttr attr)
    • getAttributeNodes

      public List<DOMAttr> getAttributeNodes()
    • getChildrenWithAttributeValue

      public List<DOMNode> getChildrenWithAttributeValue(String name, String value)
      Returns a list of children, each having an attribute called name, with a value of value
      Parameters:
      name - name of attribute
      value - value of attribute
      Returns:
      list of children, each having a specified attribute name and value
    • getChildren

      public List<DOMNode> getChildren()
      Returns the node children.
      Returns:
      the node children.
    • addChild

      public void addChild(DOMNode child)
      Add node child and set child.parent to this
      Parameters:
      child - the node child to add.
    • getChild

      public DOMNode getChild(int index)
      Returns node child at the given index.
      Parameters:
      index -
      Returns:
      node child at the given index.
    • isClosed

      public boolean isClosed()
    • getParentElement

      public DOMElement getParentElement()
    • isComment

      public boolean isComment()
    • isProcessingInstruction

      public boolean isProcessingInstruction()
    • isProlog

      public boolean isProlog()
    • isCDATA

      public boolean isCDATA()
    • isDoctype

      public boolean isDoctype()
    • isGenericDTDDecl

      public boolean isGenericDTDDecl()
    • isElement

      public boolean isElement()
    • isAttribute

      public boolean isAttribute()
    • isText

      public boolean isText()
    • isCharacterData

      public boolean isCharacterData()
    • isDTDElementDecl

      public boolean isDTDElementDecl()
    • isDTDAttListDecl

      public boolean isDTDAttListDecl()
    • isDTDEntityDecl

      public boolean isDTDEntityDecl()
    • isDTDNotationDecl

      public boolean isDTDNotationDecl()
    • isOwnerDocument

      public boolean isOwnerDocument()
    • isChildOfOwnerDocument

      public boolean isChildOfOwnerDocument()
    • getStart

      public int getStart()
      Description copied from interface: DOMRange
      Returns the start offset of the node.
      Specified by:
      getStart in interface DOMRange
      Returns:
      the start offset of the node.
    • getEnd

      public int getEnd()
      Description copied from interface: DOMRange
      Returns the end offset of the node.
      Specified by:
      getEnd in interface DOMRange
      Returns:
      the end offset of the node.
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface Node
    • getParentNode

      public DOMNode getParentNode()
      Specified by:
      getParentNode in interface Node
    • getFirstChild

      public DOMNode getFirstChild()
      Specified by:
      getFirstChild in interface Node
    • getLastChild

      public DOMNode getLastChild()
      Specified by:
      getLastChild in interface Node
    • getAttributes

      public NamedNodeMap getAttributes()
      Specified by:
      getAttributes in interface Node
    • getChildNodes

      public NodeList getChildNodes()
      Specified by:
      getChildNodes in interface Node
    • appendChild

      public Node appendChild(Node newChild) throws DOMException
      Specified by:
      appendChild in interface Node
      Throws:
      DOMException
    • cloneNode

      public Node cloneNode(boolean deep)
      Specified by:
      cloneNode in interface Node
    • compareDocumentPosition

      public short compareDocumentPosition(Node other) throws DOMException
      Specified by:
      compareDocumentPosition in interface Node
      Throws:
      DOMException
    • getBaseURI

      public String getBaseURI()
      Specified by:
      getBaseURI in interface Node
    • getFeature

      public Object getFeature(String arg0, String arg1)
      Specified by:
      getFeature in interface Node
    • getNamespaceURI

      public String getNamespaceURI()
      Specified by:
      getNamespaceURI in interface Node
    • getNextSibling

      public DOMNode getNextSibling()
      Specified by:
      getNextSibling in interface Node
    • getNodeValue

      public String getNodeValue() throws DOMException
      Specified by:
      getNodeValue in interface Node
      Throws:
      DOMException
    • getPrefix

      public String getPrefix()
      Specified by:
      getPrefix in interface Node
    • getPreviousSibling

      public DOMNode getPreviousSibling()
      Specified by:
      getPreviousSibling in interface Node
    • getPreviousNonTextSibling

      public DOMNode getPreviousNonTextSibling()
    • getOrphanEndElement

      public DOMElement getOrphanEndElement(int offset, String tagName)
      Returns the orphan end element after the given offset which matches the given tagName and null otherwise. The following sample sample with tagName=foo will returns the <\foo> orphan end element:

      | <\foo>

      Parameters:
      offset - the offset.
      tagName - the tag name.
      Returns:
      the orphan end element after the given offset which matches the given tagName and null otherwise.
    • getOrphanEndElement

      public DOMElement getOrphanEndElement(int offset, String tagName, boolean anyOrphan)
      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>

      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.
    • getTextContent

      public String getTextContent() throws DOMException
      Specified by:
      getTextContent in interface Node
      Throws:
      DOMException
    • getUserData

      public Object getUserData(String arg0)
      Specified by:
      getUserData in interface Node
    • hasChildNodes

      public boolean hasChildNodes()
      Specified by:
      hasChildNodes in interface Node
    • insertBefore

      public Node insertBefore(Node arg0, Node arg1) throws DOMException
      Specified by:
      insertBefore in interface Node
      Throws:
      DOMException
    • isDefaultNamespace

      public boolean isDefaultNamespace(String arg0)
      Specified by:
      isDefaultNamespace in interface Node
    • isEqualNode

      public boolean isEqualNode(Node arg0)
      Specified by:
      isEqualNode in interface Node
    • isSameNode

      public boolean isSameNode(Node arg0)
      Specified by:
      isSameNode in interface Node
    • isSupported

      public boolean isSupported(String arg0, String arg1)
      Specified by:
      isSupported in interface Node
    • lookupNamespaceURI

      public String lookupNamespaceURI(String arg0)
      Specified by:
      lookupNamespaceURI in interface Node
    • lookupPrefix

      public String lookupPrefix(String arg0)
      Specified by:
      lookupPrefix in interface Node
    • normalize

      public void normalize()
      Specified by:
      normalize in interface Node
    • removeChild

      public Node removeChild(Node arg0) throws DOMException
      Specified by:
      removeChild in interface Node
      Throws:
      DOMException
    • replaceChild

      public Node replaceChild(Node arg0, Node arg1) throws DOMException
      Specified by:
      replaceChild in interface Node
      Throws:
      DOMException
    • setNodeValue

      public void setNodeValue(String arg0) throws DOMException
      Specified by:
      setNodeValue in interface Node
      Throws:
      DOMException
    • setPrefix

      public void setPrefix(String arg0) throws DOMException
      Specified by:
      setPrefix in interface Node
      Throws:
      DOMException
    • setTextContent

      public void setTextContent(String arg0) throws DOMException
      Specified by:
      setTextContent in interface Node
      Throws:
      DOMException
    • setUserData

      public Object setUserData(String arg0, Object arg1, UserDataHandler arg2)
      Specified by:
      setUserData in interface Node