|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cs132.util.StringUtil
public class StringUtil
Field Summary | |
---|---|
static String |
Hex
|
static String |
NL
The platform-specific end-of-line marker (Usually "\n" on
Unix and "\r\n" on Windows). |
static Charset |
UTF8
A convenience instance of the UTF-8 Charset object. |
Method Summary | |
---|---|
static String |
decode(Charset charset,
byte[] data)
|
static String |
decode(Charset charset,
byte[] data,
int offset,
int length)
|
static String |
decode(CharsetDecoder decoder,
byte[] data)
|
static String |
decode(CharsetDecoder decoder,
byte[] data,
int offset,
int length)
|
static byte[] |
getUTF8(String s)
Return the UTF-8-encoded equivalent of the given string. |
static void |
hex(StringBuilder buf,
char c)
Append the hex value of the given character. |
static void |
hex2(StringBuilder buf,
byte c)
Append the 2-digit hex value of the given character's low byte. |
static void |
hex4(StringBuilder buf,
char c)
Append the 4-digit hex value of the given character. |
static String |
join(Iterable<? extends CharSequence> items,
String sep)
Equivalent to: join(items, sep, "") |
static String |
join(Iterable<? extends CharSequence> items,
String sep,
String empty)
Concatenate the strings in 'items', separated by the string in 'sep'. |
static String |
jq(String s)
Return a Java string literal that is equivalent to the given string. |
static void |
jq(StringBuilder buf,
String s)
Equivalent to jq(String) , except it appends the
result to a StringBuilder instead of returning it as a string. |
static void |
jqc(StringBuilder buf,
String s)
Equivalent to jq(StringBuilder,String) , except it doesn't
include the leading and trailing quote characters. |
static String |
readableChar(char c)
Human-readable representation of a character. |
static void |
readableChar(StringBuilder buf,
char c)
Equivalent to readableChar(char) , except it appends the
result to a StringBuilder instead of returning it as a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NL
"\n"
on
Unix and "\r\n"
on Windows).
public static final Charset UTF8
Charset.forName("UTF-8")
.
public static final String Hex
Method Detail |
---|
public static byte[] getUTF8(String s)
public static String jq(String s)
Return a Java string literal that is equivalent to the given string.
abcd
→ "abcd"
ab"cd
→ "ab\"cd"
ab\cd
→ "ab\\cd"
public static void jq(StringBuilder buf, String s)
jq(String)
, except it appends the
result to a StringBuilder instead of returning it as a string.
public static void jqc(StringBuilder buf, String s)
jq(StringBuilder,String)
, except it doesn't
include the leading and trailing quote characters.
public static String readableChar(char c)
Human-readable representation of a character. Most "normal" characters are simply placed between quotes.
public static void readableChar(StringBuilder buf, char c)
readableChar(char)
, except it appends the
result to a StringBuilder instead of returning it as a string.
public static void hex2(StringBuilder buf, byte c)
public static void hex4(StringBuilder buf, char c)
public static void hex(StringBuilder buf, char c)
public static String join(Iterable<? extends CharSequence> items, String sep)
public static String join(Iterable<? extends CharSequence> items, String sep, String empty)
items
- The strings to concatenate.sep
- The string to use as a separator.empty
- The string to return if 'items' is an empty list.public static String decode(Charset charset, byte[] data) throws CharacterCodingException
CharacterCodingException
public static String decode(Charset charset, byte[] data, int offset, int length) throws CharacterCodingException
CharacterCodingException
public static String decode(CharsetDecoder decoder, byte[] data) throws CharacterCodingException
CharacterCodingException
public static String decode(CharsetDecoder decoder, byte[] data, int offset, int length) throws CharacterCodingException
CharacterCodingException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |