|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sandev.basics.util.StringUtil
Utilities for String value manipulation. These aren't strictly necessary but they make coding easier.
Number conversion:
When converting from a string to a number, you really just want two methods: one to tell you if it can be converted (so you can do a nice error if it's not going to work), and another to do the conversion in an intelligent way. Writing the same code blocks repeatedly for this is annoying, so we have the methods factored here. That leaves all the ParseException, NumberFormatException, ClassCastException stuff from cluttering up the application code.
| Field Summary | |
protected static java.text.DateFormat |
dateFormat
Our DateFormat instance so we don't have to keep retrieving this on repeated calls. |
protected static java.text.NumberFormat |
numberFormat
Our NumberFormat instance so we don't have to keep retrieving this on repeated calls. |
| Constructor Summary | |
StringUtil()
|
|
| Method Summary | |
static java.lang.String[] |
atomize(java.lang.String text)
Split up the given text into individual words. |
static boolean |
convertsToDate(java.lang.String val)
Return true if the given value can be converted to a Date, false otherwise. |
static boolean |
convertsToDouble(java.lang.String val)
Return true if the given value can be converted to a long, false otherwise. |
static boolean |
convertsToInt(java.lang.String val)
Return true if the given value can be converted to an int, false otherwise. |
static boolean |
convertsToLong(java.lang.String val)
Return true if the given value can be converted to a long, false otherwise. |
static java.lang.String |
dateToString(java.util.Date date)
Return the String value of the given Date. |
static java.lang.String |
fixAMPMTimeValues(java.lang.String probtext)
Assuming AM or PM needs to be specified, fix the problem text. |
static java.lang.String |
fixUnparseableDateStr(java.lang.String probtext)
Look for known parsing breakages on dates and fix them, returning the corrected text. |
static java.text.DateFormat |
getDateFormat()
Initializing accessor for dateFormat. |
static java.util.Date |
getDateValue(java.lang.String val)
Convert the given String to a Date value. |
static double |
getDoubleValue(java.lang.String val)
Convert the given String to a double value. |
static int |
getIntValue(java.lang.String val)
Convert the given String to an int value. |
static long |
getLongValue(java.lang.String val)
Convert the given String to a long value. |
static java.text.NumberFormat |
getNumberFormat()
Initializing accessor for numberFormat. |
static java.util.Date |
safeGetDateValue(java.lang.String val)
Calls getDateValue but returns null rather than throwing if the value cannot be converted. |
static double |
safeGetDoubleValue(java.lang.String val)
Calls getDoubleValue but returns 0 rather than throwing if the value can't be converted. |
static int |
safeGetIntValue(java.lang.String val)
Calls getIntValue but returns 0 rather than throwing if the value can't be converted. |
static long |
safeGetLongValue(java.lang.String val)
Calls getLongValue but returns 0 rather than throwing if the value can't be converted. |
static double |
sandGetDoubleValue(java.lang.String val)
Wraps getDoubleValue and throws a SandException if anything goes wrong. |
static int |
sandGetIntValue(java.lang.String val)
Wraps getIntValue and throws a SandException if anything goes wrong. |
static long |
sandGetLongValue(java.lang.String val)
Wraps getLongValue and throws a SandException if anything goes wrong. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static java.text.NumberFormat numberFormat
protected static java.text.DateFormat dateFormat
| Constructor Detail |
public StringUtil()
| Method Detail |
public static java.text.NumberFormat getNumberFormat()
public static java.text.DateFormat getDateFormat()
public static boolean convertsToInt(java.lang.String val)
public static int getIntValue(java.lang.String val)
throws java.text.ParseException
java.text.ParseExceptionpublic static int safeGetIntValue(java.lang.String val)
public static int sandGetIntValue(java.lang.String val)
throws SandException
SandExceptionpublic static boolean convertsToLong(java.lang.String val)
public static long getLongValue(java.lang.String val)
throws java.text.ParseException
java.text.ParseExceptionpublic static long safeGetLongValue(java.lang.String val)
public static long sandGetLongValue(java.lang.String val)
throws SandException
SandExceptionpublic static boolean convertsToDouble(java.lang.String val)
public static double getDoubleValue(java.lang.String val)
throws java.text.ParseException
java.text.ParseExceptionpublic static double safeGetDoubleValue(java.lang.String val)
public static double sandGetDoubleValue(java.lang.String val)
throws SandException
SandExceptionpublic static java.lang.String dateToString(java.util.Date date)
public static boolean convertsToDate(java.lang.String val)
public static java.util.Date getDateValue(java.lang.String val)
throws java.text.ParseException
java.text.ParseExceptionpublic static java.util.Date safeGetDateValue(java.lang.String val)
public static java.lang.String fixUnparseableDateStr(java.lang.String probtext)
public static java.lang.String fixAMPMTimeValues(java.lang.String probtext)
public static java.lang.String[] atomize(java.lang.String text)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||