|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.afcs.warts.util.StringUtils
The StringUtils class provides various utility methods for string processing.
LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.
| Method Summary | |
static java.lang.String |
encodeAsHex(byte[] bytes)
This method takes in an array of bytes and returns a string containing the hexadecimal representation of those bytes. |
static java.lang.String |
leftPad(java.lang.String text,
int size)
Returns the specified text, padded on the left with whitespace (0#x20) characters to make it the specified length. |
static java.lang.String |
leftPad(java.lang.String text,
int size,
char padChar)
Returns the specified text, padded on the left with the specified padding character to make it the specified length. |
static java.lang.String |
rightPad(java.lang.String text,
int size)
Returns the specified text, padded on the right with whitespace (0#x20) characters to make it the specified length. |
static java.lang.String |
rightPad(java.lang.String text,
int size,
char padChar)
Returns the specified text, padded on the right with the specified padding character to make it the specified length. |
static java.lang.String |
truncateToMaxLength(java.lang.String inputString,
int maxLength)
If the string received is longer than the maximum length specified, then it is truncated, and a '...' replaces the last three characters to indicate that truncation occurred. |
static java.lang.String |
truncateUtf8String(java.lang.String text,
int maxLengthInBytes)
Returns the specified string truncated to the specified maximum length in bytes (when encoded in UTF-8 format), with an ellipses (...) if need be. |
static java.lang.String |
wrapAt(java.lang.String input,
int wrapAt,
int indent)
This method returns a formatted version of the input string with newlines (\n) inserted every wrapAt characters. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static java.lang.String encodeAsHex(byte[] bytes)
bytes - The bytes to encode.
public static java.lang.String leftPad(java.lang.String text,
int size)
text - The text to pad. If this is null, then size whitespace
characters will be returned. If this is longer than
size, then it is returned unmodified.size - The length of the returned string (if the length of
text is less than this).
public static java.lang.String leftPad(java.lang.String text,
int size,
char padChar)
text - The text to pad. If this is null, then size whitespace
characters will be returned. If this is longer than
size, then it is returned unmodified.size - The length of the returned string (if the length of
text is less than this).padChar - The character to pad the text with.
public static java.lang.String rightPad(java.lang.String text,
int size)
text - The text to pad. If this is null, then size whitespace
characters will be returned. If this is longer than
size, then it is returned unmodified.size - The length of the returned string (if the length of
text is less than this).
public static java.lang.String rightPad(java.lang.String text,
int size,
char padChar)
text - The text to pad. If this is null, then size whitespace
characters will be returned. If this is longer than
size, then it is returned unmodified.size - The length of the returned string (if the length of
text is less than this).padChar - The character to pad the text with.
public static java.lang.String truncateToMaxLength(java.lang.String inputString,
int maxLength)
inputString - The string to truncate, if necessary.maxLength - The maximum length of the string, after truncation.
public static java.lang.String truncateUtf8String(java.lang.String text,
int maxLengthInBytes)
text - The text to truncate.maxLengthInBytes - The maximum length in bytes.
java.lang.NullPointerException - If text is null.
java.lang.IllegalArgumentException - If maxLengthInBytes is less than 3.
public static java.lang.String wrapAt(java.lang.String input,
int wrapAt,
int indent)
input - The string to format.wrapAt - The number of characters in a line.indent - The number of spaces to insert at the start of all
lines other than the first.
java.lang.IllegalArgumentException - If wrapAt is less than 5, indent is less
than 0, indent is greater than or equal to wrapAt, or
indent is greater than 30. The first and last constraints
are arbitrary and could be trivially worked around.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||