Class SegmentedSequence

    • Field Detail

      • startOffset

        protected final int startOffset
      • endOffset

        protected final int endOffset
      • length

        protected final int length
    • Constructor Detail

      • SegmentedSequence

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

      • getBase

        @NotNull
        public final java.lang.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
      • 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 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 java.lang.CharSequence
      • baseSubSequence

        @NotNull
        public final 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
                                           java.lang.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)