Class CharSequences

java.lang.Object
com.pnfsoftware.jeb.util.format.CharSequences

public class CharSequences extends Object
Utility methods for character sequences.
  • Constructor Details

    • CharSequences

      public CharSequences()
  • Method Details

    • toByteArray

      public static byte[] toByteArray(char[] chars)
      Convert a char[] to a byte[] using the system-default charset.
      Parameters:
      chars - char[] to be converted
      Returns:
      the byte[]
    • isBlank

      public static boolean isBlank(CharSequence s)
      Determine if a character sequence is null, empty, or contains WSP chars exclusively.
      Parameters:
      s - the character sequence
      Returns:
      true if the sequence is null or blank
    • indexOf

      public static int indexOf(CharSequence text, char c)
      Implementation of indexOf for CharSequence. Same behavior as String.indexOf(int).
      Parameters:
      text - the character sequence
      c - char
      Returns:
      the index position, or -1 if not found
    • indexOf

      public static int indexOf(CharSequence text, char c, int from)
      Implementation of indexOf for CharSequence. Same behavior as String.indexOf(int).
      Parameters:
      text - the character sequence
      c - char
      from - first index to start from
      Returns:
      the index position, or -1 if not found
    • indexOf2

      public static int indexOf2(CharSequence text, char c0, char c1)
      Find the first one of two characters and return its position.
      Parameters:
      text - the character sequence
      c0 - first char
      c1 - second char
      Returns:
      the position of the first occurrence of c0 or c1 (whichever came first), -1 if not found
    • indexOfn

      public static int indexOfn(CharSequence text, char... cs)
      Find the first one of n characters and return its position.
      Parameters:
      text - string
      cs - characters
      Returns:
      the position of the first occurrence of any char (whichever came first), -1 if not found
    • startsWith

      public static boolean startsWith(CharSequence text, String prefix)
    • startsWith

      public static boolean startsWith(CharSequence text, String prefix, boolean trim)
      Tests if this character sequence starts with the specified prefix.
      Parameters:
      text - the main character sequence
      prefix - the prefix token
      trim - act as a trimmed string: ignore preceding spaces
      Returns:
      true if the string is a prefix of the main character sequence