|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jomic.tools.StringTools
public final class StringTools
Utility class to simplify dealing with Strings.
Method Summary | |
---|---|
java.lang.String |
arrayToString(double[] data)
|
java.lang.String |
arrayToString(java.io.File[] data)
|
java.lang.String |
arrayToString(float[] data)
|
java.lang.String |
arrayToString(int[] data)
|
java.lang.String |
arrayToString(java.lang.String[] data)
|
java.lang.String |
asHtmlEscaped(java.lang.String some)
Escaped as HTML attribute value. |
java.lang.String |
camelized(java.lang.String some)
Return some converted to "camel case" using "-" or "_" as word seperators. |
java.lang.String |
colorString(java.awt.Color color)
Hex-color representation of color . |
java.lang.String |
colorString(long rgba)
Hex-color representation of RGB color value. |
boolean |
equalsAnyOf(java.lang.String[] haystack,
java.lang.String needle)
|
boolean |
equalsAnyOf(java.lang.String[] haystack,
java.lang.String needle,
boolean sort)
|
java.lang.String |
extractNumberBackwards(java.lang.String possiblyPagedName,
int endIndex)
Extract number by moving backwards starting at endIndex . |
int |
getDigitCount(int value)
Get number of digits required to represent value (including a possible '-' for
negative numbers). |
java.text.DecimalFormat |
getLeadingZeroFormat(int maxValue)
Get DecimalFormat with leading zeroes that can handle up to maxValue . |
char[] |
getMnemonics(java.lang.String[] labels,
char[] suggestions)
Get unique mnemonics for all labels . |
java.lang.String |
getPercentText(double value)
Get value formatted as percent. |
java.lang.String |
hexString(long value,
int digits)
Hex representation of value , prefixed with "0x". |
java.lang.String |
hexString(long value,
int digits,
java.lang.String prefix)
Hex representation of value . |
static StringTools |
instance()
Get accessor to unique instance. |
boolean |
isNullOrEmpty(java.lang.String some)
Is some null or only consisting of white space? |
boolean |
isSorted(java.lang.String[] some)
Return true if some is sorted. |
boolean |
isWhiteSpace(java.lang.String some)
Are all characters in some white space? If some is empty, return
false . |
double |
log10(double some)
Get 10-log. |
java.lang.String |
sourced(char some)
Source code version of character some that can be pasted into a Java source. |
java.lang.String |
sourced(java.io.File some)
Same as sourced(String) , but uses absolute file path. |
java.lang.String |
sourced(java.lang.String some)
Source code version of some that can be pasted into a Java source. |
int[] |
stringToIntArray(java.lang.String data)
|
java.lang.String |
titled(java.lang.String some)
Some as some , but with the first character converted to title case. |
java.lang.String |
trimPrefix(java.lang.String text,
java.lang.String prefix)
If text starts with prefix , trim it from the left, otherwise just
return text . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public int getDigitCount(int value)
value
(including a possible '-' for
negative numbers).
public java.text.DecimalFormat getLeadingZeroFormat(int maxValue)
maxValue
.
public char[] getMnemonics(java.lang.String[] labels, char[] suggestions)
labels
.
labels
- the long texts that need mnemonicssuggestions
- an array with the same length as labels
that can already
contain mnemonics for certain labels. For the rest, use '\0'
as suggestion
so the will be computed automatically. A suggestion of null
means that all
mnemonics should be computed.public java.lang.String getPercentText(double value)
value
formatted as percent.
public boolean isNullOrEmpty(java.lang.String some)
some
null or only consisting of white space?
public boolean isSorted(java.lang.String[] some)
true
if some
is sorted.
String.compareTo(java.lang.String)
public boolean isWhiteSpace(java.lang.String some)
some
white space? If some
is empty, return
false
.
public static StringTools instance()
public java.lang.String arrayToString(double[] data)
public java.lang.String arrayToString(java.io.File[] data)
public java.lang.String arrayToString(float[] data)
public java.lang.String arrayToString(int[] data)
public java.lang.String arrayToString(java.lang.String[] data)
public java.lang.String asHtmlEscaped(java.lang.String some)
public java.lang.String camelized(java.lang.String some)
some
converted to "camel case" using "-" or "_" as word seperators. For
example, "some-stuff-to-do" yields "someStuffToDo".
public java.lang.String colorString(long rgba)
int
of 0x123456, and yield
"#123456". (This is the same principle used to represent colors in HTML.)
Color.getRGB()
public java.lang.String colorString(java.awt.Color color)
color
.
Color.getRGB()
public boolean equalsAnyOf(java.lang.String[] haystack, java.lang.String needle)
public boolean equalsAnyOf(java.lang.String[] haystack, java.lang.String needle, boolean sort)
public java.lang.String extractNumberBackwards(java.lang.String possiblyPagedName, int endIndex)
endIndex
. If the character at
endIndex
is no digit, return an empty string ("").
public java.lang.String hexString(long value, int digits, java.lang.String prefix)
value
.
digits
- the number of digits the result should have at least; if necessary, leading
"0"s are prependedprefix
- the text to be used as the fist few characters of the result; "0x" if null.public java.lang.String hexString(long value, int digits)
value
, prefixed with "0x".
digits
- the number of digits the result should have at least; if necessary, leading
"0"s are prependedpublic double log10(double some)
public java.lang.String sourced(java.lang.String some)
some
that can be pasted into a Java source. The result
is embedded in two quotes, escape characters are rendered where possible. Invisible
characters are rendered as unicode escape. The value null
results in the the
text "null" (without quotes).
public java.lang.String sourced(char some)
some
that can be pasted into a Java source.
The result is embedded in two quotes, escape characters are rendered where possible.
Invisible characters are rendered as unicode escape.
public java.lang.String sourced(java.io.File some)
sourced(String)
, but uses absolute file path.
sourced(String)
public int[] stringToIntArray(java.lang.String data) throws java.io.IOException, java.text.ParseException
java.io.IOException
java.text.ParseException
public java.lang.String titled(java.lang.String some)
some
, but with the first character converted to title case.
Character.toTitleCase(char)
public java.lang.String trimPrefix(java.lang.String text, java.lang.String prefix)
text
starts with prefix
, trim it from the left, otherwise just
return text
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |