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 MutableDataSet
dataSet
static Document
NULL
-
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 DataHolder
aggregate()
static @NotNull DataHolder
aggregate(@Nullable DataHolder other, @Nullable DataHolder overrides)
static @NotNull DataHolder
aggregateActions(@NotNull DataHolder other, @NotNull DataHolder overrides)
@NotNull MutableDataHolder
clear()
clear all options out of the data setboolean
contains(@NotNull DataKeyBase<?> key)
@NotNull java.util.Map<? extends DataKeyBase<?>,java.lang.Object>
getAll()
@NotNull java.util.Collection<? extends DataKeyBase<?>>
getKeys()
int
getLineCount()
int
getLineNumber(int offset)
Get line number at offset@Nullable java.lang.Object
getOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory)
Get key if it exists or compute using supplier@NotNull BasedSequence[]
getSegments()
static MutableDataSet
merge(DataHolder... dataHolders)
@NotNull MutableDataSet
remove(@NotNull DataKeyBase<?> key)
Remove the stored value for the key, used to force to default or to force recompute<T> @NotNull MutableDataHolder
set(@NotNull DataKey<T> key, T value)
Store the given value for the key<T> @NotNull MutableDataHolder
set(@NotNull NullableDataKey<T> key, T value)
Store the given value for the key@NotNull MutableDataSet
setAll(@NotNull DataHolder other)
Copy all values from one data holder to this data holder@NotNull MutableDataSet
setFrom(@NotNull MutableDataSetter dataSetter)
Store the given value for the key@NotNull MutableDataHolder
setIn(@NotNull MutableDataHolder dataHolder)
Set options in given mutable data holder@NotNull MutableDataSet
toDataSet()
@NotNull DataSet
toImmutable()
@NotNull MutableDataSet
toMutable()
-
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:
getSegments
in classNode
-
clear
@NotNull public @NotNull MutableDataHolder clear()
Description copied from interface:MutableDataHolder
clear all options out of the data set- Specified by:
clear
in 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:MutableDataHolder
Store the given value for the key- Specified by:
set
in 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:MutableDataHolder
Store the given value for the key- Specified by:
set
in 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:MutableDataHolder
Store the given value for the key- Specified by:
setFrom
in 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:MutableDataHolder
Copy all values from one data holder to this data holder- Specified by:
setAll
in 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:MutableDataHolder
Set options in given mutable data holder- Specified by:
setIn
in interfaceDataHolder
- Specified by:
setIn
in interfaceMutableDataHolder
- Specified by:
setIn
in 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:MutableDataHolder
Remove the stored value for the key, used to force to default or to force recompute- Specified by:
remove
in 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:DataHolder
Get 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:
getOrCompute
in interfaceDataHolder
- Specified by:
getOrCompute
in 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:
toMutable
in interfaceDataHolder
-
toImmutable
@NotNull public @NotNull DataSet toImmutable()
- Specified by:
toImmutable
in interfaceDataHolder
-
toDataSet
@NotNull public @NotNull MutableDataSet toDataSet()
- Specified by:
toDataSet
in 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:
getAll
in interfaceDataHolder
-
getKeys
@NotNull public @NotNull java.util.Collection<? extends DataKeyBase<?>> getKeys()
- Specified by:
getKeys
in interfaceDataHolder
-
contains
public boolean contains(@NotNull @NotNull DataKeyBase<?> key)
- Specified by:
contains
in interfaceDataHolder
-
getLineCount
public int getLineCount()
- Specified by:
getLineCount
in interfaceContent
- Overrides:
getLineCount
in 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
-
-