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 StringBuilder f(StringBuilder stb, String format, Object... args)
Format using the standard US.
static StringBuilder f(String format, Object... args)
Format using the standard US.
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)
Tests if this character sequence starts with the specified prefix.
static byte[] toByteArray(char[] chars)
Convert a char[] to a byte[] using the system-default charset.
static byte[] toByteArray(char[] chars, Charset charset)
Convert a char[] to a byte[].
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CharSequences ()

Public Methods

public static StringBuilder f (StringBuilder stb, String format, Object... args)

Format using the standard US.

Parameters
stb StringBuilder to append the formatted string
format A format string as described in standard Formatter
args Arguments referenced by the format specifiers in the format string
Returns
  • stb (allow chaining)

public static StringBuilder f (String format, Object... args)

Format using the standard US. Best for performance and memory: do not create intermediate String.

Parameters
format A format string as described in standard Formatter
args Arguments referenced by the format specifiers in the format string
Returns
  • the formatted StringBuilder

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)

Tests if this character sequence starts with the specified prefix.

Parameters
text the main character sequence
prefix the prefix token
Returns
  • true if the string is a prefix of the main character sequence

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

public static byte[] toByteArray (char[] chars, Charset charset)

Convert a char[] to a byte[].

Parameters
chars char[] to be converted
charset character set to use (null means to use the system-default charset)
Returns
  • the byte[]