Interface IRichSequence<T extends IRichSequence<T>>
- All Superinterfaces:
CharSequence
,Comparable<CharSequence>
,SequenceUtils
- All Known Subinterfaces:
BasedSequence
,ReplacedBasedSequence
,RichSequence
- All Known Implementing Classes:
BasedSequence.EmptyBasedSequence
,BasedSequenceImpl
,CharSubSequence
,IRichSequenceBase
,MappedBasedSequence
,MappedRichSequence
,PrefixedSubSequence
,RichSequenceImpl
,SegmentedSequence
,SegmentedSequenceFull
,SegmentedSequenceTree
,SubSequence
NOTE: '\0' changed to '�' use NullEncoder.decodeNull
mapper to get original null chars.
safe access methods return '\0' for no char response.
-
Field Summary
Fields inherited from interface com.vladsch.flexmark.util.sequence.SequenceUtils
ANY_EOL, ANY_EOL_SET, BACKSLASH_SET, DECIMAL_DIGITS, EMPTY_INDICES, ENC_NUL, EOL, EOL_CHAR, EOL_CHAR1, EOL_CHAR2, EOL_CHARS, EOL_SET, HASH_SET, HEXADECIMAL_DIGITS, LINE_SEP, LS, LSEP, NBSP, NBSP_CHARS, NUL, OCTAL_DIGITS, SPACE, SPACE_EOL, SPACE_EOL_SET, SPACE_SET, SPACE_TAB, SPACE_TAB_EOL_SET, SPACE_TAB_NBSP_SET, SPACE_TAB_SET, SPC, SPLIT_INCLUDE_DELIM_PARTS, SPLIT_INCLUDE_DELIMS, SPLIT_SKIP_EMPTY, SPLIT_TRIM_PARTS, SPLIT_TRIM_SKIP_EMPTY, TAB_SET, US, US_CHARS, US_SET, visibleSpacesMap, WHITESPACE, WHITESPACE_CHARS, WHITESPACE_NBSP, WHITESPACE_NBSP_CHARS, WHITESPACE_NBSP_SET, WHITESPACE_NO_EOL_CHARS, WHITESPACE_SET
-
Method Summary
Modifier and TypeMethodDescriptionappend
(CharSequence... sequences) Concatenate this sequence and list of others, returning sequence of resultappend
(Iterable<? extends CharSequence> sequences) appendRangesTo
(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Range... ranges) Append given ranges of this sequence to string builderappendRangesTo
(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Iterable<? extends Range> ranges) appendRangesTo
(@NotNull StringBuilder out, Range... ranges) appendRangesTo
(@NotNull StringBuilder out, Iterable<? extends Range> ranges) appendSpaces
(int count) appendTo
(@NotNull StringBuilder out) appendTo
(@NotNull StringBuilder out, int startIndex) appendTo
(@NotNull StringBuilder out, int startIndex, int endIndex) appendTo
(@NotNull StringBuilder out, @Nullable CharMapper charMapper) appendTo
(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex) appendTo
(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex, int endIndex) Append helpersblankLinesRemovedRanges
(int fromIndex) blankLinesRemovedRanges
(int fromIndex, int endIndex) blankLinesRemovedRanges
(@NotNull CharPredicate eolChars, int fromIndex, int endIndex) int
columnAtIndex
(int index) default int
Deprecated.default int
countLeading
(char c) Deprecated.consider using built-in sets of characters, ..._SET, or Use CharPredicate.anyOf(...)int
countLeading
(@NotNull CharPredicate chars) Count leading/trailing characters of this sequenceint
countLeading
(@NotNull CharPredicate chars, int startIndex) int
countLeading
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
countLeadingColumns
(int startColumn, @NotNull CharPredicate chars) Count column of indent given by chars in the set in this sequence, expanding tabs to 4th columnint
countLeadingNot
(@NotNull CharPredicate chars) int
countLeadingNot
(@NotNull CharPredicate chars, int startIndex) int
countLeadingNot
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
int
countLeadingNotSpace
(int startIndex) int
countLeadingNotSpace
(int startIndex, int endIndex) int
int
countLeadingNotSpaceTab
(int startIndex) int
countLeadingNotSpaceTab
(int startIndex, int endIndex) int
int
countLeadingNotWhitespace
(int startIndex) int
countLeadingNotWhitespace
(int startIndex, int endIndex) int
int
countLeadingSpace
(int startIndex) int
countLeadingSpace
(int startIndex, int endIndex) int
int
countLeadingSpaceTab
(int startIndex) int
countLeadingSpaceTab
(int startIndex, int endIndex) int
int
countLeadingWhitespace
(int startIndex) int
countLeadingWhitespace
(int startIndex, int endIndex) default int
countOf
(char c) Deprecated.int
countOfAny
(@NotNull CharPredicate chars) int
countOfAny
(@NotNull CharPredicate chars, int startIndex) int
countOfAny
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
countOfAnyNot
(@NotNull CharPredicate chars) int
countOfAnyNot
(@NotNull CharPredicate chars, int startIndex) int
countOfAnyNot
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
int
int
int
default int
Deprecated.int
countTrailing
(@NotNull CharPredicate chars) int
countTrailing
(@NotNull CharPredicate chars, int startIndex) int
countTrailing
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
countTrailingNot
(@NotNull CharPredicate chars) int
countTrailingNot
(@NotNull CharPredicate chars, int startIndex) int
countTrailingNot
(@NotNull CharPredicate chars, int startIndex, int endIndex) int
int
countTrailingNotSpace
(int fromIndex) int
countTrailingNotSpace
(int startIndex, int fromIndex) int
int
countTrailingNotSpaceTab
(int fromIndex) int
countTrailingNotSpaceTab
(int startIndex, int fromIndex) int
int
countTrailingNotWhitespace
(int fromIndex) int
countTrailingNotWhitespace
(int startIndex, int fromIndex) int
int
countTrailingSpace
(int fromIndex) int
countTrailingSpace
(int startIndex, int fromIndex) int
int
countTrailingSpaceTab
(int fromIndex) int
countTrailingSpaceTab
(int startIndex, int fromIndex) int
int
countTrailingWhitespace
(int fromIndex) int
countTrailingWhitespace
(int startIndex, int fromIndex) delete
(int startIndex, int endIndex) Delete range in sequence@NotNull T[]
char
endCharAt
(int index) Convenience method to get characters offset from end of sequence.int
endOfDelimitedBy
(@NotNull CharSequence s, int index) Find start/end region in this sequence delimited by any characters in argument or the CharSequenceint
endOfDelimitedByAny
(@NotNull CharPredicate s, int index) int
endOfDelimitedByAnyNot
(@NotNull CharPredicate s, int index) int
endOfLine
(int index) Get the offset of the end of line at given index, end of line delimited by \nint
endOfLineAnyEOL
(int index) Get the offset of the end of line at given index, end of line delimited by \n or any of \n \r \r\n for Any methods.endSequence
(int startIndex) Convenience method to get characters offset from endIndex of sequence.endSequence
(int startIndex, int endIndex) Convenience method to get characters offset from endIndex of sequence.boolean
endsWith
(@NotNull CharPredicate chars) boolean
endsWith
(@NotNull CharSequence suffix) test if this sequence ends with given charactersboolean
endsWith
(@NotNull CharSequence suffix, boolean ignoreCase) test if this sequence ends with given charactersboolean
boolean
boolean
endsWithIgnoreCase
(@NotNull CharSequence suffix) test if this sequence ends with given characters, ignoring case differencesboolean
boolean
boolean
int
Get the length of EOL character at the end of this sequence, if present.int
eolEndLength
(int eolEnd) Get the length of EOL character at the given index of this sequence, if present.@NotNull Range
eolEndRange
(int eolEnd) Return Range of eol at given indexdefault int
eolLength
(int eolStart) Deprecated.default int
Deprecated.int
eolStartLength
(int eolStart) Get the length of EOL character at the given index of this sequence, if present.@NotNull Range
eolStartRange
(int eolStart) Return Range of eol at given indexboolean
Comparison to another CharSequence should result in a match if their contents are equal regardless of the implementation.boolean
Test the sequence for a match to another CharSequenceboolean
equalsIgnoreCase
(@Nullable Object other) Test the sequence for a match to another CharSequence, ignoring case differencesextractRanges
(Range... ranges) Build a sequence of ranges in this sequenceextractRanges
(Iterable<Range> ranges) char
<B extends ISequenceBuilder<B,
T>>
BGet a sequence builder for this sequence typedefault int
getColumnAtIndex
(int index) Deprecated.getLineColumnAtIndex
(int index) Deprecated.int
hashCode()
Should return hashCode of the underlying character sequence which is equal to the String value of that sequenceIf this sequence is the nullSequence() instance then returns other, otherwise returns this sequence.ifNullEmptyAfter
(T other) If this sequence is the nullSequence() instance then returns an empty subSequence from the end of other, otherwise returns this sequence.ifNullEmptyBefore
(T other) If this sequence is the nullSequence() instance then returns an empty subSequence from the start of other, otherwise returns this sequence.int
indexOf
(char c) int
indexOf
(char c, int fromIndex) int
indexOf
(char c, int fromIndex, int endIndex) int
indexOf
(@NotNull CharSequence s) All index methods return the position or -1 if not found of the given character, characters or string.int
indexOf
(@NotNull CharSequence s, int fromIndex) int
indexOf
(@NotNull CharSequence s, int fromIndex, int endIndex) @org.jetbrains.annotations.NotNull int[]
indexOfAll
(@NotNull CharSequence s) Get indices of all occurrences of a sequenceint
indexOfAny
(@NotNull CharPredicate s) int
indexOfAny
(@NotNull CharPredicate s, int fromIndex) int
indexOfAny
(@NotNull CharPredicate s, int fromIndex, int endIndex) int
indexOfAnyNot
(@NotNull CharPredicate s) int
indexOfAnyNot
(@NotNull CharPredicate s, int fromIndex) int
indexOfAnyNot
(@NotNull CharPredicate s, int fromIndex, int endIndex) int
indexOfNot
(char c) int
indexOfNot
(char c, int fromIndex) int
indexOfNot
(char c, int fromIndex, int endIndex) insert
(int index, @NotNull CharSequence chars) Insert char sequence at given indexdefault T
insert
(@NotNull CharSequence chars, int index) Deprecated.useinsert(int, CharSequence)
insteadboolean
isBlank()
boolean
isCharAt
(int index, @NotNull CharPredicate predicate) Safe, if index out of range returns '\0'boolean
isEmpty()
boolean
boolean
isIn
(@NotNull Collection<? extends CharSequence> texts) boolean
boolean
boolean
boolean
isNull()
char
lastChar()
int
lastIndexOf
(char c) int
lastIndexOf
(char c, int fromIndex) int
lastIndexOf
(char c, int startIndex, int fromIndex) int
lastIndexOf
(@NotNull CharSequence s) int
lastIndexOf
(@NotNull CharSequence s, int fromIndex) int
lastIndexOf
(@NotNull CharSequence s, int startIndex, int fromIndex) int
lastIndexOfAny
(@NotNull CharPredicate s) int
lastIndexOfAny
(@NotNull CharPredicate s, int fromIndex) int
lastIndexOfAny
(@NotNull CharPredicate s, int startIndex, int fromIndex) int
lastIndexOfAnyNot
(@NotNull CharPredicate s) int
lastIndexOfAnyNot
(@NotNull CharPredicate s, int fromIndex) int
lastIndexOfAnyNot
(@NotNull CharPredicate s, int startIndex, int fromIndex) int
lastIndexOfNot
(char c) int
lastIndexOfNot
(char c, int fromIndex) int
lastIndexOfNot
(char c, int startIndex, int fromIndex) @NotNull Range
@NotNull Range
leadingBlankLinesRange
(int startIndex) @NotNull Range
leadingBlankLinesRange
(int fromIndex, int endIndex) @NotNull Range
leadingBlankLinesRange
(@NotNull CharPredicate eolChars, int fromIndex, int endIndex) Get Range of leading blank lines at given index offsets in sequencelineAt
(int index) Get the line characters at given index, line delimited by \nlineAtAnyEOL
(int index) Get the line characters at given index, line delimited by \n, \r or \r\nlineColumnAtIndex
(int index) Get the line and column information from index into sequence@NotNull Range
lineRangeAt
(int index) Get the line characters at given index, line delimited by \n@NotNull Range
lineRangeAtAnyEOL
(int index) Get the line characters at given index, line delimited by \n, \r or \r\nboolean
matchChars
(@NotNull CharSequence chars) Test the sequence portion for a match to another CharSequenceboolean
matchChars
(@NotNull CharSequence chars, boolean ignoreCase) boolean
matchChars
(@NotNull CharSequence chars, int startIndex) boolean
matchChars
(@NotNull CharSequence chars, int startIndex, boolean ignoreCase) Test the sequence portion for a match to another CharSequenceboolean
matchCharsIgnoreCase
(@NotNull CharSequence chars) boolean
matchCharsIgnoreCase
(@NotNull CharSequence chars, int startIndex) boolean
matchCharsReversed
(@NotNull CharSequence chars, int endIndex) boolean
matchCharsReversed
(@NotNull CharSequence chars, int endIndex, boolean ignoreCase) Test the sequence portion for a match to another CharSequence, reverse orderboolean
matchCharsReversedIgnoreCase
(@NotNull CharSequence chars, int endIndex) int
matchedCharCount
(@NotNull CharSequence chars, int startIndex) int
matchedCharCount
(@NotNull CharSequence chars, int startIndex, boolean ignoreCase) int
matchedCharCount
(@NotNull CharSequence chars, int startIndex, int endIndex) int
matchedCharCount
(@NotNull CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) int
matchedCharCount
(@NotNull CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) Test the sequence portion for a match to another CharSequenceint
matchedCharCountIgnoreCase
(@NotNull CharSequence chars, int startIndex) int
matchedCharCountIgnoreCase
(@NotNull CharSequence chars, int startIndex, int endIndex) int
matchedCharCountReversed
(@NotNull CharSequence chars, int fromIndex) int
matchedCharCountReversed
(@NotNull CharSequence chars, int fromIndex, boolean ignoreCase) int
matchedCharCountReversed
(@NotNull CharSequence chars, int startIndex, int fromIndex) int
matchedCharCountReversed
(@NotNull CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) Test the sequence portion for a match to another CharSequence, equivalent to taking this.subSequence(startIndex, fromIndex) and then count matching chars going from end of both sequencesint
matchedCharCountReversedIgnoreCase
(@NotNull CharSequence chars, int fromIndex) int
matchedCharCountReversedIgnoreCase
(@NotNull CharSequence chars, int startIndex, int fromIndex) boolean
matches
(@NotNull CharSequence chars) Test the sequence for a match to another CharSequenceboolean
matches
(@NotNull CharSequence chars, boolean ignoreCase) boolean
matchesIgnoreCase
(@NotNull CharSequence chars) char
midCharAt
(int index) Convenience method to get characters offset from start or end of sequence.midSequence
(int startIndex) Convenience method to get characters offset from start or end of sequence.midSequence
(int startIndex, int endIndex) Convenience method to get characters offset from start or end of sequence.@NotNull String
replace any \r\n and \r by \n, append terminating EOL if one is not present@NotNull String
replace any \r\n and \r by \nnullIf
(boolean condition) If condition is true return nullSequence() otherwise returns this sequence.nullIf
(@NotNull BiPredicate<? super T, ? super CharSequence> predicate, CharSequence... matches) If predicate returns true for this sequence and one of given sequences return nullSequence() otherwise returns this sequence.nullIf
(@NotNull Predicate<? super CharSequence> predicate, CharSequence... matches) If predicate returns true for one of given sequences return nullSequence() otherwise returns this sequence.nullIf
(CharSequence... matches) If this sequence matches one of given sequences return nullSequence() otherwise returns this sequence.If this sequence is blank return nullSequence() otherwise returns this sequence.If this sequence is empty return nullSequence() otherwise returns this sequence.nullIfEndsWith
(boolean ignoreCase, CharSequence... matches) nullIfEndsWith
(CharSequence... matches) nullIfEndsWithIgnoreCase
(CharSequence... matches) default T
nullIfEndsWithNot
(CharSequence... matches) Deprecated.nullIfNot
(@NotNull BiPredicate<? super T, ? super CharSequence> predicate, CharSequence... matches) nullIfNot
(@NotNull Predicate<? super CharSequence> predicate, CharSequence... matches) nullIfNot
(CharSequence... matches) nullIfNotEndsWith
(boolean ignoreCase, CharSequence... matches) nullIfNotEndsWith
(CharSequence... matches) nullIfNotEndsWithIgnoreCase
(CharSequence... matches) nullIfNotStartsWith
(boolean ignoreCase, CharSequence... matches) nullIfNotStartsWith
(CharSequence... matches) nullIfNotStartsWithIgnoreCase
(CharSequence... matches) nullIfStartsWith
(boolean ignoreCase, CharSequence... matches) nullIfStartsWith
(CharSequence... matches) nullIfStartsWithIgnoreCase
(CharSequence... matches) default T
nullIfStartsWithNot
(CharSequence... matches) Deprecated.padding
(int length) padding
(int length, char pad) Get the chars needed for padding to lengthpadEnd
(int length) padEnd
(int length, char pad) padStart
(int length) padStart
(int length, char pad) Pad this sequence to given lengthprefixOnceWith
(@Nullable CharSequence prefix) Prefix this sequence with a char sequence if not already starting with prefixprefixWith
(@Nullable CharSequence prefix) Prefix this sequence with a char sequenceprefixWithSpaces
(int count) removePrefix
(@NotNull CharSequence prefix) Remove prefix if presentremovePrefix
(@NotNull CharSequence prefix, boolean ignoreCase) Remove prefix if presentremovePrefixIgnoreCase
(@NotNull CharSequence prefix) Remove prefix if present, ignoring case differencesremoveProperPrefix
(@NotNull CharSequence prefix) Remove prefix if present but only if this sequence is longer than the suffixremoveProperPrefix
(@NotNull CharSequence prefix, boolean ignoreCase) Remove prefix if present but only if this sequence is longer than the suffixremoveProperPrefixIgnoreCase
(@NotNull CharSequence prefix) Remove prefix if present but only if this sequence is longer than the suffix, ignoring case differencesremoveProperSuffix
(@NotNull CharSequence suffix) Remove suffix if present but only if this sequence is longer than the suffixremoveProperSuffix
(@NotNull CharSequence suffix, boolean ignoreCase) Remove suffix if present but only if this sequence is longer than the suffixremoveProperSuffixIgnoreCase
(@NotNull CharSequence suffix) Remove suffix if present but only if this sequence is longer than the suffix, ignoring case differencesremoveSuffix
(@NotNull CharSequence suffix) Remove suffix if presentremoveSuffix
(@NotNull CharSequence suffix, boolean ignoreCase) Remove suffix if presentremoveSuffixIgnoreCase
(@NotNull CharSequence suffix) Remove suffix if present, ignoring case differencesreplace
(int startIndex, int endIndex, @NotNull CharSequence replacement) Replace part of the sequence with a char sequencereplace
(@NotNull CharSequence find, @NotNull CharSequence replace) Replace all occurrences of one sequence with anotherchar
safeCharAt
(int index) return char at index or '\0' if index <0 or >=length()safeSubSequence
(int startIndex) Get a portion of this sequence, if index < 0 use 0, if > length() use lengthsafeSubSequence
(int startIndex, int endIndex) Get a portion of this sequence, if index < 0 use 0, if > length() use lengthsequenceOf
(@Nullable CharSequence charSequence) Factory functionsequenceOf
(@Nullable CharSequence charSequence, int startIndex) Factory functionsequenceOf
(@Nullable CharSequence charSequence, int startIndex, int endIndex) Factory functiondefault @NotNull T[]
split
(char delimiter) Deprecated.default @NotNull T[]
split
(char delimiter, int limit) Deprecated.default @NotNull T[]
split
(char delimiter, int limit, int flags) Deprecated.@NotNull T[]
split
(@NotNull CharSequence delimiter) @NotNull T[]
split
(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) @NotNull T[]
split
(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) @NotNull T[]
split
(@NotNull CharSequence delimiter, int limit, int flags) @NotNull T[]
split
(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) @NotNull T[]
splitEOL()
@NotNull T[]
splitEOL
(boolean includeDelims) splitList
(@NotNull CharSequence delimiter) splitList
(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) splitList
(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) Split helpers based on delimiter character sets contained in CharPredicatesplitList
(@NotNull CharSequence delimiter, int limit, int flags) splitList
(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) Split helpers based on delimiter character sets contained in CharSequencesplitListEOL
(boolean includeDelims) splitListEOL
(boolean includeDelims, @Nullable CharPredicate trimChars) int
startOfDelimitedBy
(@NotNull CharSequence s, int index) int
startOfDelimitedByAny
(@NotNull CharPredicate s, int index) int
startOfDelimitedByAnyNot
(@NotNull CharPredicate s, int index) int
startOfLine
(int index) Get the offset of the start of line at given index, start of line delimited by \nint
startOfLineAnyEOL
(int index) Get the offset of the start of line at given index, start of line delimited by \n or any of \n \r \r\n for Any methods.boolean
startsWith
(@NotNull CharPredicate chars) boolean
startsWith
(@NotNull CharSequence prefix) test if this sequence starts with given charactersboolean
startsWith
(@NotNull CharSequence prefix, boolean ignoreCase) test if this sequence starts with given charactersboolean
boolean
boolean
startsWithIgnoreCase
(@NotNull CharSequence prefix) test if this sequence starts with given characters, ignoring case differencesboolean
boolean
boolean
subSequence
(int startIndex) Get a portion of this sequence starting from a given offset to endIndex of the sequencesubSequence
(int startIndex, int endIndex) Get a portion of this sequencesubSequence
(@NotNull Range range) Get a portion of this sequence selected by rangesubSequenceAfter
(@NotNull Range range) Get a portion of this sequence after one selected by rangesubSequenceBefore
(@NotNull Range range) Get a portion of this sequence before one selected by rangesuffixOnceWith
(@Nullable CharSequence suffix) Suffix this sequence with a char sequence if not already ending with suffixsuffixWith
(@Nullable CharSequence suffix) Prefix this sequence with a char sequencesuffixWithSpaces
(int count) Map characters of this sequence to: Uppercase, Lowercase or use custom mappingtoMapped
(CharMapper mapper) toNbSp()
Map spaces to non break spacestoSpc()
Map non break spaces to spaces@Nullable String
Return string or null if BaseSequence.NULL@NotNull String
@NotNull Range
@NotNull Range
trailingBlankLinesRange
(int fromIndex) @NotNull Range
trailingBlankLinesRange
(int startIndex, int fromIndex) @NotNull Range
trailingBlankLinesRange
(CharPredicate eolChars, int startIndex, int fromIndex) Get Range of trailing blank lines at given index offsets in sequencetrim()
trim
(int keep) trim
(int keep, @NotNull CharPredicate chars) trim
(@NotNull CharPredicate chars) trimEnd()
trimEnd
(int keep) trimEnd
(int keep, @NotNull CharPredicate chars) trimEnd
(@NotNull CharPredicate chars) @NotNull Range
@NotNull Range
trimEndRange
(int keep) @NotNull Range
trimEndRange
(int keep, @NotNull CharPredicate chars) @NotNull Range
trimEndRange
(@NotNull CharPredicate chars) trimEOL()
Trim last eol at the end of this sequence,trimmed()
trimmed
(int keep) trimmed
(int keep, @NotNull CharPredicate chars) trimmed
(@NotNull CharPredicate chars) trimmedEnd
(int keep) trimmedEnd
(int keep, @NotNull CharPredicate chars) trimmedEnd
(@NotNull CharPredicate chars) Get Trimmed part bytrimEOL()
trimmedStart
(int keep) trimmedStart
(int keep, @NotNull CharPredicate chars) Get the characters Trimmed, Trimmed from start/end of this sequence, characters to trim are passed in the sequence argumenttrimmedStart
(@NotNull CharPredicate chars) @NotNull Range
@NotNull Range
trimRange
(int keep) @NotNull Range
trimRange
(int keep, @NotNull CharPredicate chars) @NotNull Range
trimRange
(@NotNull CharPredicate chars) trimStart
(int keep) trimStart
(int keep, @NotNull CharPredicate chars) Trim, Trim start/end of this sequence, characters to trim are passed in the sequence argumenttrimStart
(@NotNull CharPredicate chars) @NotNull Range
@NotNull Range
trimStartRange
(int keep) @NotNull Range
trimStartRange
(int keep, @NotNull CharPredicate chars) Range of kept sequence when trim start/end of this sequence is performed, characters to trim are passed in the sequence argument@NotNull Range
trimStartRange
(@NotNull CharPredicate chars) Trim leading trailing blank lines in this sequencetrimToEndOfLine
(boolean includeEol) trimToEndOfLine
(boolean includeEol, int index) trimToEndOfLine
(int index) trimToEndOfLine
(@NotNull CharPredicate eolChars, boolean includeEol, int index) Trim end to end of line containing indextrimToStartOfLine
(boolean includeEol) trimToStartOfLine
(boolean includeEol, int index) trimToStartOfLine
(int index) trimToStartOfLine
(@NotNull CharPredicate eolChars, boolean includeEol, int index) Trim start to start of line containing indexMethods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, length, toString
Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
equals
Comparison to another CharSequence should result in a match if their contents are equal regardless of the implementation. Should not resort to content comparison unless -
hashCode
int hashCode()Should return hashCode of the underlying character sequence which is equal to the String value of that sequence -
emptyArray
-
nullSequence
-
lastChar
char lastChar()- Returns:
- the last character of the sequence or '\0' if empty
-
firstChar
char firstChar()- Returns:
- the first character of the sequence or '\0' if empty
-
safeCharAt
char safeCharAt(int index) return char at index or '\0' if index <0 or >=length()- Parameters:
index
- index- Returns:
- char or '\0'
-
subSequence
Get a portion of this sequenceNOTE: the returned value should only depend on start/end indices. If a subsequence of this sequence with matching start/end should equal (using equals()) all such subsequences of this sequence.
- Specified by:
subSequence
in interfaceCharSequence
- Parameters:
startIndex
- offset from startIndex of this sequenceendIndex
- offset from startIndex of this sequence- Returns:
- based sequence whose contents reflect the selected portion
-
safeSubSequence
Get a portion of this sequence, if index < 0 use 0, if > length() use lengthNOTE: the returned value should only depend on start/end indices. If a subsequence of this sequence with matching start/end should equal (using equals()) all such subsequences of this sequence.
- Parameters:
startIndex
- offset from startIndex of this sequenceendIndex
- offset from startIndex of this sequence- Returns:
- based sequence whose contents reflect the selected portion
-
safeSubSequence
Get a portion of this sequence, if index < 0 use 0, if > length() use lengthNOTE: the returned value should only depend on start/end indices. If a subsequence of this sequence with matching start/end should equal (using equals()) all such subsequences of this sequence.
- Parameters:
startIndex
- offset from startIndex of this sequence- Returns:
- based sequence whose contents reflect the selected portion
-
subSequence
Get a portion of this sequence selected by range- Parameters:
range
- range to get, coordinates offset form start of this sequence- Returns:
- based sequence whose contents reflect the selected portion, if range.isNull() then
nullSequence()
-
subSequenceBefore
Get a portion of this sequence before one selected by range- Parameters:
range
- range to get, coordinates offset form start of this sequence- Returns:
- based sequence whose contents reflect the selected portion, if range.isNull() then
nullSequence()
-
subSequenceAfter
Get a portion of this sequence after one selected by range- Parameters:
range
- range to get, coordinates offset form start of this sequence- Returns:
- based sequence whose contents reflect the selected portion, if range.isNull() then
nullSequence()
-
subSequence
Get a portion of this sequence starting from a given offset to endIndex of the sequence- Parameters:
startIndex
- offset from startIndex of this sequence- Returns:
- based sequence whose contents reflect the selected portion
-
endSequence
Convenience method to get characters offset from endIndex of sequence. no exceptions are thrown, instead a \0 is returned for an invalid index positions- Parameters:
startIndex
- offset from endIndex of sequence [ 0..length() )endIndex
- offset from endIndex of sequence [ 0..length() )- Returns:
- selected portion spanning length() - startIndex to length() - endIndex of this sequence
-
endSequence
Convenience method to get characters offset from endIndex of sequence. no exceptions are thrown, instead a \0 is returned for an invalid index positions- Parameters:
startIndex
- offset from endIndex of sequence [ 0..length() )- Returns:
- selected portion spanning length() - startIndex to length() of this sequence
-
endCharAt
char endCharAt(int index) Convenience method to get characters offset from end of sequence. no exceptions are thrown, instead a \0 is returned for an invalid index positions- Parameters:
index
- offset from end of sequence- Returns:
- character located at length() - index in this sequence
-
midSequence
Convenience method to get characters offset from start or end of sequence. when offset >=0 then it is offset from the start of the sequence, when <0 then from the endno exceptions are thrown, instead a \0 is returned for an invalid index positions
- Parameters:
startIndex
- offset into this sequenceendIndex
- offset into this sequence- Returns:
- selected portion spanning startIndex to endIndex of this sequence. If offset is <0 then it is taken as relative to length()
-
midSequence
Convenience method to get characters offset from start or end of sequence. when offset >= then it is offset from the start of the sequence, when <0 then from the endno exceptions are thrown, instead a \0 is returned for an invalid index positions
- Parameters:
startIndex
- offset into this sequence- Returns:
- selected portion spanning startIndex to length() of this sequence. If offset is <0 then it is taken as relative to length()
-
midCharAt
char midCharAt(int index) Convenience method to get characters offset from start or end of sequence. when index >= then it is offset from the start of the sequence, when <0 then from the end no exceptions are thrown, instead a \0 is returned for an invalid index positions- Parameters:
index
- of character to get- Returns:
- character at index or \0 if index is outside valid range for this sequence
-
sequenceOf
Factory function- Parameters:
charSequence
- char sequence from which to construct a rich char sequence- Returns:
- rich char sequence from given inputs
-
sequenceOf
Factory function- Parameters:
charSequence
- char sequence from which to construct a rich char sequencestartIndex
- start index of the sequence to use- Returns:
- rich char sequence from given inputs
-
sequenceOf
Factory function- Parameters:
charSequence
- char sequence from which to construct a rich char sequencestartIndex
- start index of the sequence to useendIndex
- end index of the sequence to use- Returns:
- rich char sequence from given inputs
-
getBuilder
Get a sequence builder for this sequence type- Type Parameters:
B
- type of builder- Returns:
- builder which can build this type of sequence
-
indexOf
All index methods return the position or -1 if not found of the given character, characters or string.The basic methods have overloads for 1, 2, or 3 characters and CharSequence parameters. If fromIndex is not given then for forward searching methods 0 is taken as the value, for reverse searching methods length() is taken as the value
For forward searching methods fromIndex is the minimum start position for search and endIndex is the maximum end position, if not given the length() of string is assumed.
For reverse searching methods fromIndex is the maximum start position for search and startIndex is the minimum end position, if not given then 0 is assumed.
- Parameters:
s
- character pre whose occurrence to find- Returns:
- index where found or -1
-
indexOf
-
indexOf
-
indexOf
int indexOf(char c, int fromIndex, int endIndex) -
indexOf
int indexOf(char c, int fromIndex) -
indexOf
int indexOf(char c) -
indexOfAny
-
indexOfAny
-
indexOfAny
-
indexOfNot
int indexOfNot(char c, int fromIndex, int endIndex) -
indexOfNot
int indexOfNot(char c, int fromIndex) -
indexOfNot
int indexOfNot(char c) -
indexOfAnyNot
-
indexOfAnyNot
-
indexOfAnyNot
-
lastIndexOf
-
lastIndexOf
-
lastIndexOf
-
lastIndexOf
int lastIndexOf(char c, int startIndex, int fromIndex) -
lastIndexOf
int lastIndexOf(char c, int fromIndex) -
lastIndexOf
int lastIndexOf(char c) -
lastIndexOfAny
-
lastIndexOfAny
-
lastIndexOfAny
-
lastIndexOfNot
int lastIndexOfNot(char c) -
lastIndexOfNot
int lastIndexOfNot(char c, int fromIndex) -
lastIndexOfNot
int lastIndexOfNot(char c, int startIndex, int fromIndex) -
lastIndexOfAnyNot
-
lastIndexOfAnyNot
-
lastIndexOfAnyNot
-
countLeading
Count leading/trailing characters of this sequenceParameters can be CharPredicate, counts any contiguous leading/trailing characters in the sequence which are contained in the given char set.
All functions have overloads: with no fromIndex then 0 is taken for leading and length() for trailing methods with fromIndex then this is taken as the start for leading and end for trailing methods with fromIndex and endIndex, counting will start at fromIndex and stop at endIndex
countLeading(CharPredicate): count contiguous leading characters from set in this sequence countLeadingNot(CharPredicate): count contiguous leading characters not from set in this sequence countTrailing(CharPredicate): count contiguous leading characters from set in this sequence countTrailingNot(CharPredicate): count contiguous leading characters not from set in this sequence
- Parameters:
chars
- predicate for set of contiguous characters which should be counted- Returns:
- number of chars in contiguous span at start of sequence
-
countLeadingNot
-
countLeading
-
countLeadingNot
-
countLeading
-
countLeadingNot
-
countLeading
Deprecated.consider using built-in sets of characters, ..._SET, or Use CharPredicate.anyOf(...)- Parameters:
c
- char- Returns:
- leading count
-
countTrailing
-
countTrailingNot
-
countTrailing
-
countTrailingNot
-
countTrailing
-
countTrailingNot
-
countLeadingSpace
int countLeadingSpace() -
countLeadingNotSpace
int countLeadingNotSpace() -
countLeadingSpace
int countLeadingSpace(int startIndex) -
countLeadingNotSpace
int countLeadingNotSpace(int startIndex) -
countLeadingSpace
int countLeadingSpace(int startIndex, int endIndex) -
countLeadingNotSpace
int countLeadingNotSpace(int startIndex, int endIndex) -
countTrailingSpace
int countTrailingSpace() -
countTrailingNotSpace
int countTrailingNotSpace() -
countTrailingSpace
int countTrailingSpace(int fromIndex) -
countTrailingNotSpace
int countTrailingNotSpace(int fromIndex) -
countTrailingSpace
int countTrailingSpace(int startIndex, int fromIndex) -
countTrailingNotSpace
int countTrailingNotSpace(int startIndex, int fromIndex) -
countLeadingSpaceTab
int countLeadingSpaceTab() -
countLeadingNotSpaceTab
int countLeadingNotSpaceTab() -
countLeadingSpaceTab
int countLeadingSpaceTab(int startIndex) -
countLeadingNotSpaceTab
int countLeadingNotSpaceTab(int startIndex) -
countLeadingSpaceTab
int countLeadingSpaceTab(int startIndex, int endIndex) -
countLeadingNotSpaceTab
int countLeadingNotSpaceTab(int startIndex, int endIndex) -
countTrailingSpaceTab
int countTrailingSpaceTab() -
countTrailingNotSpaceTab
int countTrailingNotSpaceTab() -
countTrailingSpaceTab
int countTrailingSpaceTab(int fromIndex) -
countTrailingNotSpaceTab
int countTrailingNotSpaceTab(int fromIndex) -
countTrailingSpaceTab
int countTrailingSpaceTab(int startIndex, int fromIndex) -
countTrailingNotSpaceTab
int countTrailingNotSpaceTab(int startIndex, int fromIndex) -
countLeadingWhitespace
int countLeadingWhitespace() -
countLeadingNotWhitespace
int countLeadingNotWhitespace() -
countLeadingWhitespace
int countLeadingWhitespace(int startIndex) -
countLeadingNotWhitespace
int countLeadingNotWhitespace(int startIndex) -
countLeadingWhitespace
int countLeadingWhitespace(int startIndex, int endIndex) -
countLeadingNotWhitespace
int countLeadingNotWhitespace(int startIndex, int endIndex) -
countTrailingWhitespace
int countTrailingWhitespace() -
countTrailingNotWhitespace
int countTrailingNotWhitespace() -
countTrailingWhitespace
int countTrailingWhitespace(int fromIndex) -
countTrailingNotWhitespace
int countTrailingNotWhitespace(int fromIndex) -
countTrailingWhitespace
int countTrailingWhitespace(int startIndex, int fromIndex) -
countTrailingNotWhitespace
int countTrailingNotWhitespace(int startIndex, int fromIndex) -
countLeading
Deprecated. -
countTrailing
Deprecated. -
countOfSpaceTab
int countOfSpaceTab() -
countOfNotSpaceTab
int countOfNotSpaceTab() -
countOfWhitespace
int countOfWhitespace() -
countOfNotWhitespace
int countOfNotWhitespace() -
countOf
Deprecated. -
countOfAny
-
countOfAnyNot
-
countOfAny
-
countOfAnyNot
-
countOfAny
-
countOfAnyNot
-
countLeadingColumns
Count column of indent given by chars in the set in this sequence, expanding tabs to 4th column- Parameters:
startColumn
- column of where this sequence startschars
- whitespace characters- Returns:
- column of first non-whitespace as given by chars
-
trimStartRange
Range of kept sequence when trim start/end of this sequence is performed, characters to trim are passed in the sequence argumentreturns range of kept sequence or if nothing matched then Range.NULL is returned, meaning keep all
If character set in the form of character sequence is not passed in the
SequenceUtils.WHITESPACE
are assumed.- Parameters:
keep
- minimum length of would be trimmed characters to keep. ie. keep 4, will leave 0..4 as is but remove any >4chars
- set of characters to trim from start of line- Returns:
- range in this sequence to keep or Range.NULL if to keep all
-
trimEndRange
-
trimRange
-
trimStartRange
-
trimEndRange
-
trimRange
-
trimStartRange
-
trimEndRange
-
trimRange
-
trimStartRange
-
trimEndRange
-
trimRange
-
trimStart
Trim, Trim start/end of this sequence, characters to trim are passed in the sequence argumentreturns trimmed sequence or if nothing matched the original sequence
If character set in the form of character sequence is not passed in the
SequenceUtils.WHITESPACE
are assumed.- Parameters:
keep
- minimum length of would be trimmed characters to keep. ie. keep 4, will leave 0..4 as is but remove any >4chars
- set of characters to trim from start of line- Returns:
- sequence after it is trimmed
-
trimEnd
-
trim
-
trimStart
-
trimEnd
-
trim
-
trimStart
-
trimEnd
-
trim
-
trimStart
-
trimEnd
-
trim
-
trimmedStart
Get the characters Trimmed, Trimmed from start/end of this sequence, characters to trim are passed in the sequence argumentreturns trimmed sequence or if nothing matched the original sequence
The pair returning functions return before and after sequence
- Parameters:
keep
- minimum length of would be trimmed characters to keep. ie. keep 4, will leave 0..4 as is but remove any >4chars
- set of characters to trim from start of line- Returns:
- part of the sequence that was trimmed from the start
-
trimmedEnd
-
trimmed
-
trimmedStart
-
trimmedEnd
-
trimmed
-
trimmedStart
-
trimmedEnd
-
trimmed
-
trimmedStart
-
trimmedEnd
-
trimmed
-
padding
Get the chars needed for padding to length- Parameters:
length
- lengthpad
- char to use for padding- Returns:
- padding chars
-
padding
-
padStart
Pad this sequence to given length- Parameters:
length
- length to padpad
- char to use for padding- Returns:
- sequence padded
-
padEnd
-
padStart
-
padEnd
-
isEmpty
boolean isEmpty()- Specified by:
isEmpty
in interfaceCharSequence
-
isBlank
boolean isBlank() -
isNotEmpty
boolean isNotEmpty() -
isNotBlank
boolean isNotBlank() -
isNull
boolean isNull() -
isNotNull
boolean isNotNull() -
ifNull
If this sequence is the nullSequence() instance then returns other, otherwise returns this sequence.- Parameters:
other
- based sequence to return if this is nullSequence()- Returns:
- this or other
-
ifNullEmptyAfter
If this sequence is the nullSequence() instance then returns an empty subSequence from the end of other, otherwise returns this sequence.- Parameters:
other
- based sequence from which to take the empty sequence- Returns:
- this or other.subSequence(other.length(), other.length())
-
ifNullEmptyBefore
If this sequence is the nullSequence() instance then returns an empty subSequence from the start of other, otherwise returns this sequence.- Parameters:
other
- based sequence from which to take the empty sequence- Returns:
- this or other.subSequence(0, 0)
-
nullIfEmpty
If this sequence is empty return nullSequence() otherwise returns this sequence.- Returns:
- this or nullSequence()
-
nullIfBlank
If this sequence is blank return nullSequence() otherwise returns this sequence.- Returns:
- this or nullSequence()
-
nullIf
If condition is true return nullSequence() otherwise returns this sequence.- Parameters:
condition
- when true return NULL else this- Returns:
- this or nullSequence()
-
nullIf
@NotNull T nullIf(@NotNull @NotNull BiPredicate<? super T, ? super CharSequence> predicate, CharSequence... matches) If predicate returns true for this sequence and one of given sequences return nullSequence() otherwise returns this sequence.- Parameters:
predicate
- bi predicate for test, first argument is always this, second is one of the match sequencesmatches
- match sequence list- Returns:
- this or nullSequence()
-
nullIfNot
@NotNull T nullIfNot(@NotNull @NotNull BiPredicate<? super T, ? super CharSequence> predicate, CharSequence... matches) -
nullIf
@NotNull T nullIf(@NotNull @NotNull Predicate<? super CharSequence> predicate, CharSequence... matches) If predicate returns true for one of given sequences return nullSequence() otherwise returns this sequence.- Parameters:
predicate
- sequence predicatematches
- match sequence list- Returns:
- this or nullSequence()
-
nullIfNot
@NotNull T nullIfNot(@NotNull @NotNull Predicate<? super CharSequence> predicate, CharSequence... matches) -
nullIf
If this sequence matches one of given sequences return nullSequence() otherwise returns this sequence.- Parameters:
matches
- match sequence list- Returns:
- this or nullSequence()
-
nullIfNot
-
nullIfStartsWith
-
nullIfNotStartsWith
-
nullIfStartsWithNot
Deprecated. -
nullIfEndsWith
-
nullIfNotEndsWith
-
nullIfStartsWithIgnoreCase
-
nullIfNotStartsWithIgnoreCase
-
nullIfEndsWithIgnoreCase
-
nullIfNotEndsWithIgnoreCase
-
nullIfStartsWith
-
nullIfNotStartsWith
-
nullIfEndsWith
-
nullIfNotEndsWith
-
nullIfEndsWithNot
Deprecated. -
eolEndLength
int eolEndLength()Get the length of EOL character at the end of this sequence, if present.\n - 1 \r - 1 \r\n - 2
- Returns:
- 0 if no EOL, 1, or 2 depending on the EOL suffix of this sequence
-
eolStartLength
Deprecated. -
eolEndLength
int eolEndLength(int eolEnd) Get the length of EOL character at the given index of this sequence, if present.\n - 1 \r - 1 \r\n - 2
- Parameters:
eolEnd
- index where the EOL ends, if any, any value can be passed for this argument. If > length of this sequence then it is the same as passing length(), if 0 or less then 0 is returned.- Returns:
- 0 if no EOL, 1, or 2 depending on the EOL suffix of this sequence
-
eolStartLength
int eolStartLength(int eolStart) Get the length of EOL character at the given index of this sequence, if present.\n - 1 \r - 1 \r\n - 2
- Parameters:
eolStart
- index where the EOL starts, if any, any value can be passed for this argument. If >= length of this sequence then 0 is returned if 0 or less then it is the same as 0- Returns:
- 0 if no EOL, 1, or 2 depending on the EOL suffix of this sequence
-
eolLength
Deprecated. -
eolEndRange
Return Range of eol at given index- Parameters:
eolEnd
- index where the EOL ends, if any, any value can be passed for this argument. If > length of this sequence then it is the same as passing length(), if 0 or less then 0 is returned.- Returns:
- range of eol given by index of its end or Range.NULL if no eol ends at index
-
eolStartRange
Return Range of eol at given index- Parameters:
eolStart
- index where the EOL starts, if any, any value can be passed for this argument. If >= length of this sequence then 0 is returned if 0 or less then it is the same as 0- Returns:
- range of eol given by index of its end or Range.NULL if no eol starts at index
-
trimEOL
Trim last eol at the end of this sequence,- Returns:
- sequence with one EOL trimmed off if it had one
-
trimmedEOL
Get Trimmed part bytrimEOL()
- Returns:
- trimmed off EOL if sequence had one or
nullSequence()
-
endOfDelimitedBy
Find start/end region in this sequence delimited by any characters in argument or the CharSequenceFor Any and AnyNot methods uses the CharSequence argument as a character set of possible delimiting characters
- Parameters:
s
- character sequence delimiting the regionindex
- from which to start looking for end of region- Returns:
- index of end of region delimited by s
-
endOfDelimitedByAny
-
endOfDelimitedByAnyNot
-
startOfDelimitedBy
-
startOfDelimitedByAny
-
startOfDelimitedByAnyNot
-
endOfLine
int endOfLine(int index) Get the offset of the end of line at given index, end of line delimited by \n- Parameters:
index
- index where to start searching for end of line- Returns:
- index of end of line delimited by \n
-
endOfLineAnyEOL
int endOfLineAnyEOL(int index) Get the offset of the end of line at given index, end of line delimited by \n or any of \n \r \r\n for Any methods.- Parameters:
index
- index where to start searching for end of line- Returns:
- index of end of line delimited by \n
-
startOfLine
int startOfLine(int index) Get the offset of the start of line at given index, start of line delimited by \n- Parameters:
index
- index where to start searching for end of line- Returns:
- index of end of line delimited by \n
-
startOfLineAnyEOL
int startOfLineAnyEOL(int index) Get the offset of the start of line at given index, start of line delimited by \n or any of \n \r \r\n for Any methods.- Parameters:
index
- index where to start searching for end of line- Returns:
- index of end of line delimited by \n
-
lineRangeAt
Get the line characters at given index, line delimited by \n- Parameters:
index
- index at which to get the line- Returns:
- range in sequence for the line delimited by '\n', containing index
-
lineRangeAtAnyEOL
Get the line characters at given index, line delimited by \n, \r or \r\n- Parameters:
index
- index at which to get the line- Returns:
- range in sequence for the line delimited by end of line, containing index
-
lineAt
Get the line characters at given index, line delimited by \n- Parameters:
index
- index at which to get the line- Returns:
- sub-sequence for the line containing index
-
lineAtAnyEOL
Get the line characters at given index, line delimited by \n, \r or \r\n- Parameters:
index
- index at which to get the line- Returns:
- sub-sequence for the line containing index
-
trimTailBlankLines
Trim leading trailing blank lines in this sequence- Returns:
- return sequence with trailing blank lines trimmed off
-
trimLeadBlankLines
-
leadingBlankLinesRange
@NotNull @NotNull Range leadingBlankLinesRange(@NotNull @NotNull CharPredicate eolChars, int fromIndex, int endIndex) Get Range of leading blank lines at given index offsets in sequence- Parameters:
eolChars
- characters to consider as EOL, noteeolStartLength(int)
should report length of EOL found if length > 1fromIndex
- minimum index in sequence to check and include in range of blank lines can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()endIndex
- index in sequence from which to start blank line search, also maximum index to include in blank lines range can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()- Returns:
- range of blank lines at or before fromIndex and ranging to minimum of startIndex, Range.NULL if none found if the range in sequence contains only whitespace characters then the whole range will be returned even if contains no EOL characters
-
trailingBlankLinesRange
@NotNull @NotNull Range trailingBlankLinesRange(CharPredicate eolChars, int startIndex, int fromIndex) Get Range of trailing blank lines at given index offsets in sequence- Parameters:
eolChars
- characters to consider as EOL, noteeolStartLength(int)
should report length of EOL found if length > 1startIndex
- index in sequence from which to start blank line search, also maximum index to include in blank lines range can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()fromIndex
- maximum index in sequence to check and include in range of blank lines can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()- Returns:
- range of blank lines at or before fromIndex and ranging to minimum of startIndex if the range in sequence contains only whitespace characters then the whole range will be returned even if contains no EOL characters
-
leadingBlankLinesRange
-
leadingBlankLinesRange
-
leadingBlankLinesRange
-
trailingBlankLinesRange
-
trailingBlankLinesRange
-
trailingBlankLinesRange
-
blankLinesRemovedRanges
-
blankLinesRemovedRanges
-
blankLinesRemovedRanges
-
blankLinesRemovedRanges
@NotNull @NotNull List<Range> blankLinesRemovedRanges(@NotNull @NotNull CharPredicate eolChars, int fromIndex, int endIndex) -
trimToEndOfLine
Trim end to end of line containing index- Parameters:
eolChars
- characters to consider as EOL, noteeolStartLength(int)
should report length of EOL found if length > 1includeEol
- true if EOL is to be included in the lineindex
- index for offset contained by the line can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()- Returns:
- trimmed version of the sequence to given EOL or the original sequence
-
trimToEndOfLine
-
trimToEndOfLine
-
trimToEndOfLine
-
trimToEndOfLine
-
trimToStartOfLine
@NotNull T trimToStartOfLine(@NotNull @NotNull CharPredicate eolChars, boolean includeEol, int index) Trim start to start of line containing index- Parameters:
eolChars
- characters to consider as EOL, noteeolStartLength(int)
should report length of EOL found if length > 1includeEol
- true if EOL is to be included in the lineindex
- index for offset contained by the line can be any value, if less than 0 it is the same as 0, if greater than length() it is the same as length()- Returns:
- trimmed version of the sequence to given EOL or the original sequence
-
trimToStartOfLine
-
trimToStartOfLine
-
trimToStartOfLine
-
trimToStartOfLine
-
normalizeEOL
replace any \r\n and \r by \n- Returns:
- string with only \n for line separators
-
normalizeEndWithEOL
replace any \r\n and \r by \n, append terminating EOL if one is not present- Returns:
- string with only \n for line separators and terminated by \n
-
matches
Test the sequence for a match to another CharSequence- Parameters:
chars
- characters to match against- Returns:
- true if match
-
matchesIgnoreCase
-
matches
-
equalsIgnoreCase
Test the sequence for a match to another CharSequence, ignoring case differences- Parameters:
other
- characters to match against- Returns:
- true if match
-
equals
Test the sequence for a match to another CharSequence- Parameters:
other
- characters to match againstignoreCase
- case ignored when true- Returns:
- true if match
-
matchChars
Test the sequence portion for a match to another CharSequence- Parameters:
chars
- characters to match against- Returns:
- true if characters at the start of this sequence match
-
matchCharsIgnoreCase
-
matchChars
-
matchChars
Test the sequence portion for a match to another CharSequence- Parameters:
chars
- characters to match againststartIndex
- index from which to start the matchignoreCase
- if true match ignoring case differences- Returns:
- true if characters at the start index of this sequence match
-
matchChars
-
matchCharsIgnoreCase
-
matchedCharCount
int matchedCharCount(@NotNull @NotNull CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) Test the sequence portion for a match to another CharSequence- Parameters:
chars
- characters to match againststartIndex
- index from which to start the matchendIndex
- index at which to end the matchingfullMatchOnly
- if true will do quick fail if length of chars is longer than characters after startIndex in this sequenceignoreCase
- if true match ignoring case differences- Returns:
- count of characters at the start index of this sequence matching corresponding characters in chars
-
matchedCharCount
int matchedCharCount(@NotNull @NotNull CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) -
matchedCharCount
-
matchedCharCount
-
matchedCharCount
-
matchedCharCountIgnoreCase
-
matchedCharCountIgnoreCase
-
matchCharsReversed
Test the sequence portion for a match to another CharSequence, reverse order- Parameters:
chars
- characters to match againstendIndex
- index from which to start the match and proceed to 0ignoreCase
- if true match ignoring case differences- Returns:
- true if characters at the start index of this sequence match
-
matchCharsReversed
-
matchCharsReversedIgnoreCase
-
matchedCharCountReversed
int matchedCharCountReversed(@NotNull @NotNull CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) Test the sequence portion for a match to another CharSequence, equivalent to taking this.subSequence(startIndex, fromIndex) and then count matching chars going from end of both sequences- Parameters:
chars
- characters to match againststartIndex
- index at which to stop the matchfromIndex
- index from which to start the match, not inclusive, matching starts at fromIndex-1 and proceeds towards 0ignoreCase
- if true match ignoring case differences- Returns:
- count of characters at the from index of this sequence matching corresponding characters in chars in reverse order
-
matchedCharCountReversed
-
matchedCharCountReversedIgnoreCase
int matchedCharCountReversedIgnoreCase(@NotNull @NotNull CharSequence chars, int startIndex, int fromIndex) -
matchedCharCountReversed
int matchedCharCountReversed(@NotNull @NotNull CharSequence chars, int fromIndex, boolean ignoreCase) -
matchedCharCountReversed
-
matchedCharCountReversedIgnoreCase
-
endsWith
test if this sequence ends with given characters- Parameters:
suffix
- characters to test- Returns:
- true if ends with suffix
-
endsWith
-
endsWithEOL
boolean endsWithEOL() -
endsWithAnyEOL
boolean endsWithAnyEOL() -
endsWithSpace
boolean endsWithSpace() -
endsWithSpaceTab
boolean endsWithSpaceTab() -
endsWithWhitespace
boolean endsWithWhitespace() -
endsWithIgnoreCase
test if this sequence ends with given characters, ignoring case differences- Parameters:
suffix
- characters to test- Returns:
- true if ends with suffix
-
endsWith
test if this sequence ends with given characters- Parameters:
suffix
- characters to testignoreCase
- case ignored when true- Returns:
- true if ends with suffix
-
startsWith
test if this sequence starts with given characters- Parameters:
prefix
- characters to test- Returns:
- true if starts with prefix
-
startsWith
-
startsWithEOL
boolean startsWithEOL() -
startsWithAnyEOL
boolean startsWithAnyEOL() -
startsWithSpace
boolean startsWithSpace() -
startsWithSpaceTab
boolean startsWithSpaceTab() -
startsWithWhitespace
boolean startsWithWhitespace() -
startsWithIgnoreCase
test if this sequence starts with given characters, ignoring case differences- Parameters:
prefix
- characters to test- Returns:
- true if starts with prefix
-
startsWith
test if this sequence starts with given characters- Parameters:
prefix
- characters to testignoreCase
- case ignored when true- Returns:
- true if starts with prefix
-
removeSuffix
Remove suffix if present- Parameters:
suffix
- characters to remove- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removeSuffixIgnoreCase
Remove suffix if present, ignoring case differences- Parameters:
suffix
- characters to remove- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removeSuffix
Remove suffix if present- Parameters:
suffix
- characters to removeignoreCase
- case ignored when true- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removePrefix
Remove prefix if present- Parameters:
prefix
- characters to remove- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
removePrefixIgnoreCase
Remove prefix if present, ignoring case differences- Parameters:
prefix
- characters to remove- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
removePrefix
Remove prefix if present- Parameters:
prefix
- characters to removeignoreCase
- case ignored when true- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
removeProperSuffix
Remove suffix if present but only if this sequence is longer than the suffix- Parameters:
suffix
- characters to remove- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removeProperSuffixIgnoreCase
Remove suffix if present but only if this sequence is longer than the suffix, ignoring case differences- Parameters:
suffix
- characters to remove- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removeProperSuffix
Remove suffix if present but only if this sequence is longer than the suffix- Parameters:
suffix
- characters to removeignoreCase
- case ignored when true- Returns:
- sequence with suffix removed, or same sequence if no suffix was present
-
removeProperPrefix
Remove prefix if present but only if this sequence is longer than the suffix- Parameters:
prefix
- characters to remove- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
removeProperPrefixIgnoreCase
Remove prefix if present but only if this sequence is longer than the suffix, ignoring case differences- Parameters:
prefix
- characters to remove- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
removeProperPrefix
Remove prefix if present but only if this sequence is longer than the suffix- Parameters:
prefix
- characters to removeignoreCase
- case ignored when true- Returns:
- sequence with prefix removed, or same sequence if no prefix was present
-
insert
Insert char sequence at given index- Parameters:
index
- index of insertion. if >length of this sequence then same as length, if <0 then same as 0chars
- char sequence to insert- Returns:
- resulting sequence based sequence implementation may throw an IllegalArgumentException if inserting another based sequence out of order based on offsets
-
insert
Deprecated.useinsert(int, CharSequence)
instead- Parameters:
chars
- charsindex
- index of insertion- Returns:
- resulting sequence
-
delete
Delete range in sequence- Parameters:
startIndex
- start index of deletionendIndex
- end index, not inclusive, of insertion- Returns:
- resulting sequence
-
replace
Replace part of the sequence with a char sequence- Parameters:
startIndex
- start index of replaced partendIndex
- end index of replaced partreplacement
- char sequence- Returns:
- resulting sequence
-
replace
Replace all occurrences of one sequence with another- Parameters:
find
- sequence to findreplace
- replacement sequence- Returns:
- array of indices
-
toLowerCase
Map characters of this sequence to: Uppercase, Lowercase or use custom mapping- Returns:
- lowercase version of sequence
-
toUpperCase
-
toMapped
-
toNbSp
Map spaces to non break spaces- Returns:
- mapped sequence with spc changed to NbSp
-
toSpc
Map non break spaces to spaces- Returns:
- mapped sequence with NbSp changed to spc
-
toVisibleWhitespaceString
-
splitList
@NotNull @NotNull List<T> splitList(@NotNull @NotNull CharSequence delimiter, int limit, int flags, @Nullable @Nullable CharPredicate trimChars) Split helpers based on delimiter character sets contained in CharSequence- Parameters:
delimiter
- delimiter char sequence to use for splittinglimit
- max number of segments to splitflags
- flags for desired options: SPLIT_INCLUDE_DELIMS: include delimiters as part of split item SPLIT_TRIM_PARTS: trim the segments, if trimChars is not null or empty then this flag is turned on automatically SPLIT_SKIP_EMPTY: skip empty segments (or empty after trimming if enabled) SPLIT_INCLUDE_DELIM_PARTS: include delimiters as separate split item of its own SPLIT_TRIM_SKIP_EMPTY: same as SPLIT_TRIM_PARTS | SPLIT_SKIP_EMPTYtrimChars
- set of characters that should be used for trimming individual split results- Returns:
- List of split results
-
splitList
-
splitList
-
split
@NotNull @NotNull T[] split(@NotNull @NotNull CharSequence delimiter, int limit, int flags, @Nullable @Nullable CharPredicate trimChars) -
split
-
split
-
split
Deprecated. -
split
Deprecated. -
split
Deprecated. -
splitList
@NotNull @NotNull List<T> splitList(@NotNull @NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable @Nullable CharPredicate trimChars) Split helpers based on delimiter character sets contained in CharPredicate- Parameters:
delimiter
- sequence of chars on which to split this sequencelimit
- max number of segments to splitincludeDelims
- if true include delimiters as part of split itemtrimChars
- set of characters that should be used for trimming individual split results- Returns:
- List of split results
-
splitList
@NotNull @NotNull List<T> splitList(@NotNull @NotNull CharSequence delimiter, boolean includeDelims, @Nullable @Nullable CharPredicate trimChars) -
split
@NotNull @NotNull T[] split(@NotNull @NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable @Nullable CharPredicate trimChars) -
split
@NotNull @NotNull T[] split(@NotNull @NotNull CharSequence delimiter, boolean includeDelims, @Nullable @Nullable CharPredicate trimChars) -
splitEOL
-
splitEOL
-
splitListEOL
-
splitListEOL
-
splitListEOL
@NotNull @NotNull List<T> splitListEOL(boolean includeDelims, @Nullable @Nullable CharPredicate trimChars) -
indexOfAll
Get indices of all occurrences of a sequence- Parameters:
s
- sequence whose indices to find- Returns:
- array of indices
-
prefixWith
Prefix this sequence with a char sequence- Parameters:
prefix
- char sequence- Returns:
- resulting sequence
-
suffixWith
Prefix this sequence with a char sequence- Parameters:
suffix
- char sequence- Returns:
- resulting sequence
-
prefixOnceWith
Prefix this sequence with a char sequence if not already starting with prefix- Parameters:
prefix
- char sequence- Returns:
- resulting sequence
-
suffixOnceWith
Suffix this sequence with a char sequence if not already ending with suffix- Parameters:
suffix
- char sequence- Returns:
- resulting sequence
-
appendEOL
-
suffixWithEOL
-
prefixWithEOL
-
prefixOnceWithEOL
-
suffixOnceWithEOL
-
appendSpace
-
suffixWithSpace
-
prefixWithSpace
-
appendSpaces
-
suffixWithSpaces
-
prefixWithSpaces
-
prefixOnceWithSpace
-
suffixOnceWithSpace
-
appendTo
@NotNull T appendTo(@NotNull @NotNull StringBuilder out, @Nullable @Nullable CharMapper charMapper, int startIndex, int endIndex) Append helpers- Parameters:
out
- string builderstartIndex
- start indexendIndex
- end indexcharMapper
- mapping to use for output or null if none- Returns:
- this
-
appendTo
-
appendTo
@NotNull T appendTo(@NotNull @NotNull StringBuilder out, @Nullable @Nullable CharMapper charMapper, int startIndex) -
appendTo
-
appendTo
-
appendTo
-
appendRangesTo
@NotNull T appendRangesTo(@NotNull @NotNull StringBuilder out, @Nullable @Nullable CharMapper charMapper, Range... ranges) Append given ranges of this sequence to string builder- Parameters:
out
- string builder to append tocharMapper
- mapping to use for output or null if noneranges
- ranges to append, null range or one for which range.isNull() is true ranges are skipped- Returns:
- this
-
appendRangesTo
-
appendRangesTo
@NotNull T appendRangesTo(@NotNull @NotNull StringBuilder out, @Nullable @Nullable CharMapper charMapper, Iterable<? extends Range> ranges) -
appendRangesTo
-
extractRanges
Build a sequence of ranges in this sequenceNOTE: BasedSequence ranges must be non-overlapping and ordered by startOffset or IllegalArgumentException will be thrown
- Parameters:
ranges
- ranges to extract- Returns:
- resulting sequence
-
extractRanges
-
append
Concatenate this sequence and list of others, returning sequence of result- Parameters:
sequences
- list of char sequences to append to this sequence, null sequences are skipped- Returns:
- appended sequence
-
append
-
lineColumnAtIndex
Get the line and column information from index into sequence- Parameters:
index
- index for which to get line information- Returns:
- Pair(line, column) where line and column are 0 based, throws IllegalArgumentException if index < 0 or > length.
-
getLineColumnAtIndex
Deprecated. -
columnAtIndex
int columnAtIndex(int index) -
getColumnAtIndex
Deprecated. -
isCharAt
Safe, if index out of range returns '\0'- Parameters:
index
- index in stringpredicate
- character set predicate- Returns:
- true if character at index tests true
-
toStringOrNull
Return string or null if BaseSequence.NULL- Returns:
- string or null if BaseSequence.NULL
-
isIn
-
isIn
-