Package snap.util

Class CharSequenceUtils

java.lang.Object
snap.util.CharSequenceUtils

public class CharSequenceUtils extends Object
This class adds some convenience methods for CharSequence.
  • Constructor Details

    • CharSequenceUtils

      public CharSequenceUtils()
  • Method Details

    • getLastChar

      public static char getLastChar(CharSequence theChars)
      Returns the last char.
    • isLastCharNewline

      public static boolean isLastCharNewline(CharSequence theChars)
      Returns whether char sequence ends with newline.
    • indexOfNewline

      public 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.
    • indexAfterNewline

      public 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.
    • indexAfterNewlineOrEnd

      public 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.
    • lastIndexOfNewline

      public 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.
    • lastIndexAfterNewline

      public 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.
    • isLineEnd

      public static boolean isLineEnd(CharSequence theChars, int anIndex)
      Returns whether the index in the given char sequence is at a line end.
    • isAfterLineEnd

      public static boolean isAfterLineEnd(CharSequence theChars, int anIndex)
      Returns whether the index in the given char sequence is at just after a line end.
    • isLineEndChar

      public static boolean isLineEndChar(CharSequence theChars, int anIndex)
      Returns whether a char is a newline char.
    • isLineEndChar

      public static boolean isLineEndChar(char c)
      Returns whether a char is a newline char.
    • startsWith

      public static boolean startsWith(CharSequence theChars, String aString)
      Returns whether sequence starts with given string.
    • getIndentLength

      public static int getIndentLength(CharSequence theChars)
      Returns the length of leading whitespace chars for given char sequence.
    • getIndentString

      public static String getIndentString(CharSequence theChars)
      Returns a string of any leading whitespace chars for given char sequence.
    • isWhiteSpace

      public static boolean isWhiteSpace(CharSequence theChars)
      Returns whether given sequence is just whitespace.
    • getNewlineCount

      public static int getNewlineCount(CharSequence theChars)
      Returns number of newlines in given chars.