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 Object
  • Field Details

    • EMPTY_SEGMENTS

      public static final BasedSequence[] EMPTY_SEGMENTS
    • SPLICE

      public static final String SPLICE
      See Also:
    • AST_ADAPTER

      public static final AstNode<Node> AST_ADAPTER
    • 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 Details

    • Node

      public Node()
    • Node

      public Node(@NotNull @NotNull BasedSequence chars)
  • Method Details

    • 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<Integer,Integer> lineColumnAtIndex(int index)
    • lineColumnAtStart

      public Pair<Integer,Integer> lineColumnAtStart()
    • getLineColumnAtEnd

      public Pair<Integer,Integer> getLineColumnAtEnd()
    • getAncestorOfType

      @Nullable public @Nullable Node getAncestorOfType(@NotNull @NotNull Class<?>... classes)
    • countAncestorsOfType

      public int countAncestorsOfType(@NotNull @NotNull Class<?>... classes)
    • countDirectAncestorsOfType

      public int countDirectAncestorsOfType(@Nullable @Nullable Class<?> skip, @NotNull @NotNull Class<?>... classes)
    • getOldestAncestorOfTypeAfter

      @Nullable public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull @NotNull Class<?> ancestor, @NotNull @NotNull Class<?> after)
    • getChildOfType

      @Nullable public @Nullable Node getChildOfType(@NotNull @NotNull Class<?>... classes)
    • getNodeOfTypeIndex

      public static int getNodeOfTypeIndex(@NotNull @NotNull Node node, @NotNull @NotNull Class<?>... classes)
    • isOrDescendantOfType

      public boolean isOrDescendantOfType(@NotNull @NotNull Class<?>... classes)
    • getNodeOfTypeIndex

      public int getNodeOfTypeIndex(@NotNull @NotNull 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 Class<?>... classes)
    • getPreviousAny

      @Nullable public @Nullable Node getPreviousAny(@NotNull @NotNull Class<?>... classes)
    • getNextAnyNot

      @Nullable public @Nullable Node getNextAnyNot(@NotNull @NotNull Class<?>... classes)
    • getNextAny

      @Nullable public @Nullable Node getNextAny(@NotNull @NotNull Class<?>... classes)
    • getFirstChild

      @Nullable public @Nullable Node getFirstChild()
    • getFirstChildAnyNot

      @Nullable public @Nullable Node getFirstChildAnyNot(@NotNull @NotNull Class<?>... classes)
    • getFirstChildAny

      @Nullable public @Nullable Node getFirstChildAny(@NotNull @NotNull Class<?>... classes)
    • getLastChild

      @Nullable public @Nullable Node getLastChild()
    • getLastChildAnyNot

      @Nullable public @Nullable Node getLastChildAnyNot(@NotNull @NotNull Class<?>... classes)
    • getLastChildAny

      @Nullable public @Nullable Node getLastChildAny(@NotNull @NotNull 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 String toString()
      Overrides:
      toString in class Object
    • getAstExtra

      public void getAstExtra(@NotNull @NotNull StringBuilder out)
    • astExtraChars

      public void astExtraChars(@NotNull @NotNull StringBuilder out)
    • astChars

      public static void astChars(@NotNull @NotNull StringBuilder out, @NotNull @NotNull CharSequence chars, @NotNull @NotNull String name)
    • toStringAttributes

      @NotNull protected @NotNull 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 StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable String name)
    • segmentSpanChars

      public static void segmentSpanChars(@NotNull @NotNull StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable String name, @NotNull @NotNull String chars)
    • segmentSpanChars

      public static void segmentSpanChars(@NotNull @NotNull StringBuilder out, int startOffset, int endOffset, @Nullable @Nullable String name, @NotNull @NotNull String chars1, @NotNull @NotNull String splice, @NotNull @NotNull String chars2)
    • segmentSpan

      public static void segmentSpan(@NotNull @NotNull StringBuilder out, @NotNull @NotNull BasedSequence sequence, @Nullable @Nullable String name)
    • segmentSpanChars

      public static void segmentSpanChars(@NotNull @NotNull StringBuilder out, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull String name)
    • segmentSpanCharsToVisible

      public static void segmentSpanCharsToVisible(@NotNull @NotNull StringBuilder out, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull String name)
    • delimitedSegmentSpan

      public static void delimitedSegmentSpan(@NotNull @NotNull StringBuilder out, @NotNull @NotNull BasedSequence openingSequence, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull BasedSequence closingSequence, @NotNull @NotNull String name)
    • delimitedSegmentSpanChars

      public static void delimitedSegmentSpanChars(@NotNull @NotNull StringBuilder out, @NotNull @NotNull BasedSequence openingSequence, @NotNull @NotNull BasedSequence sequence, @NotNull @NotNull BasedSequence closingSequence, @NotNull @NotNull String name)
    • takeChildren

      public void takeChildren(@NotNull @NotNull Node node)
    • getNodeName

      @NotNull public @NotNull String getNodeName()
    • astString

      public void astString(@NotNull @NotNull StringBuilder out, boolean withExtra)
    • toAstString

      @NotNull public @NotNull String toAstString(boolean withExtra)
    • toSegmentSpan

      @NotNull public static @NotNull String toSegmentSpan(@NotNull @NotNull BasedSequence sequence, @Nullable @Nullable 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