Package org.eclipse.lemminx.dom
Class DOMNode
- java.lang.Object
-
- org.eclipse.lemminx.dom.DOMNode
-
- Direct Known Subclasses:
DOMAttr,DOMCharacterData,DOMDocument,DOMElement,DTDDeclNode
public abstract class DOMNode extends Object implements Node, DOMRange
DOM node.
-
-
Field Summary
Fields Modifier and Type Field Description static shortDTD_ATT_LIST_NODEThe node is aDTD Attribute List.static shortDTD_DECL_NODEThe node is a genericDTD Decl Node.static shortDTD_ELEMENT_DECL_NODEThe node is aDTD Element Declaration.static shortDTD_ENTITY_DECL_NODEThe node is aDTD Entity Declaraction.static shortDTD_NOTATION_DECLThe node is aDTD Notation Declaraction.static intNULL_VALUENull value used for offset.-
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
-
Constructor Summary
Constructors Constructor Description DOMNode(int start, int end)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(DOMNode child)Add node child and set child.parent tothisNodeappendChild(Node newChild)NodecloneNode(boolean deep)shortcompareDocumentPosition(Node other)DOMAttrfindAttrAt(int offset)static DOMAttrfindAttrAt(DOMNode node, int offset)DTDDeclParameterfindDTDDeclParameterAt(int offset)static DTDDeclParameterfindDTDDeclParameterAt(DOMNode node, int offset)DOMNodefindNodeAt(int offset)DOMNodefindNodeBefore(int offset)Returns the node beforestatic DOMNodefindNodeOrAttrAt(DOMDocument document, int offset)static DOMTextfindTextAt(DOMNode node, int offset)StringgetAttribute(String name)DOMAttrgetAttributeAtIndex(int index)Returns the attribute at the given index, the order is how the attributes appear in the document.DOMAttrgetAttributeNode(String name)DOMAttrgetAttributeNode(String prefix, String suffix)Returns the attribute that matches the given name.List<DOMAttr>getAttributeNodes()NamedNodeMapgetAttributes()StringgetBaseURI()DOMNodegetChild(int index)Returns node child at the given index.NodeListgetChildNodes()List<DOMNode>getChildren()Returns the node children.List<DOMNode>getChildrenWithAttributeValue(String name, String value)Returns a list of children, each having an attribute called name, with a value of valueintgetEnd()Returns the end offset of the node.ObjectgetFeature(String arg0, String arg1)DOMNodegetFirstChild()DOMNodegetLastChild()StringgetLocalName()StringgetNamespaceURI()DOMNodegetNextSibling()StringgetNodeValue()DOMElementgetOrphanEndElement(int offset, String tagName)Returns the orphan end element after the given offset which matches the given tagName and null otherwise.DOMElementgetOrphanEndElement(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.DOMDocumentgetOwnerDocument()Returns the owner document and null otherwise.DOMElementgetParentElement()DOMNodegetParentNode()StringgetPrefix()DOMNodegetPreviousNonTextSibling()DOMNodegetPreviousSibling()intgetStart()Returns the start offset of the node.StringgetTextContent()ObjectgetUserData(String arg0)booleanhasAttribute(String name)booleanhasAttributes()booleanhasChildNodes()NodeinsertBefore(Node arg0, Node arg1)booleanisAttribute()booleanisCDATA()booleanisCharacterData()booleanisChildOfOwnerDocument()booleanisClosed()booleanisComment()booleanisDefaultNamespace(String arg0)booleanisDoctype()booleanisDTDAttListDecl()booleanisDTDElementDecl()booleanisDTDEntityDecl()booleanisDTDNotationDecl()booleanisElement()booleanisEqualNode(Node arg0)booleanisGenericDTDDecl()static booleanisIncluded(int start, int end, int offset)static booleanisIncluded(DOMRange node, int offset)Returns true if the node included the given offset and false otherwise.booleanisOwnerDocument()booleanisProcessingInstruction()booleanisProlog()booleanisSameNode(Node arg0)booleanisSupported(String arg0, String arg1)booleanisText()StringlookupNamespaceURI(String arg0)StringlookupPrefix(String arg0)voidnormalize()NoderemoveChild(Node arg0)NodereplaceChild(Node arg0, Node arg1)voidsetAttribute(String name, String value)voidsetAttributeNode(DOMAttr attr)voidsetNodeValue(String arg0)voidsetPrefix(String arg0)voidsetTextContent(String arg0)ObjectsetUserData(String arg0, Object arg1, UserDataHandler arg2)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType
-
-
-
-
Field Detail
-
NULL_VALUE
public static final int NULL_VALUE
Null value used for offset.- See Also:
- Constant Field Values
-
DTD_ELEMENT_DECL_NODE
public static final short DTD_ELEMENT_DECL_NODE
The node is aDTD Element Declaration.- See Also:
- Constant Field Values
-
DTD_ATT_LIST_NODE
public static final short DTD_ATT_LIST_NODE
The node is aDTD Attribute List.- See Also:
- Constant Field Values
-
DTD_ENTITY_DECL_NODE
public static final short DTD_ENTITY_DECL_NODE
The node is aDTD Entity Declaraction.- See Also:
- Constant Field Values
-
DTD_NOTATION_DECL
public static final short DTD_NOTATION_DECL
The node is aDTD Notation Declaraction.- See Also:
- Constant Field Values
-
DTD_DECL_NODE
public static final short DTD_DECL_NODE
The node is a genericDTD Decl Node.- See Also:
- Constant Field Values
-
-
Method Detail
-
getOwnerDocument
public DOMDocument getOwnerDocument()
Returns the owner document and null otherwise.- Specified by:
getOwnerDocumentin interfaceDOMRange- Specified by:
getOwnerDocumentin interfaceNode- Returns:
- the owner document and null otherwise.
-
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)
-
findDTDDeclParameterAt
public DTDDeclParameter findDTDDeclParameterAt(int offset)
-
findDTDDeclParameterAt
public static DTDDeclParameter findDTDDeclParameterAt(DOMNode node, int offset)
-
findNodeOrAttrAt
public static DOMNode findNodeOrAttrAt(DOMDocument document, int offset)
-
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.
-
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:
hasAttributesin interfaceNode
-
setAttributeNode
public void setAttributeNode(DOMAttr attr)
-
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 attributevalue- 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 tothis- 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:DOMRangeReturns the start offset of the node.
-
getEnd
public int getEnd()
Description copied from interface:DOMRangeReturns the end offset of the node.
-
getLocalName
public String getLocalName()
- Specified by:
getLocalNamein interfaceNode
-
getParentNode
public DOMNode getParentNode()
- Specified by:
getParentNodein interfaceNode
-
getFirstChild
public DOMNode getFirstChild()
- Specified by:
getFirstChildin interfaceNode
-
getLastChild
public DOMNode getLastChild()
- Specified by:
getLastChildin interfaceNode
-
getAttributes
public NamedNodeMap getAttributes()
- Specified by:
getAttributesin interfaceNode
-
getChildNodes
public NodeList getChildNodes()
- Specified by:
getChildNodesin interfaceNode
-
appendChild
public Node appendChild(Node newChild) throws DOMException
- Specified by:
appendChildin interfaceNode- Throws:
DOMException
-
compareDocumentPosition
public short compareDocumentPosition(Node other) throws DOMException
- Specified by:
compareDocumentPositionin interfaceNode- Throws:
DOMException
-
getBaseURI
public String getBaseURI()
- Specified by:
getBaseURIin interfaceNode
-
getFeature
public Object getFeature(String arg0, String arg1)
- Specified by:
getFeaturein interfaceNode
-
getNamespaceURI
public String getNamespaceURI()
- Specified by:
getNamespaceURIin interfaceNode
-
getNextSibling
public DOMNode getNextSibling()
- Specified by:
getNextSiblingin interfaceNode
-
getNodeValue
public String getNodeValue() throws DOMException
- Specified by:
getNodeValuein interfaceNode- Throws:
DOMException
-
getPreviousSibling
public DOMNode getPreviousSibling()
- Specified by:
getPreviousSiblingin interfaceNode
-
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:
getTextContentin interfaceNode- Throws:
DOMException
-
getUserData
public Object getUserData(String arg0)
- Specified by:
getUserDatain interfaceNode
-
hasChildNodes
public boolean hasChildNodes()
- Specified by:
hasChildNodesin interfaceNode
-
insertBefore
public Node insertBefore(Node arg0, Node arg1) throws DOMException
- Specified by:
insertBeforein interfaceNode- Throws:
DOMException
-
isDefaultNamespace
public boolean isDefaultNamespace(String arg0)
- Specified by:
isDefaultNamespacein interfaceNode
-
isEqualNode
public boolean isEqualNode(Node arg0)
- Specified by:
isEqualNodein interfaceNode
-
isSameNode
public boolean isSameNode(Node arg0)
- Specified by:
isSameNodein interfaceNode
-
isSupported
public boolean isSupported(String arg0, String arg1)
- Specified by:
isSupportedin interfaceNode
-
lookupNamespaceURI
public String lookupNamespaceURI(String arg0)
- Specified by:
lookupNamespaceURIin interfaceNode
-
lookupPrefix
public String lookupPrefix(String arg0)
- Specified by:
lookupPrefixin interfaceNode
-
removeChild
public Node removeChild(Node arg0) throws DOMException
- Specified by:
removeChildin interfaceNode- Throws:
DOMException
-
replaceChild
public Node replaceChild(Node arg0, Node arg1) throws DOMException
- Specified by:
replaceChildin interfaceNode- Throws:
DOMException
-
setNodeValue
public void setNodeValue(String arg0) throws DOMException
- Specified by:
setNodeValuein interfaceNode- Throws:
DOMException
-
setPrefix
public void setPrefix(String arg0) throws DOMException
- Specified by:
setPrefixin interfaceNode- Throws:
DOMException
-
setTextContent
public void setTextContent(String arg0) throws DOMException
- Specified by:
setTextContentin interfaceNode- Throws:
DOMException
-
setUserData
public Object setUserData(String arg0, Object arg1, UserDataHandler arg2)
- Specified by:
setUserDatain interfaceNode
-
-