Package org.commonmark.node
Class Node
- java.lang.Object
-
- org.commonmark.node.Node
-
- Direct Known Subclasses:
Block,Code,CustomNode,Emphasis,HardLineBreak,HtmlInline,Image,Link,SoftLineBreak,StrongEmphasis,Text
public abstract class Node extends java.lang.ObjectThe base class of all CommonMark AST nodes (Blockand inlines).A node can have multiple children, and a parent (except for the root node).
-
-
Field Summary
Fields Modifier and Type Field Description private NodefirstChildprivate NodelastChildprivate Nodenextprivate Nodeparentprivate Nodeprevprivate java.util.List<SourceSpan>sourceSpans
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaccept(Visitor visitor)voidaddSourceSpan(SourceSpan sourceSpan)Add a source span to the end of the list.voidappendChild(Node child)NodegetFirstChild()NodegetLastChild()NodegetNext()NodegetParent()NodegetPrevious()java.util.List<SourceSpan>getSourceSpans()voidinsertAfter(Node sibling)Inserts thesiblingnode afterthisnode.voidinsertBefore(Node sibling)Inserts thesiblingnode beforethisnode.voidprependChild(Node child)protected voidsetParent(Node parent)voidsetSourceSpans(java.util.List<SourceSpan> sourceSpans)Replace the current source spans with the provided list.java.lang.StringtoString()protected java.lang.StringtoStringAttributes()voidunlink()
-
-
-
Method Detail
-
accept
public abstract void accept(Visitor visitor)
-
getNext
public Node getNext()
-
getPrevious
public Node getPrevious()
-
getFirstChild
public Node getFirstChild()
-
getLastChild
public Node getLastChild()
-
getParent
public Node getParent()
-
setParent
protected void setParent(Node parent)
-
appendChild
public void appendChild(Node child)
-
prependChild
public void prependChild(Node child)
-
unlink
public void unlink()
-
insertAfter
public void insertAfter(Node sibling)
Inserts thesiblingnode afterthisnode.
-
insertBefore
public void insertBefore(Node sibling)
Inserts thesiblingnode beforethisnode.
-
getSourceSpans
public java.util.List<SourceSpan> getSourceSpans()
- Returns:
- the source spans of this node if included by the parser, an empty list otherwise
- Since:
- 0.16.0
-
setSourceSpans
public void setSourceSpans(java.util.List<SourceSpan> sourceSpans)
Replace the current source spans with the provided list.- Parameters:
sourceSpans- the new source spans to set- Since:
- 0.16.0
-
addSourceSpan
public void addSourceSpan(SourceSpan sourceSpan)
Add a source span to the end of the list.- Parameters:
sourceSpan- the source span to add- Since:
- 0.16.0
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringAttributes
protected java.lang.String toStringAttributes()
-
-