public class

CharSequences

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

Class Overview

Utility methods for character sequences.

Summary

Public Constructors
CharSequences()
Public Methods
static int indexOf(CharSequence text, char c, int from)
Implementation of indexOf for CharSequence.
static int indexOf(CharSequence text, char c)
Implementation of indexOf for CharSequence.
static int indexOf2(CharSequence text, char c0, char c1)
Find the first one of two characters and return its position.
static int indexOfn(CharSequence text, char... cs)
Find the first one of n characters and return its position.
static boolean isBlank(CharSequence s)
Determine if a character sequence is null, empty, or contains WSP chars exclusively.
static boolean startsWith(CharSequence text, String prefix, boolean trim)
Tests if this character sequence starts with the specified prefix.
static boolean startsWith(CharSequence text, String prefix)
static byte[] toByteArray(char[] chars)
Convert a char[] to a byte[] using the system-default charset.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CharSequences ()

Public Methods

public static int indexOf (CharSequence text, char c, int from)

Implementation of indexOf for CharSequence. Same behavior as indexOf(int).

Parameters
text the character sequence
c char
from first index to start from
Returns
  • the index position, or -1 if not found

public static int indexOf (CharSequence text, char c)

Implementation of indexOf for CharSequence. Same behavior as indexOf(int).

Parameters
text the character sequence
c char
Returns
  • the index position, or -1 if not found

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

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

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

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

public static boolean startsWith (CharSequence text, String prefix)

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[]