|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.foray.common.StringUtil
public final class StringUtil
Utility class containing methods that are useful for manipulating or managing strings.
Field Summary | |
---|---|
static String |
EMPTY_STRING
An empty string suitable for String comparisons or initializations. |
static String |
LINE_SEPARATOR
A static capture of the system line separator. |
static char |
NULL_TERMINATOR
The null terminator character, used to mark the end of Strings in char arrays in some applications, U+0000. |
static String |
SINGLE_SPACE
A single space. |
Method Summary | |
---|---|
static byte |
asciiHexBytesToHex(byte byte1,
byte byte2)
Converts two bytes, each of which must be valid ASCII hex (0-9, A-F, a-f) into the byte that those ASCII characters represent. |
static byte |
asciiHexByteToHex(byte inputByte)
Converts one ASCII Hex byte (0-9, A-F, a-f) to the hexadecimal byte that it represents. |
static String |
charToHexString(char c,
boolean upperCase,
int minimumSize)
Returns a String representing a character's hex value. |
static String |
charToOctalString(char c,
int minimumSize)
Returns a String representing a character's octal value. |
static int |
firstDifferent(String string1,
String string2)
Compares two Strings for equality, returning the index to the first different character. |
static int |
indexOfSortedCharArray(char[] charArray,
char inputChar,
int startIndex,
int endIndex)
Efficiently finds the index within charArray ,
if any, that matches inputChar . |
static boolean |
isASCIIHex(int input)
Reports whether an input character is a valid hexadecimal character. |
static void |
lineBreakStringBuffer(StringBuilder buffer,
String eol,
int length)
Adds linefeeds to the contents of a StringBuffer. |
static int |
nullTerminatedLength(char[] charArray,
int start)
Computes the length of all or part of a null-terminated char array. |
static int |
nullTerminatedLength(CharSequence charSequence,
int start)
Computes the length of all or part of a null-terminated String or other CharSequence. |
static int |
replace(StringBuilder buffer,
String oldString,
String newString)
Replaces all occurrences of a given substring with a different substring. |
static void |
toChars(CharSequence source,
int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Copies characters from a CharSequence string into a destination char[]. |
static int[] |
toCodePoints(char[] input)
Converts a char[] to an array of Unicode code points. |
static int[] |
toCodePoints(CharSequence input)
Converts a CharSequence to an array of Unicode code points. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String EMPTY_STRING
public static final String SINGLE_SPACE
public static final String LINE_SEPARATOR
public static final char NULL_TERMINATOR
Method Detail |
---|
public static boolean isASCIIHex(int input)
input
- The character to be tested.
public static byte asciiHexBytesToHex(byte byte1, byte byte2)
byte1
- The high-order byte to be converted.byte2
- The low-order byte to be converted.
public static byte asciiHexByteToHex(byte inputByte)
inputByte
- The ASCII Hex byte to convert.
public static int indexOfSortedCharArray(char[] charArray, char inputChar, int startIndex, int endIndex)
charArray
,
if any, that matches inputChar
. Note:
charArray
must be already sorted. No checking
of this condition is performed.
charArray
- The array of char items which should be searched
to find a match for inputChar
.inputChar
- The char for which a match is sought.startIndex
- The first index in the array to be considered.endIndex
- The last index in the array to be considered.
public static String charToHexString(char c, boolean upperCase, int minimumSize)
c
- The character to be converted.upperCase
- Set to true if the a-f hex characters should be
converted to uppercase.minimumSize
- The minimum size of the return String. The return
value will be padded with sufficient "0" characters at the beginning to
ensure this size.
public static String charToOctalString(char c, int minimumSize)
c
- The character to be converted.minimumSize
- The minimum size of the return String. The return
value will be padded with sufficient "0" characters at the beginning to
ensure this size.
public static void lineBreakStringBuffer(StringBuilder buffer, String eol, int length)
buffer
- The StringBuffer to which line-breaks should be added.eol
- The String that should be used for line-breaking. Note that
indenting can be added to the start of a line by simply adding some
spaces to the end of eol.length
- The maximum length that a line should contain.public static int[] toCodePoints(CharSequence input)
input
- The CharSequence to be converted.
public static int[] toCodePoints(char[] input)
input
- The char[] to be converted.
public static void toChars(CharSequence source, int srcBegin, int srcEnd, char[] dst, int dstBegin)
String.getChars(int, int, char[], int)
.
The first character to be copied is at index srcBegin
;
the last character to be copied is at index srcEnd-1
(thus the total number of characters to be copied is
srcEnd-srcBegin
). The characters are copied into the
subarray of dst
starting at index dstBegin
and ending at index:
dstbegin + (srcEnd-srcBegin) - 1
source
- The CharSequence from which the chars will be copied.srcBegin
- Index of the first character in the CharSequence to copy.srcEnd
- Index after the last character in the CharSequence to copy.dst
- The destination array.dstBegin
- The start offset in the destination array.String.getChars(int, int, char[], int)
public static int firstDifferent(String string1, String string2)
string1
- The first String being compared.string2
- The second String being compared.
public static int replace(StringBuilder buffer, String oldString, String newString)
buffer
- The SringBuffer in which the replacement should occur.oldString
- The substring to be replaced by newString.newString
- The substring that should replace oldString.
public static int nullTerminatedLength(char[] charArray, int start)
charArray
- The array which contains the null-terminated string.start
- The index to the first char in charArray
which should
be counted.
public static int nullTerminatedLength(CharSequence charSequence, int start)
charSequence
- The CharSequence which contains the null-terminated string.start
- The index to the first char in charSequence
which should be counted.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |