Class SegmentedSequence

All Implemented Interfaces:
BasedOptionsHolder, BasedSequence, IRichSequence<BasedSequence>, ReplacedBasedSequence, SequenceUtils, CharSequence, Comparable<CharSequence>
Direct Known Subclasses:
SegmentedSequenceFull, SegmentedSequenceTree

public abstract class SegmentedSequence extends BasedSequenceImpl implements ReplacedBasedSequence
A BasedSequence which consists of segments of other BasedSequences
  • Field Details

    • baseSeq

      protected final BasedSequence baseSeq
    • startOffset

      protected final int startOffset
    • endOffset

      protected final int endOffset
    • length

      protected final int length
  • Constructor Details

    • SegmentedSequence

      protected SegmentedSequence(BasedSequence baseSeq, int startOffset, int endOffset, int length)
  • Method Details

    • getBase

      @NotNull public final @NotNull Object getBase()
      Description copied from interface: BasedSequence
      Get the underlying object on which this sequence contents are based
      Specified by:
      getBase in interface BasedSequence
      Returns:
      underlying object containing original text
    • getBaseSequence

      @NotNull public final @NotNull BasedSequence getBaseSequence()
      Description copied from interface: BasedSequence
      Get the base sequence for the text
      Specified by:
      getBaseSequence in interface BasedSequence
      Returns:
      base sequence
    • getStartOffset

      public final int getStartOffset()
      Get the start in the base sequence for this segmented sequence.

      NOTE: this is the startOffset determined when the sequence was built from segments and may differ from the startOffset of the first based segment in this sequence

      Specified by:
      getStartOffset in interface BasedSequence
      Returns:
      start in base sequence
    • getEndOffset

      public final int getEndOffset()
      Get the end offset in the base sequence

      NOTE: this is the endOffset determined when the sequence was built from segments and may differ from the endOffset of the last based segment in this sequence

      Specified by:
      getEndOffset in interface BasedSequence
      Returns:
      end in base sequence
    • getOptionFlags

      public final int getOptionFlags()
      Description copied from interface: BasedOptionsHolder
      Options test for options for this sequence

      default reports true for global default options (if any) , variation available on BasedSequenceWithOptions

      Specified by:
      getOptionFlags in interface BasedOptionsHolder
      Returns:
      option flags for this sequence
    • allOptions

      public final boolean allOptions(int options)
      Description copied from interface: BasedOptionsHolder
      Options test for options for this sequence

      default reports true for global default options (if any) , variation available on BasedSequenceWithOptions

      Specified by:
      allOptions in interface BasedOptionsHolder
      Parameters:
      options - option flags
      Returns:
      true if all option flags passed are set for this sequence
    • anyOptions

      public final boolean anyOptions(int options)
      Description copied from interface: BasedOptionsHolder
      Options test for options for this sequence

      default reports true for global default options (if any) , variation available on BasedSequenceWithOptions

      Specified by:
      anyOptions in interface BasedOptionsHolder
      Parameters:
      options - option flags
      Returns:
      true if any option flags passed are set for this sequence
    • getOption

      public final <T> T getOption(DataKeyBase<T> dataKey)
      Description copied from interface: BasedOptionsHolder
      Options holder, default has none, only available on BasedSequenceWithOptions
      Specified by:
      getOption in interface BasedOptionsHolder
      Type Parameters:
      T - type of value held by key
      Parameters:
      dataKey - in options
      Returns:
      true if data key is available
    • getOptions

      @Nullable public final @Nullable DataHolder getOptions()
      Description copied from interface: BasedOptionsHolder
      Options holder, default has none, only available on BasedSequenceWithOptions
      Specified by:
      getOptions in interface BasedOptionsHolder
      Returns:
      data holder with options or null if none for this sequence
    • length

      public final int length()
      Specified by:
      length in interface CharSequence
    • getSourceRange

      @NotNull public final @NotNull Range getSourceRange()
      Description copied from interface: BasedSequence
      Get the range of this sequence in original BasedSequence.getBaseSequence() and BasedSequence.getBase() original text source.
      Specified by:
      getSourceRange in interface BasedSequence
      Returns:
      Range of start offset and end offset
    • baseSubSequence

      @NotNull public final @NotNull BasedSequence baseSubSequence(int startIndex, int endIndex)
      Description copied from interface: BasedSequence
      Get a portion of this sequence's base sequence

      NOTE: this means that if this sequence applies modifications to the original sequence then these modifications are NOT be applied to the returned sequence.

      NOTE: It should only be implemented in classes which provide base sequences such as CharSubSequence and SubSequence others use inherited implementation of BasedSequenceImpl

      Specified by:
      baseSubSequence in interface BasedSequence
      Overrides:
      baseSubSequence in class BasedSequenceImpl
      Parameters:
      startIndex - offset from 0 of original sequence
      endIndex - offset from 0 of original sequence
      Returns:
      based sequence whose contents reflect the selected portion
    • create

      public static BasedSequence create(BasedSequence basedSequence, @NotNull @NotNull Iterable<? extends BasedSequence> segments)
      Use BasedSequence.getBuilder() and then ISequenceBuilder.addAll(Iterable) or if you know which are based segments vs. out of base Strings then use BasedSegmentBuilder to construct segments directly.

      Use only if you absolutely need to use this old method because it calls the builder.addAll() for all the segments anyway.

      If you need the location where content would have been use the FencedCodeBlock.getOpeningMarker().getEndOffset() + 1

      Parameters:
      basedSequence - base sequence for the segments
      segments - list of based sequences to put into a based sequence
      Returns:
      based sequence of segments. Result is a sequence which looks like all the segments were concatenated, while still maintaining the original offset for each character when using BasedSequence.getIndexOffset(int)(int index)
    • create

      public static BasedSequence create(BasedSequence... segments)
    • create

      public static BasedSequence create(SequenceBuilder builder)
    • of

      @Deprecated public static BasedSequence of(BasedSequence basedSequence, @NotNull @NotNull Iterable<? extends BasedSequence> segments)
      Deprecated.
      use BasedSequence.getBuilder() and then ISequenceBuilder.addAll(Iterable) or if you know which are based segments vs. out of base Strings then use BasedSegmentBuilder to construct segments directly. If you absolutely need to use the old method then use create(BasedSequence, Iterable)
      Parameters:
      basedSequence - base sequence for the segments
      segments - list of based sequences to put into a based sequence
      Returns:
      based sequence of segments. Result is a sequence which looks like all the segments were concatenated, while still maintaining the original offset for each character when using BasedSequence.getIndexOffset(int)(int index)
    • of

      @Deprecated public static BasedSequence of(BasedSequence... segments)
      Deprecated.