Package com.vladsch.flexmark.util.ast
Class Node
- java.lang.Object
-
- com.vladsch.flexmark.util.ast.Node
-
- Direct Known Subclasses:
Abbreviation
,AnchorLink
,AttributeNode
,AttributesNode
,ContentNode
,DelimitedNodeImpl
,EmbeddedAttributeProvider.EmbeddedNodeAttributes
,Emoji
,EnumeratedReferenceBase
,EscapedCharacter
,Footnote
,GfmIssue
,GfmUser
,GitLabInline
,GitLabInlineMath
,HardLineBreak
,HtmlEntity
,HtmlInlineBase
,Ins
,LinkNodeBase
,Macro
,MacroAttribute
,MacroClose
,MacroReference
,RefNode
,ResizableImage
,SimTocOption
,SimTocOptionList
,SoftLineBreak
,SpecExampleAst
,SpecExampleHtml
,SpecExampleOption
,SpecExampleOptionSeparator
,SpecExampleOptionsList
,SpecExampleSeparator
,SpecExampleSource
,Strikethrough
,Subscript
,Superscript
,TableBody
,TableCaption
,TableCell
,TableColumnSeparator
,TableHead
,TableRow
,TableSeparator
,Text
,TextBase
,TypographicQuotes
,TypographicSmarts
,WhiteSpace
,WikiNode
,YamlFrontMatterNode
,YamlFrontMatterValue
,Zzzzzz
public abstract class Node extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static AstNode<Node>
AST_ADAPTER
private @NotNull BasedSequence
chars
static BasedSequence[]
EMPTY_SEGMENTS
(package private) @Nullable Node
firstChild
private @Nullable Node
lastChild
(package private) @Nullable Node
next
private @Nullable Node
parent
private @Nullable Node
prev
static java.lang.String
SPLICE
-
Constructor Summary
Constructors Constructor Description Node()
Node(@NotNull BasedSequence chars)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
appendChain(@NotNull Node firstNode)
Append all from child to end of chain to this nodevoid
appendChild(Node child)
static void
astChars(@NotNull java.lang.StringBuilder out, @NotNull java.lang.CharSequence chars, @NotNull java.lang.String name)
void
astExtraChars(@NotNull java.lang.StringBuilder out)
void
astString(@NotNull java.lang.StringBuilder out, boolean withExtra)
BasedSequence
baseSubSequence(int startIndex)
BasedSequence
baseSubSequence(int startIndex, int endIndex)
int
countAncestorsOfType(@NotNull java.lang.Class<?>... classes)
int
countDirectAncestorsOfType(@Nullable java.lang.Class<?> skip, @NotNull java.lang.Class<?>... classes)
static void
delimitedSegmentSpan(@NotNull java.lang.StringBuilder out, @NotNull BasedSequence openingSequence, @NotNull BasedSequence sequence, @NotNull BasedSequence closingSequence, @NotNull java.lang.String name)
static void
delimitedSegmentSpanChars(@NotNull java.lang.StringBuilder out, @NotNull BasedSequence openingSequence, @NotNull BasedSequence sequence, @NotNull BasedSequence closingSequence, @NotNull java.lang.String name)
int
endOfLine(int index)
void
extractChainTo(@NotNull Node node)
void
extractToFirstInChain(@NotNull Node node)
@Nullable Node
getAncestorOfType(@NotNull java.lang.Class<?>... classes)
void
getAstExtra(@NotNull java.lang.StringBuilder out)
BasedSequence
getBaseSequence()
@NotNull Node
getBlankLineSibling()
@NotNull BasedSequence
getChars()
@NotNull BasedSequence
getCharsFromSegments()
Get the char sequence from segments making up the node's characters.BasedSequence
getChildChars()
@NotNull ReversiblePeekingIterator<Node>
getChildIterator()
@Nullable Node
getChildOfType(@NotNull java.lang.Class<?>... classes)
@NotNull ReversiblePeekingIterable<Node>
getChildren()
@NotNull ReversiblePeekingIterable<Node>
getDescendants()
@NotNull Document
getDocument()
BasedSequence
getEmptyPrefix()
BasedSequence
getEmptySuffix()
int
getEndLineNumber()
int
getEndOffset()
int
getEndOfLine()
BasedSequence
getExactChildChars()
@Nullable Node
getFirstChild()
@Nullable Node
getFirstChildAny(@NotNull java.lang.Class<?>... classes)
@Nullable Node
getFirstChildAnyNot(@NotNull java.lang.Class<?>... classes)
@NotNull Node
getFirstInChain()
@Nullable Node
getGrandParent()
@Nullable Node
getLastBlankLineChild()
Overridden by ListBlock and any others whose children propagate their blank line to parent@Nullable Node
getLastChild()
@Nullable Node
getLastChildAny(@NotNull java.lang.Class<?>... classes)
@Nullable Node
getLastChildAnyNot(@NotNull java.lang.Class<?>... classes)
@NotNull Node
getLastInChain()
static @NotNull BasedSequence
getLeadSegment(@NotNull BasedSequence[] segments)
Pair<java.lang.Integer,java.lang.Integer>
getLineColumnAtEnd()
int
getLineNumber()
@Nullable Node
getNext()
@Nullable Node
getNextAny(@NotNull java.lang.Class<?>... classes)
@Nullable Node
getNextAnyNot(@NotNull java.lang.Class<?>... classes)
@NotNull java.lang.String
getNodeName()
static int
getNodeOfTypeIndex(@NotNull Node node, @NotNull java.lang.Class<?>... classes)
int
getNodeOfTypeIndex(@NotNull java.lang.Class<?>... classes)
@Nullable Node
getOldestAncestorOfTypeAfter(@NotNull java.lang.Class<?> ancestor, @NotNull java.lang.Class<?> after)
@Nullable Node
getParent()
@Nullable Node
getPrevious()
@Nullable Node
getPreviousAny(@NotNull java.lang.Class<?>... classes)
@Nullable Node
getPreviousAnyNot(@NotNull java.lang.Class<?>... classes)
@NotNull ReversiblePeekingIterator<Node>
getReversedChildIterator()
@NotNull ReversiblePeekingIterable<Node>
getReversedChildren()
@NotNull ReversiblePeekingIterable<Node>
getReversedDescendants()
abstract @NotNull BasedSequence[]
getSegments()
@NotNull BasedSequence[]
getSegmentsForChars()
Get the segments making up the node's characters.Range
getSourceRange()
int
getStartLineNumber()
int
getStartOffset()
int
getStartOfLine()
int
getTextLength()
static @NotNull BasedSequence
getTrailSegment(BasedSequence[] segments)
boolean
hasChildren()
boolean
hasOrMoreChildren(int childCount)
void
insertAfter(@NotNull Node sibling)
void
insertBefore(Node sibling)
void
insertChainAfter(@NotNull Node firstNode)
Append all from child to end of chain to this nodevoid
insertChainBefore(@NotNull Node firstNode)
Append all from child to end of chain to this nodeboolean
isOrDescendantOfType(@NotNull java.lang.Class<?>... classes)
Pair<java.lang.Integer,java.lang.Integer>
lineColumnAtIndex(int index)
Pair<java.lang.Integer,java.lang.Integer>
lineColumnAtStart()
void
moveTrailingBlankLines()
void
prependChild(@NotNull Node child)
void
removeChildren()
static void
segmentSpan(@NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable java.lang.String name)
static void
segmentSpan(@NotNull java.lang.StringBuilder out, @NotNull BasedSequence sequence, @Nullable java.lang.String name)
static void
segmentSpanChars(@NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable java.lang.String name, @NotNull java.lang.String chars)
static void
segmentSpanChars(@NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable java.lang.String name, @NotNull java.lang.String chars1, @NotNull java.lang.String splice, @NotNull java.lang.String chars2)
static void
segmentSpanChars(@NotNull java.lang.StringBuilder out, @NotNull BasedSequence sequence, @NotNull java.lang.String name)
static void
segmentSpanCharsToVisible(@NotNull java.lang.StringBuilder out, @NotNull BasedSequence sequence, @NotNull java.lang.String name)
void
setChars(@NotNull BasedSequence chars)
void
setCharsFromContent()
void
setCharsFromContentOnly()
void
setCharsFromSegments()
Set the node's char string from segments making up the node's characters.protected void
setParent(@Nullable Node parent)
static @NotNull BasedSequence
spanningChars(BasedSequence... segments)
int
startOfLine(int index)
void
takeChildren(@NotNull Node node)
@NotNull java.lang.String
toAstString(boolean withExtra)
static @NotNull java.lang.String
toSegmentSpan(@NotNull BasedSequence sequence, @Nullable java.lang.String name)
java.lang.String
toString()
protected @NotNull java.lang.String
toStringAttributes()
void
unlink()
-
-
-
Field Detail
-
EMPTY_SEGMENTS
public static final BasedSequence[] EMPTY_SEGMENTS
-
SPLICE
public static final java.lang.String SPLICE
- See Also:
- Constant Field Values
-
parent
@Nullable private @Nullable Node parent
-
firstChild
@Nullable @Nullable Node firstChild
-
lastChild
@Nullable private @Nullable Node lastChild
-
prev
@Nullable private @Nullable Node prev
-
next
@Nullable @Nullable Node next
-
chars
@NotNull private @NotNull BasedSequence chars
-
-
Constructor Detail
-
Node
public Node()
-
Node
public Node(@NotNull @NotNull BasedSequence chars)
-
-
Method Detail
-
getStartOffset
public int getStartOffset()
-
getEndOffset
public int getEndOffset()
-
getTextLength
public int getTextLength()
-
getBaseSequence
public BasedSequence getBaseSequence()
-
getSourceRange
public Range getSourceRange()
-
baseSubSequence
public BasedSequence baseSubSequence(int startIndex, int endIndex)
-
baseSubSequence
public BasedSequence baseSubSequence(int startIndex)
-
getEmptyPrefix
public BasedSequence getEmptyPrefix()
-
getEmptySuffix
public BasedSequence getEmptySuffix()
-
getStartOfLine
public int getStartOfLine()
-
getEndOfLine
public int getEndOfLine()
-
startOfLine
public int startOfLine(int index)
-
endOfLine
public int endOfLine(int index)
-
lineColumnAtIndex
public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int index)
-
lineColumnAtStart
public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart()
-
getLineColumnAtEnd
public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd()
-
getAncestorOfType
@Nullable public @Nullable Node getAncestorOfType(@NotNull @NotNull java.lang.Class<?>... classes)
-
countAncestorsOfType
public int countAncestorsOfType(@NotNull @NotNull java.lang.Class<?>... classes)
-
countDirectAncestorsOfType
public int countDirectAncestorsOfType(@Nullable @Nullable java.lang.Class<?> skip, @NotNull @NotNull java.lang.Class<?>... classes)
-
getOldestAncestorOfTypeAfter
@Nullable public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull @NotNull java.lang.Class<?> ancestor, @NotNull @NotNull java.lang.Class<?> after)
-
getChildOfType
@Nullable public @Nullable Node getChildOfType(@NotNull @NotNull java.lang.Class<?>... classes)
-
getNodeOfTypeIndex
public static int getNodeOfTypeIndex(@NotNull @NotNull Node node, @NotNull @NotNull java.lang.Class<?>... classes)
-
isOrDescendantOfType
public boolean isOrDescendantOfType(@NotNull @NotNull java.lang.Class<?>... classes)
-
getNodeOfTypeIndex
public int getNodeOfTypeIndex(@NotNull @NotNull java.lang.Class<?>... classes)
-
getLastBlankLineChild
@Nullable public @Nullable Node getLastBlankLineChild()
Overridden by ListBlock and any others whose children propagate their blank line to parent- Returns:
- return a child block that can contain the parent's last blank line
-
getChildren
@NotNull public @NotNull ReversiblePeekingIterable<Node> getChildren()
-
getReversedChildren
@NotNull public @NotNull ReversiblePeekingIterable<Node> getReversedChildren()
-
getDescendants
@NotNull public @NotNull ReversiblePeekingIterable<Node> getDescendants()
-
getReversedDescendants
@NotNull public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants()
-
getChildIterator
@NotNull public @NotNull ReversiblePeekingIterator<Node> getChildIterator()
-
getReversedChildIterator
@NotNull public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator()
-
getChars
@NotNull public @NotNull BasedSequence getChars()
-
removeChildren
public void removeChildren()
-
hasChildren
public boolean hasChildren()
-
hasOrMoreChildren
public boolean hasOrMoreChildren(int childCount)
-
getDocument
@NotNull public @NotNull Document getDocument()
-
setChars
public void setChars(@NotNull @NotNull BasedSequence chars)
-
getNext
@Nullable public @Nullable Node getNext()
-
getLastInChain
@NotNull public @NotNull Node getLastInChain()
-
getPrevious
@Nullable public @Nullable Node getPrevious()
-
extractToFirstInChain
public void extractToFirstInChain(@NotNull @NotNull Node node)
-
extractChainTo
public void extractChainTo(@NotNull @NotNull Node node)
-
getFirstInChain
@NotNull public @NotNull Node getFirstInChain()
-
getPreviousAnyNot
@Nullable public @Nullable Node getPreviousAnyNot(@NotNull @NotNull java.lang.Class<?>... classes)
-
getPreviousAny
@Nullable public @Nullable Node getPreviousAny(@NotNull @NotNull java.lang.Class<?>... classes)
-
getNextAnyNot
@Nullable public @Nullable Node getNextAnyNot(@NotNull @NotNull java.lang.Class<?>... classes)
-
getNextAny
@Nullable public @Nullable Node getNextAny(@NotNull @NotNull java.lang.Class<?>... classes)
-
getFirstChild
@Nullable public @Nullable Node getFirstChild()
-
getFirstChildAnyNot
@Nullable public @Nullable Node getFirstChildAnyNot(@NotNull @NotNull java.lang.Class<?>... classes)
-
getFirstChildAny
@Nullable public @Nullable Node getFirstChildAny(@NotNull @NotNull java.lang.Class<?>... classes)
-
getLastChild
@Nullable public @Nullable Node getLastChild()
-
getLastChildAnyNot
@Nullable public @Nullable Node getLastChildAnyNot(@NotNull @NotNull java.lang.Class<?>... classes)
-
getLastChildAny
@Nullable public @Nullable Node getLastChildAny(@NotNull @NotNull java.lang.Class<?>... classes)
-
getParent
@Nullable public @Nullable Node getParent()
-
getGrandParent
@Nullable public @Nullable Node getGrandParent()
-
setParent
protected void setParent(@Nullable @Nullable Node parent)
-
appendChild
public void appendChild(Node child)
-
prependChild
public void prependChild(@NotNull @NotNull Node child)
-
unlink
public void unlink()
-
insertAfter
public void insertAfter(@NotNull @NotNull Node sibling)
-
insertBefore
public void insertBefore(Node sibling)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getAstExtra
public void getAstExtra(@NotNull @NotNull java.lang.StringBuilder out)
-
astExtraChars
public void astExtraChars(@NotNull @NotNull java.lang.StringBuilder out)
-
astChars
public static void astChars(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull java.lang.CharSequence chars, @NotNull @NotNull java.lang.String name)
-
toStringAttributes
@NotNull protected @NotNull java.lang.String toStringAttributes()
-
getSegments
@NotNull public abstract @NotNull BasedSequence[] getSegments()
-
getLeadSegment
@NotNull public static @NotNull BasedSequence getLeadSegment(@NotNull @NotNull BasedSequence[] segments)
-
getTrailSegment
@NotNull public static @NotNull BasedSequence getTrailSegment(BasedSequence[] segments)
-
spanningChars
@NotNull public static @NotNull BasedSequence spanningChars(BasedSequence... segments)
-
setCharsFromContentOnly
public void setCharsFromContentOnly()
-
setCharsFromContent
public void setCharsFromContent()
-
segmentSpan
public static void segmentSpan(@NotNull @NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable java.lang.String name)
-
segmentSpanChars
public static void segmentSpanChars(@NotNull @NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable java.lang.String name, @NotNull @NotNull java.lang.String chars)
-
segmentSpanChars
public static void segmentSpanChars(@NotNull @NotNull java.lang.StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable java.lang.String name, @NotNull @NotNull java.lang.String chars1, @NotNull @NotNull java.lang.String splice, @NotNull @NotNull java.lang.String chars2)
-
segmentSpan
public static void segmentSpan(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull BasedSequence sequence, @Nullable @Nullable java.lang.String name)
-
segmentSpanChars
public static void segmentSpanChars(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull java.lang.String name)
-
segmentSpanCharsToVisible
public static void segmentSpanCharsToVisible(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull java.lang.String name)
-
delimitedSegmentSpan
public static void delimitedSegmentSpan(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull BasedSequence openingSequence, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull BasedSequence closingSequence, @NotNull @NotNull java.lang.String name)
-
delimitedSegmentSpanChars
public static void delimitedSegmentSpanChars(@NotNull @NotNull java.lang.StringBuilder out, @NotNull @NotNull BasedSequence openingSequence, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull BasedSequence closingSequence, @NotNull @NotNull java.lang.String name)
-
takeChildren
public void takeChildren(@NotNull @NotNull Node node)
-
getNodeName
@NotNull public @NotNull java.lang.String getNodeName()
-
astString
public void astString(@NotNull @NotNull java.lang.StringBuilder out, boolean withExtra)
-
toAstString
@NotNull public @NotNull java.lang.String toAstString(boolean withExtra)
-
toSegmentSpan
@NotNull public static @NotNull java.lang.String toSegmentSpan(@NotNull @NotNull BasedSequence sequence, @Nullable @Nullable java.lang.String name)
-
getChildChars
public BasedSequence getChildChars()
-
getExactChildChars
public BasedSequence getExactChildChars()
-
getBlankLineSibling
@NotNull public @NotNull Node getBlankLineSibling()
-
moveTrailingBlankLines
public void moveTrailingBlankLines()
-
getLineNumber
public int getLineNumber()
-
getStartLineNumber
public int getStartLineNumber()
-
getEndLineNumber
public int getEndLineNumber()
-
getSegmentsForChars
@NotNull public @NotNull BasedSequence[] getSegmentsForChars()
Get the segments making up the node's characters.Used to get segments after the some of the node's elements were modified
- Returns:
- array of segments
-
getCharsFromSegments
@NotNull public @NotNull BasedSequence getCharsFromSegments()
Get the char sequence from segments making up the node's characters.Used to get segments after the some of the node's elements were modified
- Returns:
- concatenated string of all segments
-
setCharsFromSegments
public void setCharsFromSegments()
Set the node's char string from segments making up the node's characters.Used to get segments after the some of the node's elements were modified
-
appendChain
public void appendChain(@NotNull @NotNull Node firstNode)
Append all from child to end of chain to this node- Parameters:
firstNode
- first child in chain
-
insertChainAfter
public void insertChainAfter(@NotNull @NotNull Node firstNode)
Append all from child to end of chain to this node- Parameters:
firstNode
- first child in chain
-
insertChainBefore
public void insertChainBefore(@NotNull @NotNull Node firstNode)
Append all from child to end of chain to this node- Parameters:
firstNode
- first child in chain
-
-