|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.melati.poem.util.StringUtils
public final class StringUtils
An assortment of useful operations on String
s.
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
static void |
appendEscaped(StringBuffer b,
String s,
char character)
|
static void |
appendEscaped(StringBuffer b,
String s,
char character,
char escapeChar)
Append a String to a StringBuffer, and escaping any occurances of the char in the String. |
static void |
appendQuoted(StringBuffer b,
String s,
char q)
Append a String to a StringBuffer, first quoting it with a quote character and escaping any occurrences of the quote char in the String. |
static String |
capitalised(String name)
Capitalise the first character of the input string. |
static String |
concatenated(String sep,
String[] xs)
Concatenate an array of Strings with a separator. |
static byte |
hexDecoding(char c)
Decode a hex char to a byte. |
static byte[] |
hexDecoding(String digits)
Decode a hex String into a byte Array. |
static String |
hexEncoding(byte[] bytes)
Hex encode an Array of bytes. |
static boolean |
isQuoted(String in)
Determine whether a String is quoted, with either quoting character. |
static String |
nulled(String s)
Turn an empty String into a null. |
static String |
quoted(String i,
char q)
Surround a string in quotes. |
static String |
randomString(int length)
Generate a random String. |
static String[] |
split(String s,
char c)
As Perl, create an Array from a String by using a character as the Array delimiter. |
static String |
tr(String s,
char from,
char to)
Deprecated. now use string.replace(old,new) |
static String |
tr(String s,
String from,
String to)
As Perl tr ; swap any occurrences of any characters in the
from string in the input string with the
corresponding character from the to string. |
static String |
uncapitalised(String name)
Uncaptialise the first character of the input string. |
static String |
unNulled(String in)
Turn a null into an empty String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringUtils()
Method Detail |
---|
public static String[] split(String s, char c)
s
- the String to splitc
- the Array delimiter
public static void appendEscaped(StringBuffer b, String s, char character)
b
- the buffer to append tos
- the String to appendcharacter
- the character to escapepublic static void appendEscaped(StringBuffer b, String s, char character, char escapeChar)
b
- the buffer to append tos
- the String to appendcharacter
- the character to escapeescapeChar
- the character to escape withpublic static void appendQuoted(StringBuffer b, String s, char q)
b
- the buffer to append tos
- the String to appendq
- the quote characterpublic static String quoted(String i, char q)
i
- the string to quoteq
- The quote character to use
public static String capitalised(String name)
name
- String to capitalise
public static String uncapitalised(String name)
name
- String to uncapitalise
public static String tr(String s, String from, String to)
tr
; swap any occurrences of any characters in the
from
string in the input string with the
corresponding character from the to
string.
tr("melati", "ait", "osn").equals("melons")
s
- String to act uponfrom
- String containing characters to swap fromto
- String containing characters to swap to
public static String tr(String s, char from, char to)
tr
; swap any occurances of the
from
character in the input string with the
corresponding the to
character.
tr("melati", 'i', 'o').equals("melato")
s
- String to act uponfrom
- character to swap fromto
- character to swap to
public static String concatenated(String sep, String[] xs)
sep
- The separator String to use, may be null.xs
- An array of Strings to concatenate.
public static String randomString(int length)
length
- the required length of the String returned
public static String nulled(String s)
s
- input String, possibly of zero length or null
public static String unNulled(String in)
in
- input String, possibly null
public static String hexEncoding(byte[] bytes)
bytes
- the byte Array
public static byte hexDecoding(char c)
c
- the char
public static byte[] hexDecoding(String digits)
digits
- the hex String
public static boolean isQuoted(String in)
in
- String to examine
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |