|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.yajul.util.StringUtil
public class StringUtil
Provides commonly used string functions.
| Constructor Summary | |
|---|---|
StringUtil()
|
|
| Method Summary | |
|---|---|
static void |
appendIfNotEmpty(java.lang.String string,
java.lang.StringBuffer buf)
Appends the string to the string buffer IFF it is not 'empty' (null or zero length). |
static java.lang.String |
defaultToString(java.lang.Object o)
Prints the class name of the object, followed by '@', followed by the hash code of the object, just like java.lang.Object.toString(). |
static byte[] |
getBytes(java.lang.String s,
java.lang.String charset)
Returns the String encoded into an array of bytes using the named charset. |
static void |
hexChars(char[] chars,
int inByte,
char[] out)
Converts the byte into a two element array of hex characters. |
static java.lang.String |
hexString(byte[] bytes)
Returns a string containing the hexadecimal representation of the array of bytes. |
static java.lang.String |
hexString(byte[] bytes,
java.lang.String separator)
Returns a string containing the hexadecimal representation of the array of bytes, separated by an optional string. |
static void |
hexString(java.lang.StringBuffer buf,
byte[] bytes,
java.lang.String separator,
boolean lowerCase)
Appends the hex representation of the bytes to the string buffer, separated by an optional separator string. |
static boolean |
isEmpty(java.lang.String str)
Returns true if the string is null or zero length. |
static byte |
parseHexChar(char n)
Convert a hexadecimal character to a byte. |
static byte[] |
parseHexString(java.lang.String hexString)
Convert a string of hexadecimal characters to a byte array. |
static java.lang.String |
substringAfter(java.lang.String string,
java.lang.String delim)
Returns the substring after the delimiter string, not including the delimiter string. |
static java.lang.String |
substringBefore(java.lang.String string,
java.lang.String delim)
Returns the substring before the delimiter string, not including the delimiter string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringUtil()
| Method Detail |
|---|
public static byte[] getBytes(java.lang.String s,
java.lang.String charset)
s - the stringcharset - the name of a supported
charset , or null if the default
charset is to be used.
public static java.lang.String defaultToString(java.lang.Object o)
o - The object to print.
public static boolean isEmpty(java.lang.String str)
str - - The string to test.
public static java.lang.String hexString(byte[] bytes)
bytes - The array of bytes to turn into hex.
public static java.lang.String hexString(byte[] bytes,
java.lang.String separator)
bytes - The array of bytes to turn into hex.separator - The separator string. If null or zero length, no
separator will be used.
public static byte[] parseHexString(java.lang.String hexString)
hexString - The hexadecimal string
public static byte parseHexChar(char n)
n - The hex character
public static void hexString(java.lang.StringBuffer buf,
byte[] bytes,
java.lang.String separator,
boolean lowerCase)
bytes - The bytes to convert to hex.buf - The buffer to append to.separator - The separator string. If null or zero length, no
separator will be used.lowerCase - True for lower case hex (e.g. 34f0), false for upper
case hex (e.g. 34F0).
public static void hexChars(char[] chars,
int inByte,
char[] out)
chars - The hex character set to use (e.g. HEX_BYTES_LOWER / HEX_BYTES_UPPER).inByte - The input byte.out - The output array of characters. Length must be >= 2.
public static void appendIfNotEmpty(java.lang.String string,
java.lang.StringBuffer buf)
string - The string to append.buf - The string buffer.isEmpty(String)
public static java.lang.String substringBefore(java.lang.String string,
java.lang.String delim)
string - The string to look in.delim - The delimiter string.
public static java.lang.String substringAfter(java.lang.String string,
java.lang.String delim)
string - The string to look in.delim - The delimiter string.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||