|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.util.StringUtils
public class StringUtils
General string utils
Field Summary | |
---|---|
static char |
COMMA
|
static String |
COMMA_STR
|
static char |
ESCAPE_CHAR
|
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
static String |
arrayToString(String[] strs)
Given an array of strings, return a comma-separated list of its elements. |
static String |
byteToHexString(byte[] bytes)
Given an array of bytes it will convert the bytes to a hex string representation of the bytes |
static String |
escapeString(String str)
Escape commas in the string using the default escape char |
static String |
escapeString(String str,
char escapeChar,
char charToEscape)
Escape charToEscape in the string
with the escape char escapeChar |
static String |
formatPercent(double done,
int digits)
Format a percentage for presentation to the user. |
static String |
formatTimeDiff(long finishTime,
long startTime)
Given a finish and start time in long milliseconds, returns a String in the format Xhrs, Ymins, Z sec, for the time difference between two times. |
static String |
getFormattedTimeWithDiff(DateFormat dateFormat,
long finishTime,
long startTime)
Formats time in ms and appends difference (finishTime - startTime) as returned by formatTimeDiff(). |
static String |
getHostname()
Return hostname without throwing exception. |
static Collection<String> |
getStringCollection(String str)
Returns a collection of strings. |
static String[] |
getStrings(String str)
Returns an arraylist of strings. |
static byte[] |
hexStringToByte(String hex)
Given a hexstring this will return the byte array corresponding to the string |
static String |
humanReadableInt(long number)
Given an integer, return a string that is in an approximate, but human readable format. |
static String |
simpleHostname(String fullHostname)
Given a full hostname, return the word upto the first dot. |
static String[] |
split(String str)
Split a string using the default separator |
static String[] |
split(String str,
char escapeChar,
char separator)
Split a string using the given separator |
static void |
startupShutdownMessage(Class clazz,
String[] args,
org.apache.commons.logging.Log LOG)
Print a log message for starting up and shutting down |
static String |
stringifyException(Throwable e)
Make a string representation of the exception. |
static Path[] |
stringToPath(String[] str)
|
static URI[] |
stringToURI(String[] str)
|
static String |
unEscapeString(String str)
Unescape commas in the string using the default escape char |
static String |
unEscapeString(String str,
char escapeChar,
char charToEscape)
Unescape charToEscape in the string
with the escape char escapeChar |
static String |
uriToString(URI[] uris)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char COMMA
public static final String COMMA_STR
public static final char ESCAPE_CHAR
Constructor Detail |
---|
public StringUtils()
Method Detail |
---|
public static String stringifyException(Throwable e)
e
- The exception to stringify
public static String simpleHostname(String fullHostname)
fullHostname
- the full hostname
public static String humanReadableInt(long number)
number
- the number to format
public static String formatPercent(double done, int digits)
done
- the percentage to format (0.0 to 1.0)digits
- the number of digits past the decimal point
public static String arrayToString(String[] strs)
strs
- Array of strings
public static String byteToHexString(byte[] bytes)
bytes
-
public static byte[] hexStringToByte(String hex)
hex
- the hex String array
public static String uriToString(URI[] uris)
uris
- public static URI[] stringToURI(String[] str)
str
- public static Path[] stringToPath(String[] str)
str
- public static String formatTimeDiff(long finishTime, long startTime)
finishTime
- finish timestartTime
- start timepublic static String getFormattedTimeWithDiff(DateFormat dateFormat, long finishTime, long startTime)
dateFormat
- date format to usefinishTime
- fnish timestartTime
- start time
public static String[] getStrings(String str)
str
- the comma seperated string values
public static Collection<String> getStringCollection(String str)
str
- comma seperated string values
ArrayList
of string valuespublic static String[] split(String str)
str
- a string that may have escaped separator
public static String[] split(String str, char escapeChar, char separator)
str
- a string that may have escaped separatorescapeChar
- a char that be used to escape the separatorseparator
- a separator char
public static String escapeString(String str)
str
- a string
public static String escapeString(String str, char escapeChar, char charToEscape)
charToEscape
in the string
with the escape char escapeChar
str
- stringescapeChar
- escape charcharToEscape
- the char to be escaped
public static String unEscapeString(String str)
str
- a string
public static String unEscapeString(String str, char escapeChar, char charToEscape)
charToEscape
in the string
with the escape char escapeChar
str
- stringescapeChar
- escape charcharToEscape
- the escaped char
public static String getHostname()
public static void startupShutdownMessage(Class clazz, String[] args, org.apache.commons.logging.Log LOG)
clazz
- the class of the serverargs
- argumentsLOG
- the target log object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |