|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.marringtons.string.Convert
Convert to and from a String Object from various internal forms, including integers and boolean primatives.
| Nested Class Summary | |
static class |
Convert.Exception
Thrown by any conversion utility on error. |
| Method Summary | |
static String |
pad(int number,
int places)
Return a string converted from an integer and zero padded 1 == 001. |
static boolean |
toBoolean(String string)
Convert a string to boolean. |
static String |
toString(boolean flag)
Convert a Boolean to a readable string boolean check = askUser( "Shall I check?") |
static String |
toString(boolean flag,
String type)
Convert a Boolean to a readable string string = Convert.toString( flag, "yes"); string = Convert.toString( flag, "oui"); |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static boolean toBoolean(String string)
throws Convert.Exception
String question = askUser( "do it [y/n]?"); boolean answer = Convert.toBoolean( question);
string - string to test
Convert.Exception - throws if not in true or false listpublic static String toString(boolean flag)
boolean check = askUser( "Shall I check?"); System.out.print( "Check = "+Convert.toString( check));
flag - boolean to convert
public static String toString(boolean flag,
String type)
string = Convert.toString( flag, "yes"); string = Convert.toString( flag, "oui");
flag - boolean to converttype - string type using affirmative (yes/true/on/qui/da/si).
public static String pad(int number,
int places)
number - integer to convert to a stringplaces - fixed number of digits
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||