public class StringUtil extends Object
Modifier and Type | Method and Description |
---|---|
static StringBuffer |
append(StringBuffer buf,
byte[] o)
Appends hexBytes to a StringBuffer.
|
static boolean |
append(StringBuffer buf,
String description,
boolean flag,
boolean comma)
Appends description to a StringBuffer if a flag is set, optionally preceded by a comma.
|
static boolean |
append(StringBuffer buf,
String name,
int value,
boolean comma)
Appends name=value to a StringBuffer, optionally preceded by a comma.
|
static boolean |
append(StringBuffer buf,
String name,
Object[] o,
boolean comma)
Appends name=[values] to a StringBuffer, optionally preceded by a comma.
|
static boolean |
append(StringBuffer buf,
String name,
Object o,
boolean comma)
Appends name=value to a StringBuffer, optionally preceded by a comma.
|
static StringBuilder |
append(StringBuilder buf,
byte[] o)
Converts the specified byte array to 8-bit hexadecimal characters and appends them to
the specified StringBuilder with commas between each value.
|
static StringBuilder |
append(StringBuilder buf,
byte[] o,
boolean comma)
Converts the specified byte array to 8-bit hexadecimal characters and appends them to
the specified StringBuilder, optionally with commas between each value.
|
static StringBuilder |
appendASN1OctetString(StringBuilder buf,
byte[] bs)
Appends an octet string to a StringBuilder using standard ASN.1 mark-up.
|
static boolean |
appendDecimal(StringBuffer buf,
String name,
byte[] o,
boolean comma)
Appends name=[decimalBytes] to a StringBuffer, optionally preceded by a comma.
|
static boolean |
appendHex(StringBuffer buf,
String name,
byte[] o,
boolean comma)
Appends name=[hexBytes] to a StringBuffer, optionally preceded by a comma.
|
static boolean |
appendHex(StringBuilder buf,
String name,
byte[] o,
boolean comma)
Appends name=[hexBytes] to a StringBuilder, optionally preceded by a comma.
|
static StringBuilder |
appendPrintableASCIIString(StringBuilder buf,
byte[] bytes)
Appends a string containing the printable ASCII character values of the specified
byte array.
|
static void |
appendSpaces(StringBuilder buf,
int length)
Appends the given number of space characters to the given StringBuilder.
|
static int |
fromHexDigit(char ch)
Converts a hexadecimal character to its decimal equivalent.
|
static byte[] |
fromHexString(String s)
Converts a string as returned by
toHexString(byte[], boolean) back to a
byte array. |
static char |
getHexDigit(int v)
Converts a byte to a char containing its hexadecimal value.
|
static String |
spaces(int length)
Returns a String containing the given number of space characters.
|
static String |
toHexString(byte[] o)
Converts a byte array to a String containing the hexadecimal values of the bytes
with commas between each value.
|
static String |
toHexString(byte[] o,
boolean comma)
Converts a byte array to a String containing the hexadecimal values of the bytes,
optionally with commas between each value.
|
static String |
toPrintableASCIIString(byte[] bytes)
Converts a byte array to a String containing the printable ASCII character values
of the bytes.
|
public static boolean append(StringBuffer buf, String name, Object o, boolean comma)
buf
- StringBuffername
- Stringo
- object valuecomma
- whether to precede with a commapublic static boolean append(StringBuffer buf, String name, Object[] o, boolean comma)
buf
- StringBuffername
- Stringo
- object valuescomma
- whether to precede with a commapublic static boolean append(StringBuffer buf, String name, int value, boolean comma)
buf
- StringBuffername
- Stringvalue
- integer valuecomma
- whether to precede with a commapublic static boolean append(StringBuffer buf, String description, boolean flag, boolean comma)
buf
- StringBufferdescription
- Stringflag
- whether to append descriptioncomma
- whether to precede with a commapublic static boolean appendDecimal(StringBuffer buf, String name, byte[] o, boolean comma)
buf
- StringBuffername
- Stringo
- byte arraycomma
- whether to precede with a commapublic static boolean appendHex(StringBuffer buf, String name, byte[] o, boolean comma)
buf
- StringBuffername
- Stringo
- byte arraycomma
- whether to precede with a commapublic static boolean appendHex(StringBuilder buf, String name, byte[] o, boolean comma)
buf
- StringBuildername
- Stringo
- byte arraycomma
- whether to precede with a commapublic static StringBuffer append(StringBuffer buf, byte[] o)
buf
- StringBuffero
- byte arraypublic static StringBuilder append(StringBuilder buf, byte[] o)
append(buf, o, true)
.buf
- StringBuildero
- byte arraypublic static StringBuilder append(StringBuilder buf, byte[] o, boolean comma)
buf
- StringBuildero
- byte arraycomma
- flag indicating whether or not commas should be inserted between each
appended byte value.public static String toHexString(byte[] o)
toHexString(byte[], boolean)
toHexString(o, true)}.o
- byte arraypublic static String toHexString(byte[] o, boolean comma)
o
- byte arraycomma
- flag indicating whether or not commas should be inserted between each
appended byte value.public static StringBuilder appendPrintableASCIIString(StringBuilder buf, byte[] bytes)
buf
- a string builder to append to.bytes
- byte array.buf
.public static String toPrintableASCIIString(byte[] bytes)
bytes
- byte array.public static byte[] fromHexString(String s)
toHexString(byte[], boolean)
back to a
byte array. Commas, if present, are silently ignored and skipped over.s
- a stringpublic static char getHexDigit(int v)
v
- bytepublic static int fromHexDigit(char ch)
ch
- hex characterpublic static StringBuilder appendASN1OctetString(StringBuilder buf, byte[] bs)
buf
- StringBuilder to append tobs
- byte array representing octet stringpublic static final void appendSpaces(StringBuilder buf, int length)
NullPointerException
- if buf is nullIllegalArgumentException
- if length is less than zeropublic static final String spaces(int length)
IllegalArgumentException
- if length is less than zero