Package snap.util
Class CharSequenceUtils
java.lang.Object
snap.util.CharSequenceUtils
This class adds some convenience methods for CharSequence.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getIndentLength
(CharSequence theChars) Returns the length of leading whitespace chars for given char sequence.static String
getIndentString
(CharSequence theChars) Returns a string of any leading whitespace chars for given char sequence.static char
getLastChar
(CharSequence theChars) Returns the last char.static int
getNewlineCount
(CharSequence theChars) Returns number of newlines in given chars.static int
indexAfterNewline
(CharSequence theChars, int aStart) Returns index just beyond next newline (or carriage-return/newline) in given chars starting at given char index.static int
indexAfterNewlineOrEnd
(CharSequence theChars, int aStart) Returns index just beyond next newline (or carriage-return/newline) in given chars starting at given char index.static int
indexOfNewline
(CharSequence theChars, int aStart) Returns index of the next newline (or carriage-return/newline) in given chars starting at given char index.static boolean
isAfterLineEnd
(CharSequence theChars, int anIndex) Returns whether the index in the given char sequence is at just after a line end.static boolean
isLastCharNewline
(CharSequence theChars) Returns whether char sequence ends with newline.static boolean
isLineEnd
(CharSequence theChars, int anIndex) Returns whether the index in the given char sequence is at a line end.static boolean
isLineEndChar
(char c) Returns whether a char is a newline char.static boolean
isLineEndChar
(CharSequence theChars, int anIndex) Returns whether a char is a newline char.static boolean
isWhiteSpace
(CharSequence theChars) Returns whether given sequence is just whitespace.static int
lastIndexAfterNewline
(CharSequence theChars, int aStart) Returns index just beyond previous newline (or carriage-return/newline) in given chars starting at given char index.static int
lastIndexOfNewline
(CharSequence theChars, int aStart) Returns index of the previous newline (or carriage-return/newline) in given chars starting at given char index.static boolean
startsWith
(CharSequence theChars, String aString) Returns whether sequence starts with given string.
-
Constructor Details
-
CharSequenceUtils
public CharSequenceUtils()
-
-
Method Details
-
getLastChar
Returns the last char. -
isLastCharNewline
Returns whether char sequence ends with newline. -
indexOfNewline
Returns index of the next newline (or carriage-return/newline) in given chars starting at given char index. -
indexAfterNewline
Returns index just beyond next newline (or carriage-return/newline) in given chars starting at given char index. -
indexAfterNewlineOrEnd
Returns index just beyond next newline (or carriage-return/newline) in given chars starting at given char index. -
lastIndexOfNewline
Returns index of the previous newline (or carriage-return/newline) in given chars starting at given char index. -
lastIndexAfterNewline
Returns index just beyond previous newline (or carriage-return/newline) in given chars starting at given char index. -
isLineEnd
Returns whether the index in the given char sequence is at a line end. -
isAfterLineEnd
Returns whether the index in the given char sequence is at just after a line end. -
isLineEndChar
Returns whether a char is a newline char. -
isLineEndChar
public static boolean isLineEndChar(char c) Returns whether a char is a newline char. -
startsWith
Returns whether sequence starts with given string. -
getIndentLength
Returns the length of leading whitespace chars for given char sequence. -
getIndentString
Returns a string of any leading whitespace chars for given char sequence. -
isWhiteSpace
Returns whether given sequence is just whitespace. -
getNewlineCount
Returns number of newlines in given chars.
-