|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.davesag.generica.util.StringUtils
StringUtils is a collection of handy static utility methods
that help us do repetative things with Strings.
| Field Summary | |
static String |
ISO_8601_DATE_FORMAT
ISO 8601 style date format string. |
static String |
RFC_822_DATE_FORMAT
RFC 822 style date format string as per http://www.w3.org/Protocols/rfc822/. |
static String |
UTC_DATE_FORMAT
UTC style date format string. |
static String |
UTF8
UTF-8 Encoding format string. |
| Constructor Summary | |
StringUtils()
|
|
| Method Summary | |
static List |
actorControllers(Map params)
Most generica actions can accept multiple actor controllers. |
static String |
className(Object o)
Returns the short class name for the given object. |
static String |
escapeMetaAndLink(String input)
Return an escaped string where <meta, <link tags are escaped. |
static String |
escapeString(String input)
Return an escaped string where &, <, and > are converted to their HTML equivalents. |
static List |
filterParamMap(String filter,
Map params)
Filters a parameter map for values whose key starts with the supplied filter. |
static String |
fixSorts(String instancename,
String sort)
tidies up an incoming sort string for use with various hibernate queries. |
static String |
formatError(Throwable error)
format a throwable into a nice string for reporting to the user. |
static String |
getDateKey(Date date)
Return a string of "YYYYMMDD" |
static String |
getFileExtension(String filename)
Return the file extension for a given filename or null if
no file extension is present |
static String |
getFilename(String filename)
Return the filename without extension for a given filename |
static String |
getFirstLine(String input,
int length)
Extracts the first line in a given string, otherwise returns the first n bytes |
static String |
getFormattedDate(Date date,
String format)
Return a formatted date string based on the supplied format and date. |
static String |
getISO8601Date(Date date)
Return a date in ISO 8601 style as per http://www.w3.org/TR/NOTE-datetime |
static String |
getRFC822Date(Date date)
Return a date in RFC 822 style as per http://www.w3.org/Protocols/rfc822/ |
static String |
getUTCDate(Date date)
Return a date in UTC style as per http://www.ghcc.msfc.nasa.gov/utc.html |
static String |
hostIp(String host)
get the IP number for the host name provided |
static String |
nullToBlank(String input)
Check to see if the given input string is null and if so,
return a blank string instead. |
static Map |
paramToMap(String param)
The parameter supplied in an ActionMapping should either
just be a Controller class name in the case of simple
Actions, or a ';' delimited list of name=value pairs. |
static Map |
parseActorParams(Map params)
Parse a Map of Action parameters and extract any actor-param
s. |
static String[] |
parseCommaList(String list)
Parse a comma-separated list of values, consuming internal trailing white space. |
static String[] |
parseDelimitedList(String list,
String delimiter)
Parse a delimited list of values, consuming trailing white space. |
static Map |
parseListParams(Map params)
Parse a Map of Action parameters and extract any list-param
s. |
static Map |
parsePresentationParams(Map params)
Parse a Map of Action parameters and extract any
presentation-param s. |
static List |
presentationControllers(Map params)
Most generica actions can accept multiple presentation controllers. |
static String |
replace(String str,
String pattern,
String replace)
Replace any occurances of a string pattern within a string with a different string, or Regex made easy. |
static String |
stripNonNumerics(String input)
strip out anything that is not a digit |
static String |
urlDecode(String input)
Return a URL decoded string |
static String |
urlEncode(String input)
Return an input string URL encoded |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String UTF8
public static final String RFC_822_DATE_FORMAT
public static final String ISO_8601_DATE_FORMAT
public static final String UTC_DATE_FORMAT
| Constructor Detail |
public StringUtils()
| Method Detail |
public static String getRFC822Date(Date date)
date - The Date
public static String getFormattedDate(Date date,
String format)
date - The Date.format - The Date Format String.
public static String getISO8601Date(Date date)
date - The Date
public static String getUTCDate(Date date)
date - Date
public static String[] parseCommaList(String list)
list - A list of comma-separated items.
public static String[] parseDelimitedList(String list,
String delimiter)
list - The delimited listdelimiter - The delimiter
public static Map paramToMap(String param)
ActionMapping should either
just be a Controller class name in the case of simple
Actions, or a ';' delimited list of name=value pairs. The params may be
separated by any amount of white space
If the param string is broken or incomplete in any way this method will load as many params as it can make sense of and then stop. It will write to the log file for any errors.
param - The parameter string.
Map of parameters.public static List presentationControllers(Map params)
you must name the controllers presentation-controller 0
... presentation-controller n
params - The map of params supplied to the action.
public static List actorControllers(Map params)
you must name the controllers actor-controller 0 ...
actor-controller n
params - The map of params supplied to the action.
public static List filterParamMap(String filter,
Map params)
filter - The key name you are looking for.params - The map of params supplied to the action.
public static Map parsePresentationParams(Map params)
presentation-param s. presentation-param s can be of
the form
presentation-param = someparam;
or
presentation-param0 = data:somedata;
presentation-param1 = fish:somefish;
...
presentation-paramn = whatever:somewhatever;
White space is ignored and the params do not need to be sequential.
params - The Map of Action configuration parameters.
Map of parameters for the Presenter s to use.
Never null.public static Map parseActorParams(Map params)
actor-param
s. actor-param s can be of the form
actor-param = someparam;
or
actor-param0 = data:somedata;
actor-param1 = fish:somefish;
...
actor-paramn = whatever:somewhatever;
White space is ignored and the params do not need to be sequential.
params - The Map of Action configuration parameters.
Map of parameters for the TargetActor s to
use. Never null.public static Map parseListParams(Map params)
list-param
s. list-param s can be of the form
list-param = someparam;
or
list-param0 = data:somedata;
list-param1 = fish:somefish;
...
list-paramn = whatever:somewhatever;
White space is ignored and the params do not need to be sequential.
params - The Map of Action configuration parameters.
Map of parameters for the Lister s to use. Never
null.
public static String fixSorts(String instancename,
String sort)
instancename - the name of the instance used in the hibernate
querysort - the sort string
public static String className(Object o)
o - The object whose class we want the name of.
public static String escapeString(String input)
input - The unescaped string.
public static String escapeMetaAndLink(String input)
input - The unescaped string.
public static String replace(String str,
String pattern,
String replace)
str - The source string. This is the string that will be
searched and have the replacementspattern - The pattern to look for in strreplace - The string to insert in the place of pattern
public static String getFileExtension(String filename)
null if
no file extension is present
filename - Filename
null if no file
extension is presentpublic static String getFilename(String filename)
filename - Filename
public static String getDateKey(Date date)
date - Date from which to extract "key"
public static String getFirstLine(String input,
int length)
input - String from which to extract the first linelength - Number of bytes to return if line seperator isnot found
public static final String urlEncode(String input)
input - Input string
null if either the input was
null. Returns the unencoded input string if there is a encoding
exception.public static final String urlDecode(String input)
input - Input string
null if either the input was
null or there is a decoding exceptionpublic static String nullToBlank(String input)
null and if so,
return a blank string instead.
input - Input string
null, otherwise
just return the input stringpublic static String stripNonNumerics(String input)
input - The text to strip.
public static String hostIp(String host)
host - The hostname.
public static String formatError(Throwable error)
error - The throwable error or exception.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||