Package com.vladsch.flexmark.util.ast
Class Document
- java.lang.Object
-
- com.vladsch.flexmark.util.ast.Node
-
- com.vladsch.flexmark.util.ast.ContentNode
-
- com.vladsch.flexmark.util.ast.Block
-
- com.vladsch.flexmark.util.ast.Document
-
- All Implemented Interfaces:
Content,DataHolder,MutableDataHolder,MutableDataSetter
public class Document extends Block implements MutableDataHolder
-
-
Field Summary
Fields Modifier and Type Field Description private MutableDataSetdataSetstatic DocumentNULL-
Fields inherited from class com.vladsch.flexmark.util.ast.ContentNode
lineSegments
-
Fields inherited from class com.vladsch.flexmark.util.ast.Node
AST_ADAPTER, EMPTY_SEGMENTS, firstChild, next, SPLICE
-
-
Constructor Summary
Constructors Constructor Description Document(DataHolder options, BasedSequence chars)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull DataHolderaggregate()static @NotNull DataHolderaggregate(@Nullable DataHolder other, @Nullable DataHolder overrides)static @NotNull DataHolderaggregateActions(@NotNull DataHolder other, @NotNull DataHolder overrides)@NotNull MutableDataHolderclear()clear all options out of the data setbooleancontains(@NotNull DataKeyBase<?> key)@NotNull java.util.Map<? extends DataKeyBase<?>,java.lang.Object>getAll()@NotNull java.util.Collection<? extends DataKeyBase<?>>getKeys()intgetLineCount()intgetLineNumber(int offset)Get line number at offset@Nullable java.lang.ObjectgetOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory)Get key if it exists or compute using supplier@NotNull BasedSequence[]getSegments()static MutableDataSetmerge(DataHolder... dataHolders)@NotNull MutableDataSetremove(@NotNull DataKeyBase<?> key)Remove the stored value for the key, used to force to default or to force recompute<T> @NotNull MutableDataHolderset(@NotNull DataKey<T> key, T value)Store the given value for the key<T> @NotNull MutableDataHolderset(@NotNull NullableDataKey<T> key, T value)Store the given value for the key@NotNull MutableDataSetsetAll(@NotNull DataHolder other)Copy all values from one data holder to this data holder@NotNull MutableDataSetsetFrom(@NotNull MutableDataSetter dataSetter)Store the given value for the key@NotNull MutableDataHoldersetIn(@NotNull MutableDataHolder dataHolder)Set options in given mutable data holder@NotNull MutableDataSettoDataSet()@NotNull DataSettoImmutable()@NotNull MutableDataSettoMutable()-
Methods inherited from class com.vladsch.flexmark.util.ast.ContentNode
getContentChars, getContentChars, getContentLines, getContentLines, getLineChars, getSpanningChars, setContent, setContent, setContent, setContentLine, setContentLines
-
Methods inherited from class com.vladsch.flexmark.util.ast.Node
appendChain, appendChild, astChars, astExtraChars, astString, baseSubSequence, baseSubSequence, countAncestorsOfType, countDirectAncestorsOfType, delimitedSegmentSpan, delimitedSegmentSpanChars, endOfLine, extractChainTo, extractToFirstInChain, getAncestorOfType, getAstExtra, getBaseSequence, getBlankLineSibling, getChars, getCharsFromSegments, getChildChars, getChildIterator, getChildOfType, getChildren, getDescendants, getDocument, getEmptyPrefix, getEmptySuffix, getEndLineNumber, getEndOffset, getEndOfLine, getExactChildChars, getFirstChild, getFirstChildAny, getFirstChildAnyNot, getFirstInChain, getGrandParent, getLastBlankLineChild, getLastChild, getLastChildAny, getLastChildAnyNot, getLastInChain, getLeadSegment, getLineColumnAtEnd, getLineNumber, getNext, getNextAny, getNextAnyNot, getNodeName, getNodeOfTypeIndex, getNodeOfTypeIndex, getOldestAncestorOfTypeAfter, getPrevious, getPreviousAny, getPreviousAnyNot, getReversedChildIterator, getReversedChildren, getReversedDescendants, getSegmentsForChars, getSourceRange, getStartLineNumber, getStartOffset, getStartOfLine, getTextLength, getTrailSegment, hasChildren, hasOrMoreChildren, insertAfter, insertBefore, insertChainAfter, insertChainBefore, isOrDescendantOfType, lineColumnAtIndex, lineColumnAtStart, moveTrailingBlankLines, prependChild, removeChildren, segmentSpan, segmentSpan, segmentSpanChars, segmentSpanChars, segmentSpanChars, segmentSpanCharsToVisible, setChars, setCharsFromContent, setCharsFromContentOnly, setCharsFromSegments, spanningChars, startOfLine, takeChildren, toAstString, toSegmentSpan, toString, toStringAttributes, unlink
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vladsch.flexmark.util.data.MutableDataHolder
get
-
-
-
-
Field Detail
-
NULL
public static final Document NULL
-
dataSet
private final MutableDataSet dataSet
-
-
Constructor Detail
-
Document
public Document(DataHolder options, BasedSequence chars)
-
-
Method Detail
-
getSegments
@NotNull public @NotNull BasedSequence[] getSegments()
- Specified by:
getSegmentsin classNode
-
clear
@NotNull public @NotNull MutableDataHolder clear()
Description copied from interface:MutableDataHolderclear all options out of the data set- Specified by:
clearin interfaceMutableDataHolder- Returns:
- mutable data holder for chained calls
-
set
@NotNull public <T> @NotNull MutableDataHolder set(@NotNull @NotNull DataKey<T> key, @NotNull T value)
Description copied from interface:MutableDataHolderStore the given value for the key- Specified by:
setin interfaceMutableDataHolder- Type Parameters:
T- data type of the data referred by the key- Parameters:
key- data keyvalue- value to store- Returns:
- mutable data holder for chained calls
-
set
@NotNull public <T> @NotNull MutableDataHolder set(@NotNull @NotNull NullableDataKey<T> key, @Nullable T value)
Description copied from interface:MutableDataHolderStore the given value for the key- Specified by:
setin interfaceMutableDataHolder- Type Parameters:
T- data type of the data referred by the key- Parameters:
key- data keyvalue- value to store- Returns:
- mutable data holder for chained calls
-
setFrom
@NotNull public @NotNull MutableDataSet setFrom(@NotNull @NotNull MutableDataSetter dataSetter)
Description copied from interface:MutableDataHolderStore the given value for the key- Specified by:
setFromin interfaceMutableDataHolder- Parameters:
dataSetter- data setter which will set values- Returns:
- mutable data holder for chained calls
-
setAll
@NotNull public @NotNull MutableDataSet setAll(@NotNull @NotNull DataHolder other)
Description copied from interface:MutableDataHolderCopy all values from one data holder to this data holder- Specified by:
setAllin interfaceMutableDataHolder- Parameters:
other- data holder from which to copy all values- Returns:
- mutable data holder for chained calls
-
merge
public static MutableDataSet merge(DataHolder... dataHolders)
-
setIn
@NotNull public @NotNull MutableDataHolder setIn(@NotNull @NotNull MutableDataHolder dataHolder)
Description copied from interface:MutableDataHolderSet options in given mutable data holder- Specified by:
setInin interfaceDataHolder- Specified by:
setInin interfaceMutableDataHolder- Specified by:
setInin interfaceMutableDataSetter- Parameters:
dataHolder- data holder where to copy options from this data holder- Returns:
- dataHolder
-
remove
@NotNull public @NotNull MutableDataSet remove(@NotNull @NotNull DataKeyBase<?> key)
Description copied from interface:MutableDataHolderRemove the stored value for the key, used to force to default or to force recompute- Specified by:
removein interfaceMutableDataHolder- Parameters:
key- data key to remove- Returns:
- mutable data holder for chained calls
-
getOrCompute
@Nullable public @Nullable java.lang.Object getOrCompute(@NotNull @NotNull DataKeyBase<?> key, @NotNull @NotNull DataValueFactory<?> factory)Description copied from interface:DataHolderGet key if it exists or compute using supplierMethod used by DataKey classes to access data.
NOTE: MutableDataHolders will compute an absent key and add it to its dataSet. DataHolders will return computed value but not change contained dataSet because they are immutable. So value will be computed every time it is requested.
- Specified by:
getOrComputein interfaceDataHolder- Specified by:
getOrComputein interfaceMutableDataHolder- Parameters:
key- data keyfactory- factory taking this data holder and computing/providing default value- Returns:
- object value for the key
-
toMutable
@NotNull public @NotNull MutableDataSet toMutable()
- Specified by:
toMutablein interfaceDataHolder
-
toImmutable
@NotNull public @NotNull DataSet toImmutable()
- Specified by:
toImmutablein interfaceDataHolder
-
toDataSet
@NotNull public @NotNull MutableDataSet toDataSet()
- Specified by:
toDataSetin interfaceDataHolder
-
aggregateActions
@NotNull public static @NotNull DataHolder aggregateActions(@NotNull @NotNull DataHolder other, @NotNull @NotNull DataHolder overrides)
-
aggregate
@NotNull public @NotNull DataHolder aggregate()
-
aggregate
@NotNull public static @NotNull DataHolder aggregate(@Nullable @Nullable DataHolder other, @Nullable @Nullable DataHolder overrides)
-
getAll
@NotNull public @NotNull java.util.Map<? extends DataKeyBase<?>,java.lang.Object> getAll()
- Specified by:
getAllin interfaceDataHolder
-
getKeys
@NotNull public @NotNull java.util.Collection<? extends DataKeyBase<?>> getKeys()
- Specified by:
getKeysin interfaceDataHolder
-
contains
public boolean contains(@NotNull @NotNull DataKeyBase<?> key)- Specified by:
containsin interfaceDataHolder
-
getLineCount
public int getLineCount()
- Specified by:
getLineCountin interfaceContent- Overrides:
getLineCountin classContentNode
-
getLineNumber
public int getLineNumber(int offset)
Get line number at offsetNext line starts after the EOL sequence. offsets between \r and \n are considered part of the same line as offset before \r.
- Parameters:
offset- offset in document text- Returns:
- line number at offset
-
-