Class BasedSequenceImpl

    • Constructor Detail

      • BasedSequenceImpl

        public BasedSequenceImpl​(int hash)
    • Method Detail

      • sequenceOf

        @NotNull
        public BasedSequence sequenceOf​(@Nullable
                                        java.lang.CharSequence charSequence,
                                        int startIndex,
                                        int endIndex)
        Description copied from interface: IRichSequence
        Factory function
        Specified by:
        sequenceOf in interface IRichSequence<BasedSequence>
        Parameters:
        charSequence - char sequence from which to construct a rich char sequence
        startIndex - start index of the sequence to use
        endIndex - end index of the sequence to use
        Returns:
        rich char sequence from given inputs
      • addSegments

        public void addSegments​(@NotNull
                                IBasedSegmentBuilder<?> builder)
        Description copied from interface: BasedSequence
        Add segments for this sequence, replacing out of base characters with strings
        Specified by:
        addSegments in interface BasedSequence
        Parameters:
        builder - builder
      • getSegmentTree

        @NotNull
        public SegmentTree getSegmentTree()
        Get the segment tree for this sequence or null if sequence is contiguous from startOffset to endOffset
        Specified by:
        getSegmentTree in interface BasedSequence
        Returns:
        null for contiguous sequences, else segment tree for this sequence
      • baseSubSequence

        @NotNull
        public final BasedSequence baseSubSequence​(int startIndex)
        Description copied from interface: BasedSequence
        Get a portion of the original sequence that this sequence is based on
        Specified by:
        baseSubSequence in interface BasedSequence
        Parameters:
        startIndex - offset from 0 of original sequence
        Returns:
        based sequence from startIndex to the endIndex
      • baseSubSequence

        @NotNull
        public 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
        Parameters:
        startIndex - offset from 0 of original sequence
        endIndex - offset from 0 of original sequence
        Returns:
        based sequence whose contents reflect the selected portion
      • safeBaseCharAt

        public char safeBaseCharAt​(int index)
        Description copied from interface: BasedSequence
        Safe, if index out of range but based sequence has characters will return those, else returns '\0'

        Allows peeking into preceding/following characters to the ones contained in this sequence

        Specified by:
        safeBaseCharAt in interface BasedSequence
        Parameters:
        index - index in string
        Returns:
        character or '\0' if index out of base sequence
      • isBaseCharAt

        public boolean isBaseCharAt​(int index,
                                    @NotNull
                                    CharPredicate predicate)
        Description copied from interface: BasedSequence
        Safe, if index out of range but based sequence has characters will return those, else returns '\0'

        Allows peeking into preceding/following characters to the ones contained in this sequence

        Specified by:
        isBaseCharAt in interface BasedSequence
        Parameters:
        index - index in string
        predicate - character set predicate
        Returns:
        true if character at index tests true
      • unescape

        @NotNull
        public java.lang.String unescape()
        Description copied from interface: BasedSequence
        Get the unescaped string of this sequence content
        Specified by:
        unescape in interface BasedSequence
        Returns:
        unescaped text
      • unescapeNoEntities

        @NotNull
        public java.lang.String unescapeNoEntities()
        Description copied from interface: BasedSequence
        Get the unescaped string of this sequence content without unescaping entities
        Specified by:
        unescapeNoEntities in interface BasedSequence
        Returns:
        unescaped text
      • unescape

        @NotNull
        public BasedSequence unescape​(@NotNull
                                      ReplacedTextMapper textMapper)
        Description copied from interface: BasedSequence
        Get the unescaped string of this sequence content
        Specified by:
        unescape in interface BasedSequence
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        unescaped text in based sequence
      • normalizeEOL

        @NotNull
        public BasedSequence normalizeEOL​(@NotNull
                                          ReplacedTextMapper textMapper)
        Description copied from interface: BasedSequence
        replace any \r\n and \r by \n
        Specified by:
        normalizeEOL in interface BasedSequence
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        based sequence with only \n for line separators
      • normalizeEndWithEOL

        @NotNull
        public BasedSequence normalizeEndWithEOL​(@NotNull
                                                 ReplacedTextMapper textMapper)
        Description copied from interface: BasedSequence
        replace any \r\n and \r by \n, append terminating EOL if one is not present
        Specified by:
        normalizeEndWithEOL in interface BasedSequence
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        based sequence with only \n for line separators and terminated by \n
      • isContinuedBy

        public boolean isContinuedBy​(@NotNull
                                     BasedSequence other)
        Description copied from interface: BasedSequence
        Test if the given sequence is a continuation of this sequence in original source text
        Specified by:
        isContinuedBy in interface BasedSequence
        Parameters:
        other - sequence to test
        Returns:
        true if the given sequence is a continuation of this one in the original text
      • isContinuationOf

        public boolean isContinuationOf​(@NotNull
                                        BasedSequence other)
        Description copied from interface: BasedSequence
        Test if this sequence is a continuation of the given sequence in original source text
        Specified by:
        isContinuationOf in interface BasedSequence
        Parameters:
        other - sequence to test
        Returns:
        true if this sequence is a continuation of the given sequence in original source text
      • spliceAtEnd

        @NotNull
        public BasedSequence spliceAtEnd​(@NotNull
                                         BasedSequence other)
        Description copied from interface: BasedSequence
        Splice the given sequence to the end of this one and return a BasedSequence of the result. Does not copy anything, creates a new based sequence of the original text but one that spans characters of this sequence and other
        Specified by:
        spliceAtEnd in interface BasedSequence
        Parameters:
        other - sequence to append to end of this one
        Returns:
        based sequence that contains the span from start of this sequence and end of other

        assertion will fail if the other sequence is not a continuation of this one

      • containsAllOf

        public boolean containsAllOf​(@NotNull
                                     BasedSequence other)
        Description copied from interface: BasedSequence
        start/end offset based containment, not textual
        Specified by:
        containsAllOf in interface BasedSequence
        Parameters:
        other - based sequence from the same base
        Returns:
        true if other is contained in this
      • containsSomeOf

        public boolean containsSomeOf​(@NotNull
                                      BasedSequence other)
        Description copied from interface: BasedSequence
        start/end offset based containment, not textual
        Specified by:
        containsSomeOf in interface BasedSequence
        Parameters:
        other - based sequence from the same base
        Returns:
        true if other is contained in this
      • intersect

        @NotNull
        public BasedSequence intersect​(@NotNull
                                       BasedSequence other)
        Description copied from interface: BasedSequence
        start/end offset based intersection, not textual
        Specified by:
        intersect in interface BasedSequence
        Parameters:
        other - based sequence from the same parent
        Returns:
        sequence which is the intersection of the range of this and other
      • containsSomeIn

        public boolean containsSomeIn​(@NotNull
                                      CharPredicate charSet)
        Description copied from interface: BasedSequence
        Test for line containing some of the characters in the set
        Specified by:
        containsSomeIn in interface BasedSequence
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters in the set
      • containsSomeNotIn

        public boolean containsSomeNotIn​(@NotNull
                                         CharPredicate charSet)
        Description copied from interface: BasedSequence
        Test for line containing some characters not in the set
        Specified by:
        containsSomeNotIn in interface BasedSequence
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters not in the set
      • containsOnlyIn

        public boolean containsOnlyIn​(@NotNull
                                      CharPredicate charSet)
        Description copied from interface: BasedSequence
        Test for line contains only characters from the set
        Specified by:
        containsOnlyIn in interface BasedSequence
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters from the set
      • containsOnlyNotIn

        public boolean containsOnlyNotIn​(@NotNull
                                         CharPredicate charSet)
        Description copied from interface: BasedSequence
        Test for line containing only characters not in the set
        Specified by:
        containsOnlyNotIn in interface BasedSequence
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters from the set
      • extendByAny

        @NotNull
        public BasedSequence extendByAny​(@NotNull
                                         CharPredicate charSet,
                                         int maxCount)
        Description copied from interface: BasedSequence
        Extend this based sequence to include characters from underlying based sequence
        Specified by:
        extendByAny in interface BasedSequence
        Parameters:
        charSet - set of characters to include
        maxCount - maximum extra characters to include
        Returns:
        sequence which
      • extendByAnyNot

        @NotNull
        public BasedSequence extendByAnyNot​(@NotNull
                                            CharPredicate charSet,
                                            int maxCount)
        Description copied from interface: BasedSequence
        Extend this based sequence to include characters from underlying based sequence not in character set
        Specified by:
        extendByAnyNot in interface BasedSequence
        Parameters:
        charSet - set of characters to include
        maxCount - maximum extra characters to include
        Returns:
        sequence which
      • extendToEndOfLine

        @NotNull
        public final BasedSequence extendToEndOfLine​(@NotNull
                                                     CharPredicate eolChars,
                                                     boolean includeEol)
        Description copied from interface: BasedSequence
        Extend in contained based sequence
        Specified by:
        extendToEndOfLine in interface BasedSequence
        Parameters:
        eolChars - characters to consider as EOL, note IRichSequence.eolStartLength(int) IRichSequence.eolEndLength(int) should report length of EOL found if length > 1
        includeEol - if to include the eol in the string
        Returns:
        resulting sequence after extension. If already spanning the line then this sequence is returned. if the last character of this sequence are found in eolChars then no extension will be performed since it already includes the line end
      • extendToStartOfLine

        @NotNull
        public BasedSequence extendToStartOfLine​(@NotNull
                                                 CharPredicate eolChars,
                                                 boolean includeEol)
        Description copied from interface: BasedSequence
        Extend in contained based sequence
        Specified by:
        extendToStartOfLine in interface BasedSequence
        Parameters:
        eolChars - characters to consider as EOL, note IRichSequence.eolStartLength(int) IRichSequence.eolEndLength(int) should report length of EOL found if length > 1
        includeEol - if to include the eol in the string
        Returns:
        resulting sequence after extension. If already spanning the line then this sequence is returned. if the first character of this sequence are found in eolChars then no extension will be performed since it already includes the line end
      • prefixWithIndent

        @NotNull
        public BasedSequence prefixWithIndent​(int maxColumns)
        Description copied from interface: BasedSequence
        Extend this based sequence to include characters from underlying based sequence taking tab expansion to 4th spaces into account
        Specified by:
        prefixWithIndent in interface BasedSequence
        Parameters:
        maxColumns - maximum columns to include, default Integer.MAX_VALUE
        Returns:
        sequence which
      • prefixOf

        @NotNull
        public BasedSequence prefixOf​(@NotNull
                                      BasedSequence other)
        Description copied from interface: BasedSequence
        Get the prefix part of this from other, start/end offset based containment, not textual
        Specified by:
        prefixOf in interface BasedSequence
        Parameters:
        other - based sequence from the same base
        Returns:
        prefix part of this as compared to other, start/end offset based, not content
      • suffixOf

        @NotNull
        public BasedSequence suffixOf​(@NotNull
                                      BasedSequence other)
        Description copied from interface: BasedSequence
        Get the suffix part of this from other, start/end offset based containment, not textual
        Specified by:
        suffixOf in interface BasedSequence
        Parameters:
        other - based sequence from the same base
        Returns:
        suffix part of this as compared to other, start/end offset based, not content