Package org.eclipse.lemminx.dom
Class DOMElement
- java.lang.Object
-
- org.eclipse.lemminx.dom.DOMNode
-
- org.eclipse.lemminx.dom.DOMElement
-
-
Field Summary
-
Fields inherited from class org.eclipse.lemminx.dom.DOMNode
DTD_ATT_LIST_NODE, DTD_DECL_NODE, DTD_ELEMENT_DECL_NODE, DTD_ENTITY_DECL_NODE, DTD_NOTATION_DECL, NULL_VALUE
-
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 DOMElement(int start, int end)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntegerendsWith(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.DOMTextfindTextAt(int offset)Returns the DOM text node from the givenoffsetand null otherwise.Collection<String>getAllPrefixes()DOMAttrgetAttributeNode(String name)DOMAttrgetAttributeNodeNS(String arg0, String arg1)StringgetAttributeNS(String arg0, String arg1)NodeListgetElementsByTagName(String arg0)NodeListgetElementsByTagNameNS(String arg0, String arg1)intgetEndTagCloseOffset()Returns the end tag close offset andDOMNode.NULL_VALUEif it doesn't exist.intgetEndTagOpenOffset()Returns the end tag open offset andDOMNode.NULL_VALUEif it doesn't exist.StringgetLocalName()StringgetNamespaceURI()StringgetNamespaceURI(String prefix)Returns the namespace URI for the given prefix and null otherwise.StringgetNodeName()shortgetNodeType()intgetOffsetAfterStartTag()Returns the offset after the start tag name.intgetOffsetBeforeCloseOfStartTag()Returns the offset before the close of start tag name.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.StringgetPrefix()StringgetPrefix(String namespaceURI)Returns the xmlns prefix from the given namespace URI and null otherwise.TypeInfogetSchemaTypeInfo()intgetStartTagCloseOffset()Returns the start tag close offset andDOMNode.NULL_VALUEif it doesn't exist.intgetStartTagOpenOffset()Returns the start tag open offset andDOMNode.NULL_VALUEif it doesn't exist.StringgetTagName()intgetUnclosedStartTagCloseOffset()Returns the offset at which the given unclosed start tag should be closed with an angle bracketbooleanhasAttributeNS(String arg0, String arg1)booleanhasEndTag()Returns true if has an end tag.booleanhasStartTag()Returns true if has a start tag.booleanhasTagName()Returns true if the DOM element have a tag name and false otherwise (ex : '<' or '').booleanisClosed()Returns true if element has a closing end tag (eg: ) and false otherwise (eg: ).booleanisDocumentElement()booleanisEmpty()Returns true if the element is empty and false otherwise.booleanisEndTagClosed()If '>' exists inbooleanisInEndTag(int offset)booleanisInEndTag(int offset, boolean afterBackSlash)booleanisInInsideStartEndTag(int offset)booleanisInStartTag(int offset)booleanisOrphanEndTag()Returns true if the given element is an orphan end tag (which has no start tag, eg: ) and false otherwise.booleanisOrphanEndTagOf(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.booleanisSameTag(String tag)Returns true if the given tag is the same tag of this element and false otherwise.booleanisSelfClosed()booleanisStartTagClosed()If '>' exists invoidremoveAttribute(String arg0)DOMAttrremoveAttributeNode(Attr arg0)voidremoveAttributeNS(String arg0, String arg1)DOMAttrsetAttributeNode(Attr arg0)DOMAttrsetAttributeNodeNS(Attr arg0)voidsetAttributeNS(String arg0, String arg1, String arg2)voidsetIdAttribute(String arg0, boolean arg1)voidsetIdAttributeNode(Attr arg0, boolean arg1)voidsetIdAttributeNS(String arg0, String arg1, boolean arg2)-
Methods inherited from class org.eclipse.lemminx.dom.DOMNode
addChild, appendChild, cloneNode, compareDocumentPosition, findAttrAt, findAttrAt, findDTDDeclParameterAt, findDTDDeclParameterAt, findNodeAt, findNodeBefore, findNodeOrAttrAt, findTextAt, getAttribute, getAttributeAtIndex, getAttributeNode, getAttributeNodes, getAttributes, getBaseURI, getChild, getChildNodes, getChildren, getChildrenWithAttributeValue, getEnd, getFeature, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOrphanEndElement, getOwnerDocument, getParentElement, getParentNode, getPreviousNonTextSibling, getPreviousSibling, getStart, getTextContent, getUserData, hasAttribute, hasAttributes, hasChildNodes, insertBefore, isAttribute, isCDATA, isCharacterData, isChildOfOwnerDocument, isComment, isDefaultNamespace, isDoctype, isDTDAttListDecl, isDTDElementDecl, isDTDEntityDecl, isDTDNotationDecl, isElement, isEqualNode, isGenericDTDDecl, isIncluded, isIncluded, isOwnerDocument, isProcessingInstruction, isProlog, isSameNode, isSupported, isText, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setAttribute, setAttributeNode, setNodeValue, setPrefix, setTextContent, setUserData, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.w3c.dom.Element
getAttribute, hasAttribute, setAttribute
-
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
-
-
-
Method Detail
-
getNodeType
public short getNodeType()
- Specified by:
getNodeTypein interfaceNode
-
getNodeName
public String getNodeName()
- Specified by:
getNodeNamein interfaceNode
-
getTagName
public String getTagName()
- Specified by:
getTagNamein interfaceElement
-
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:
getLocalNamein interfaceNode- Overrides:
getLocalNamein classDOMNode
-
getPrefix
public String getPrefix()
-
getNamespaceURI
public String getNamespaceURI()
- Specified by:
getNamespaceURIin interfaceNode- Overrides:
getNamespaceURIin classDOMNode
-
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 andDOMNode.NULL_VALUEif it doesn't exist.- Returns:
- the start tag open offset and
DOMNode.NULL_VALUEif it doesn't exist.
-
getStartTagCloseOffset
public int getStartTagCloseOffset()
Returns the start tag close offset andDOMNode.NULL_VALUEif it doesn't exist.- Returns:
- the start tag close offset and
DOMNode.NULL_VALUEif it doesn't exist.
-
getEndTagOpenOffset
public int getEndTagOpenOffset()
Returns the end tag open offset andDOMNode.NULL_VALUEif it doesn't exist.- Returns:
- the end tag open offset and
DOMNode.NULL_VALUEif it doesn't exist.
-
getEndTagCloseOffset
public int getEndTagCloseOffset()
Returns the end tag close offset andDOMNode.NULL_VALUEif it doesn't exist.- Returns:
- the end tag close offset and
DOMNode.NULL_VALUEif 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.- Returns:
- the offset after the start tag name.
-
getOffsetBeforeCloseOfStartTag
public int getOffsetBeforeCloseOfStartTag()
Returns the offset before the close of start tag name.- 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:DOMNodeReturns 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:
getOrphanEndElementin classDOMNode- 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: ).
-
getAttributeNS
public String getAttributeNS(String arg0, String arg1) throws DOMException
- Specified by:
getAttributeNSin interfaceElement- Throws:
DOMException
-
getAttributeNode
public DOMAttr getAttributeNode(String name)
- Specified by:
getAttributeNodein interfaceElement- Overrides:
getAttributeNodein classDOMNode
-
getAttributeNodeNS
public DOMAttr getAttributeNodeNS(String arg0, String arg1) throws DOMException
- Specified by:
getAttributeNodeNSin interfaceElement- Throws:
DOMException
-
getElementsByTagName
public NodeList getElementsByTagName(String arg0)
- Specified by:
getElementsByTagNamein interfaceElement
-
getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String arg0, String arg1) throws DOMException
- Specified by:
getElementsByTagNameNSin interfaceElement- Throws:
DOMException
-
getSchemaTypeInfo
public TypeInfo getSchemaTypeInfo()
- Specified by:
getSchemaTypeInfoin interfaceElement
-
hasAttributeNS
public boolean hasAttributeNS(String arg0, String arg1) throws DOMException
- Specified by:
hasAttributeNSin interfaceElement- Throws:
DOMException
-
removeAttribute
public void removeAttribute(String arg0) throws DOMException
- Specified by:
removeAttributein interfaceElement- Throws:
DOMException
-
removeAttributeNS
public void removeAttributeNS(String arg0, String arg1) throws DOMException
- Specified by:
removeAttributeNSin interfaceElement- Throws:
DOMException
-
removeAttributeNode
public DOMAttr removeAttributeNode(Attr arg0) throws DOMException
- Specified by:
removeAttributeNodein interfaceElement- Throws:
DOMException
-
setAttributeNS
public void setAttributeNS(String arg0, String arg1, String arg2) throws DOMException
- Specified by:
setAttributeNSin interfaceElement- Throws:
DOMException
-
setAttributeNode
public DOMAttr setAttributeNode(Attr arg0) throws DOMException
- Specified by:
setAttributeNodein interfaceElement- Throws:
DOMException
-
setAttributeNodeNS
public DOMAttr setAttributeNodeNS(Attr arg0) throws DOMException
- Specified by:
setAttributeNodeNSin interfaceElement- Throws:
DOMException
-
setIdAttribute
public void setIdAttribute(String arg0, boolean arg1) throws DOMException
- Specified by:
setIdAttributein interfaceElement- Throws:
DOMException
-
setIdAttributeNS
public void setIdAttributeNS(String arg0, String arg1, boolean arg2) throws DOMException
- Specified by:
setIdAttributeNSin interfaceElement- Throws:
DOMException
-
setIdAttributeNode
public void setIdAttributeNode(Attr arg0, boolean arg1) throws DOMException
- Specified by:
setIdAttributeNodein interfaceElement- 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 givenoffsetand null otherwise.- Parameters:
offset- the offset.- Returns:
- the DOM text node from the given
offsetand null otherwise.
-
-