public class Util extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Util.AdjustCollectionResult<T>
Show changes for adjustCollection
|
static class |
Util.PropertiesPropertyFetcher |
static interface |
Util.PropertyFetcher |
| Modifier and Type | Method and Description |
|---|---|
static <T> Util.AdjustCollectionResult<T> |
adjustCollection(Collection<T> newCol,
Collection<T> toAdjust)
Used to adjust a collection toAdjust so that it looks like the collection
newCol.
|
static String[] |
appendTextToArray(String[] sarray,
String val,
int maxEntries)
Add a string to a string array of a given maximum length.
|
static String |
buildPath(boolean endWithSep,
String... val)
Build a path out of the given elements.
|
static String |
checkNull(String val)
We get a lot of zero length (or all white space) strings in the web world.
|
static int |
cmpBoolval(boolean thisone,
boolean thatone)
Compare two boolean objects
|
static int |
cmpIntval(int thisone,
int thatone)
Compare two int objects
|
static int |
cmpObjval(Collection<? extends Comparable> thisone,
Collection<? extends Comparable> thatone)
Compare two possibly null objects
|
static int |
cmpObjval(Comparable thisone,
Comparable thatone)
Compare two possibly null objects
|
static int |
compare(char[] thisone,
char[] thatone)
Compare two char arrays
|
static int |
compareStrings(String s1,
String s2)
Compare two strings.
|
static String[] |
decodeArray(String val)
Return a StringArray resulting from decoding the given String which
should have been encoded by encodeArray
|
static String |
encodeArray(String[] val)
Return a String representing the given String array, achieved by
URLEncoding the individual String elements then concatenating with
intervening blanks.
|
static boolean |
equalsString(String thisStr,
String thatStr)
Return true if Strings are equal including possible null
|
static String |
fmtMsg(String fmt,
int arg)
Format a message consisting of a format string plus one integer parameter
|
static String |
fmtMsg(String fmt,
String arg)
Format a message consisting of a format string
|
static String |
fmtMsg(String fmt,
String arg1,
String arg2)
Format a message consisting of a format string plus two string parameters
|
static List<String> |
getList(String val,
boolean emptyOk)
Turn a comma separated list into a List.
|
static Object |
getObject(String className,
Class cl)
Given a class name return an object of that class.
|
static Properties |
getPropertiesFromResource(String name)
Load a named resource as a Properties object
|
static String |
icalUTCTimestamp()
Get an ical timestamp of the form "yyyyMMddTHHmmssZ"
|
static boolean |
isEmpty(Collection val)
Return true for null or empty
|
static Locale |
makeLocale(String val)
make a locale from the standard underscore separated parts - no idea why
this isn't in Locale
|
static String |
makeRandomString(int length,
int maxVal)
Creates a string of given length where each character comes from a
set of values 0-9 followed by A-Z.
|
static String |
pathElement(int index,
String path)
get the nth element from the path - first is 0.
|
static boolean |
present(String val)
We get a lot of zero length strings in the web world.
|
static String |
propertyReplace(String val,
Util.PropertyFetcher props) |
static String[] |
splitName(String href)
if an href with terminating "/" the name part is that between the
ending "/" and the one before.
|
static URI |
validURI(String val)
Test for a valid URI and return the URI object.
|
public static String icalUTCTimestamp()
public static <T> Util.AdjustCollectionResult<T> adjustCollection(Collection<T> newCol, Collection<T> toAdjust)
newCol - make it look like thistoAdjust - if non-null will be adjustedpublic static String buildPath(boolean endWithSep, String... val)
The path is constrained to either end or not end with the path separator. The path will be adjusted according to the constraint
endWithSep - val - - list of elements and path separators.public static String[] splitName(String href)
Otherwise it's the part after the last "/"
href - to splitpublic static String pathElement(int index, String path)
index - of element we wantpath - from which we extract the elementpublic static Locale makeLocale(String val) throws Throwable
val - teh locale String e.g. en_USThrowablepublic static Properties getPropertiesFromResource(String name) throws Throwable
name - String resource nameThrowablepublic static Object getObject(String className, Class cl) throws Exception
className - String class namecl - Class expectedExceptionpublic static String propertyReplace(String val, Util.PropertyFetcher props)
public static String fmtMsg(String fmt, String arg)
fmt - arg - public static String fmtMsg(String fmt, String arg1, String arg2)
fmt - arg1 - arg2 - public static String fmtMsg(String fmt, int arg)
fmt - arg - public static String makeRandomString(int length, int maxVal)
length - returned string will be this long. Less than 1k + 1maxVal - maximum ordinal value of characters. If < than 0,
return null. If > 35, 35 is used instead.public static String[] appendTextToArray(String[] sarray, String val, int maxEntries)
sarray - String[] to be updatedval - new entrymaxEntries - Number of entries we keep.public static String encodeArray(String[] val)
val - String[] value to encodepublic static String[] decodeArray(String val)
val - String value encoded by encodeArraypublic static boolean equalsString(String thisStr, String thatStr)
thisStr - thatStr - public static int compareStrings(String s1, String s2)
s1 - first string.s2 - second string.public static String checkNull(String val)
val - String request parameter valuepublic static boolean present(String val)
val - String request parameter valuepublic static List<String> getList(String val, boolean emptyOk) throws Throwable
val - String comma separated listemptyOk - Empty elements are OKThrowable - for invalid listpublic static int cmpObjval(Comparable thisone, Comparable thatone)
thisone - thatone - public static int cmpObjval(Collection<? extends Comparable> thisone, Collection<? extends Comparable> thatone)
thisone - thatone - public static int cmpBoolval(boolean thisone,
boolean thatone)
thisone - thatone - public static int cmpIntval(int thisone,
int thatone)
thisone - thatone - public static int compare(char[] thisone,
char[] thatone)
thisone - thatone - public static boolean isEmpty(Collection val)
val - Copyright © 2018 Bedework. All rights reserved.