Package org.commonmark.node
Class Node
- java.lang.Object
-
- org.commonmark.node.Node
-
- Direct Known Subclasses:
Block
,Code
,CustomNode
,Emphasis
,HardLineBreak
,HtmlInline
,Image
,Link
,LinkReferenceDefinition
,SoftLineBreak
,StrongEmphasis
,Text
public abstract class Node extends java.lang.Object
The base class of all CommonMark AST nodes (Block
and inlines).A node can have multiple children, and a parent (except for the root node).
-
-
Field Summary
Fields Modifier and Type Field Description private Node
firstChild
private Node
lastChild
private Node
next
private Node
parent
private Node
prev
private 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 void
accept(Visitor visitor)
void
addSourceSpan(SourceSpan sourceSpan)
Add a source span to the end of the list.void
appendChild(Node child)
Node
getFirstChild()
Node
getLastChild()
Node
getNext()
Node
getParent()
Node
getPrevious()
java.util.List<SourceSpan>
getSourceSpans()
void
insertAfter(Node sibling)
void
insertBefore(Node sibling)
void
prependChild(Node child)
protected void
setParent(Node parent)
void
setSourceSpans(java.util.List<SourceSpan> sourceSpans)
Replace the current source spans with the provided list.java.lang.String
toString()
protected java.lang.String
toStringAttributes()
void
unlink()
-
-
-
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)
-
insertBefore
public void insertBefore(Node sibling)
-
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:
toString
in classjava.lang.Object
-
toStringAttributes
protected java.lang.String toStringAttributes()
-
-