|
mhuss utils 1.1.5ws | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mhuss.Util.Str
public class Str
This class holds a potporri of static String functions not included in java.lang.String.
Constructor Summary | |
---|---|
Str()
|
Method Summary | |
---|---|
static boolean |
boolCheck(java.lang.String tf)
Check for a string which represents boolean true. |
static java.lang.String |
deSpace(java.lang.String s)
Remove spaces, commas, dots and single quotes from a String. |
static java.lang.String |
escape(java.lang.String in)
Make a String URL-friendly by escaping all reserved chars. |
static int |
extractInt(java.lang.String s)
Extract the first digit substring from the passed in String and convert to an int. |
static java.lang.String |
fmt(int i)
Format a String representation of an integer using a default width of two (2). |
static java.lang.String |
fmt(int i,
char suffix)
Format a String representation of an integer using a default width of two (2), and add the specified suffix. |
static java.lang.String |
fmt(int i,
int w)
Format a String representation of an integer at the specified width. |
static java.lang.String |
fmt(int i,
int w,
char suffix)
Format a String representation of an integer at the specified width, and add the specified suffix. |
static java.lang.String |
hex(char c)
Convert a char to a "%hh " string. |
static java.lang.String |
unescape(java.lang.String in)
Make a URL-friendly "escaped" String human-friendly. |
static char |
unhex(java.lang.String h)
Convert a " %hh " String to a char . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Str()
Method Detail |
---|
public static int extractInt(java.lang.String s)
s
- The String to search
public static java.lang.String deSpace(java.lang.String s)
This is usually called to help make text into a reasonably safe filename.
s
- The String to filter
public static java.lang.String hex(char c)
char
to a "%hh
" string.
c
- char to convert
%hh
representation of char.public static char unhex(java.lang.String h)
%hh
" String
to a char
.
h
- String %hh
representation of char.
%hh
parameterpublic static java.lang.String escape(java.lang.String in)
A handy function lifted from ECMAScript. The characters which are "escaped" (i.e., converted to %hh form) include all those which are not alphanumeric AND not in the set @*-_./ Probably the most commonly seen are "%20", which represents the space (" ") character, and "%27", which represents the single quote ("'") character.
Example
Before: Foo's Funny Filename.html
After: Foo%27s%20Funny%20Filename.html
in
- The String to escape
public static java.lang.String unescape(java.lang.String in)
A handy function lifted from ECMAScript. The characters are are "unescaped" by converting all triglyphs of the form "%hh" to single characters. "+" signs are also converted to spaces.
Probably the most commonly seen are "%20", which represents the space (" ") character, and "%27", which represents the single quote ("'") character.
Example
Before: Foo%27s%20Funny%20Filename.html
After: Foo's Funny Filename.html
in
- The String to unescape
public static boolean boolCheck(java.lang.String tf)
This function assumes a String which starts with 't', 'T', or '1' means true.
tf
- The String to test
public static java.lang.String fmt(int i, int w)
Note that this function will return an incorrect representation
if the integer is wider than the specified width. For example:
fmt( 1, 3 ) will return "001"
fmt( 12, 3 ) will return "012"
fmt( 1234, 3 ) will return "234"
i
- The integer to formatw
- The format width
public static java.lang.String fmt(int i, int w, char suffix)
Note that this will return an incorrect representation if the
integer is wider than the specified width. For example:
fmt( 1, 3, ':' ) will return "001:"
fmt( 12, 3, ':' ) will return "012:"
fmt( 1234, 3, ':' ) will return "234:"
i
- The integer to formatw
- The format widthsuffix
- The character to append
public static java.lang.String fmt(int i)
Note that this will return an incorrect representation if the
integer is wider than two digits. For example:
fmt( 1 ) will return "01"
fmt( 12 ) will return "12"
fmt( 1234 ) will return "34"
i
- The integer to format
public static java.lang.String fmt(int i, char suffix)
Note that this will return an incorrect representation if the
integer is wider than the specified width. For example:
fmt( 1, ':' ) will return "01:"
fmt( 12, ':' ) will return "12:"
fmt( 1234, ':' ) will return "34:"
i
- The integer to formatsuffix
- The character to append
|
mhuss utils 1.1.5ws | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |