public class Util
extends java.lang.Object
implements java.io.Serializable
The methods in this class are accessible from within a template via the
$util
variable.
Modifier and Type | Field and Description |
---|---|
private static java.text.DecimalFormat[] |
cvCurrencyFormat
An array of formatters used to format and parse currency numbers.
|
private static java.text.DecimalFormat[] |
cvDecimalFormat
An array of formatters used to format and parse decimal numbers.
|
private static java.text.NumberFormat[] |
cvNumberFormat
An array of formatters used to format and parse whole numbers.
|
private static char[] |
hexDigit
Hexidecimal digits used to convert characters to hex output.
|
static int |
LEFT
Constant used for left padding.
|
static int |
RIGHT
Constant used for right padding.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addSiteRootPath(java.lang.String s)
Adds the site's root path to the beginning of the given string.
|
static java.lang.String |
addSiteRootPathURL(java.lang.String s)
Adds the site's root path to the beginning of the given string and
returns the result as a URL.
|
static java.lang.Object[] |
arrayListToObjectArray(java.util.ArrayList<?> al)
Converts a given array list to an object array.
|
static java.lang.String[] |
arrayListToStringArray(java.util.ArrayList<?> al)
Converts a given array list to a string array.
|
static java.util.ArrayList<java.math.BigDecimal> |
arrayMath(java.util.ArrayList<java.math.BigDecimal> a1,
java.lang.String operator,
java.util.ArrayList<java.math.BigDecimal> a2)
Performs a math operation on 2 operand arrays.
|
static java.lang.String |
booleanToYesNo(boolean value)
Returns a string of "Yes" or "No" corresponding to the true (yes)
or false (no) value of the given boolean parameter.
|
static java.lang.String |
escapeRegEx(java.lang.String s)
Returns an escaped string that is suitable for use as a regular expression
pattern.
|
static int |
findInArray(java.lang.String[] array,
java.lang.String value)
Finds the given value in the given array and returns the index of the
value within the array.
|
static java.lang.String |
formatCurrency(java.math.BigDecimal number)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatCurrency(java.math.BigDecimal number,
boolean fmtzero)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatCurrency(java.math.BigDecimal number,
boolean fmtzero,
boolean fmtgrps)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatCurrency(double number)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatCurrency(double number,
boolean fmtzero)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatCurrency(double number,
boolean fmtzero,
boolean fmtgrps)
Returns a formatted currency string based on the current system locale.
|
static java.lang.String |
formatDate(java.util.Date date,
int style)
Returns a formatted date string for the given date using the given format
style, default locale and default timezone.
|
static java.lang.String |
formatDate(java.util.Date date,
int style,
java.util.Locale locale)
Returns a formatted date string for the given date using the given format
style, locale and default timezone.
|
static java.lang.String |
formatDate(java.util.Date date,
int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a formatted date string for the given date using the given format
style, locale and timezone.
|
static java.lang.String |
formatDate(java.util.Date date,
int style,
java.util.TimeZone tz)
Returns a formatted date string for the given date using the given format
style, timezone and default locale.
|
static java.lang.String |
formatDateInput(java.util.Date date)
Returns a formatted date string for the given date using the properties
"Site.Format.DateInput" definition.
|
static java.lang.String |
formatDateTime(java.util.Date date,
int style)
Returns a formatted date and time string for the given date using the
given format style, default locale and default timezone.
|
static java.lang.String |
formatDateTime(java.util.Date date,
int style,
java.util.Locale locale)
Returns a formatted date and time string for the given date using the
given format style, locale and default timezone.
|
static java.lang.String |
formatDateTime(java.util.Date date,
int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a formatted date and time string for the given date using the
given format style, locale and timezone.
|
static java.lang.String |
formatDateTime(java.util.Date date,
int style,
java.util.TimeZone tz)
Returns a formatted date and time string for the given date using the
given format style, timezone and default locale.
|
static java.lang.String |
formatNumber(java.math.BigDecimal number)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(java.math.BigDecimal number,
boolean fmtzero)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(java.math.BigDecimal number,
boolean fmtzero,
boolean fmtgrps)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(double number)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(double number,
boolean fmtzero)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(double number,
boolean fmtzero,
boolean fmtgrps)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(long number)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(long number,
boolean fmtzero)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatNumber(long number,
boolean fmtzero,
boolean fmtgrps)
Returns a formatted number string based on the current system locale.
|
static java.lang.String |
formatString(java.lang.String text,
java.lang.String... values)
Returns a formatted string with the given set of substitution values
inserted into the given text.
|
static java.lang.String |
formatTime(java.util.Date date,
int style)
Returns a formatted time string for the given date using the given format
style and default locale and default timezone.
|
static java.lang.String |
formatTime(java.util.Date date,
int style,
java.util.Locale locale)
Returns a formatted time string for the given date using the given format
style, locale and default timezone.
|
static java.lang.String |
formatTime(java.util.Date date,
int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a formatted time string for the given date using the given format
style, locale and timezone.
|
static java.lang.String |
formatTime(java.util.Date date,
int style,
java.util.TimeZone tz)
Returns a formatted time string for the given date using the given format
style, timezone and default locale.
|
static java.lang.String |
formatTimeInput(java.util.Date date)
Returns a formatted time string for the given date using the properties
"Site.Format.TimeInput" definition.
|
static java.lang.String |
getClassRootName(java.lang.Class<?> clazz)
Returns a class' root name (what follows the package name).
|
private static java.text.DecimalFormat |
getCurrencyFormatter(int fmtidx)
Returns the decimal formatter used to format and parse currency numbers.
|
static java.lang.String |
getCurrencyFormatterPattern(int fmtidx)
Returns the pattern for the decimal formatter used to format and parse
currency numbers.
|
static java.text.DateFormat |
getDateFormatter(int style)
Returns a date formatter using the given format style, default locale and
default timezone.
|
static java.text.DateFormat |
getDateFormatter(int style,
java.util.Locale locale)
Returns a date formatter using the given format style, locale and default
timezone.
|
static java.text.DateFormat |
getDateFormatter(int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a date formatter using the given format style, locale and timezone.
|
static java.text.DateFormat |
getDateFormatter(int style,
java.util.TimeZone tz)
Returns a date formatter using the given format style, timezone and
default locale.
|
static java.text.DateFormat |
getDateTimeFormatter(int style)
Returns a date and time formatter using the given format style, default
locale and default timezone.
|
static java.text.DateFormat |
getDateTimeFormatter(int style,
java.util.Locale locale)
Returns a date and time formatter using the given format style, locale
and default timezone.
|
static java.text.DateFormat |
getDateTimeFormatter(int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a date and time formatter using the given format style, locale
and timezone.
|
static java.text.DateFormat |
getDateTimeFormatter(int style,
java.util.TimeZone tz)
Returns a date and time formatter using the given format style, timezone
and default locale.
|
private static java.text.DecimalFormat |
getDecimalFormatter(int fmtidx)
Returns the decimal formatter used to format and parse decimal numbers.
|
static java.lang.String |
getDecimalFormatterPattern(int fmtidx)
Returns the pattern for the decimal formatter used to format and parse
decimal numbers.
|
private static java.text.NumberFormat |
getIntegerFormatter(int fmtidx)
Returns the number formatter used to format and parse whole numbers.
|
static java.lang.String |
getIntegerFormatterPattern(int fmtidx)
Returns the pattern for the number formatter used to format and parse
whole numbers.
|
static java.lang.String |
getInvokerIdentity(java.lang.Object invokee)
Returns the reference point within the code from where the given invokee
is being called.
|
static java.lang.String |
getInvokerIdentity(java.lang.String invokee)
Returns the reference point within the code from where the given invokee
is being called.
|
static java.lang.String |
getResourceContent(java.lang.String resname)
Returns a
String for the given resource file name's content. |
static java.lang.String |
getResourceContent(java.lang.String resname,
boolean trim)
Returns a
String for the given resource file name's content. |
static java.lang.String |
getResourcePath(java.lang.String resname)
Returns the file path to the given resource file name.
|
static java.io.BufferedReader |
getResourceReader(java.lang.String resname)
Returns a
BufferedReader for the given resource file name. |
static java.io.InputStream |
getResourceStream(java.lang.String resname)
Returns an input stream for the given resource file name.
|
static java.net.URL |
getResourceURL(java.lang.String resname)
Returns a URL for the given resource file name.
|
static java.util.ArrayList<java.lang.String> |
getSortedPropertiesList(java.util.Properties props)
Returns a sorted list of the property keys and values in the given set
of properties.
|
static java.text.DateFormat |
getTimeFormatter(int style)
Returns a time formatter using the given format style, default locale and
default timezone.
|
static java.text.DateFormat |
getTimeFormatter(int style,
java.util.Locale locale)
Returns a time formatter using the given format style, locale and default
timezone.
|
static java.text.DateFormat |
getTimeFormatter(int style,
java.util.Locale locale,
java.util.TimeZone tz)
Returns a time formatter using the given format style, locale and timezone.
|
static java.text.DateFormat |
getTimeFormatter(int style,
java.util.TimeZone tz)
Returns a time formatter using the given format style, timezone and
default locale.
|
static java.util.Properties |
loadProperties(java.io.File file)
Returns a
Properties object that contains the contents of the
given properties file. |
static java.util.Properties |
loadProperties(java.lang.String propfile)
Returns a
Properties object that contains the contents of the
given properties file. |
static java.lang.String |
pad(java.lang.String base,
int direction,
int length,
char padChar)
Returns a string of the given length filled with the given character.
|
static java.lang.String |
padL(java.lang.String base,
int length)
Convenience method to pad a string on the left with spaces.
|
static java.lang.String |
padR(java.lang.String base,
int length)
Convenience method to pad a string on the right with spaces.
|
static java.lang.String |
padWithChar(int length,
char character)
Returns a string of the given length filled with the given character.
|
static java.util.ArrayList<java.lang.String> |
parseCSV(java.lang.String line)
Parses a string encoded in CSV format.
|
static java.util.Date |
parseDate(java.lang.String date)
Parses the given date string into a
Date object. |
static java.util.Date |
parseDate(java.lang.String date,
java.util.Locale locale)
Parses the given date string into a
Date object. |
static java.util.Date |
parseDate(java.lang.String date,
java.util.Locale locale,
java.util.TimeZone tz)
Parses the given date string into a
Date object. |
static java.util.Date |
parseDate(java.lang.String date,
java.util.TimeZone tz)
Parses the given date string into a
Date object. |
static java.util.Date |
parseDateInput(java.lang.String date)
Parses the given date string into a
Date object using the
properties "Site.Format.DateInput" definition. |
static double |
parseDouble(java.lang.String number)
Parses the given number string into a
double value. |
static <T extends java.lang.Enum<T>> |
parseEnum(java.lang.Class<T> clazz,
java.lang.String name)
Parses the given
enum and returns the constant having the
given name. |
static float |
parseFloat(java.lang.String number)
Parses the given number string into a
float value. |
static int |
parseInteger(java.lang.String number)
Parses the given number string into an
int value. |
static long |
parseLong(java.lang.String number)
Parses the given number string into a
long value. |
static short |
parseShort(java.lang.String number)
Parses the given number string into a
short value. |
static java.lang.String[] |
parseString(java.lang.String s,
java.lang.String delimiter)
Parses a given string into an array of strings based on a given delimiter.
|
static java.util.Date |
parseTimeInput(java.lang.String time)
Parses the given time string into a
Date object using the
properties "Site.Format.TimeInput" definition. |
static java.lang.String |
replaceString(java.lang.String s,
java.lang.String oldstr,
java.lang.String newstr)
Returns the given string with all occurrences of a substring replaced
with another substring.
|
static java.math.BigDecimal |
roundCurrency(java.math.BigDecimal value)
Returns the given value rounded to the appropriate number of currency
decimal positions.
|
static java.math.BigDecimal |
roundCurrency(double value)
Returns the given value rounded to the appropriate number of currency
decimal positions.
|
static java.util.ArrayList<java.lang.String> |
stringToArrayList(java.lang.String s,
int maxlen)
Converts a string into a collection of string elements with each element's
length being not more than a maximum length.
|
static char |
toHexChar(int nibble)
Convert a nibble (4 bits) to a hex character.
|
static java.lang.String |
toMixedCase(java.lang.String s)
Returns a mixed case string for the given string.
|
static java.lang.String |
trimR(java.lang.String s)
Removes trailing spaces from a string.
|
static java.lang.String |
truncate(java.lang.String input,
int maxLen)
Returns the string, truncated to maximum length.
|
static java.lang.Object[] |
vectorToObjectArray(java.util.Vector<?> v)
Converts a given vector to an object array.
|
static java.lang.String[] |
vectorToStringArray(java.util.Vector<?> v)
Converts a given vector to a string array.
|
private static final long serialVersionUID
public static final int LEFT
public static final int RIGHT
private static java.text.DecimalFormat[] cvCurrencyFormat
private static java.text.DecimalFormat[] cvDecimalFormat
private static java.text.NumberFormat[] cvNumberFormat
private static char[] hexDigit
public static java.lang.String addSiteRootPath(java.lang.String s)
s
- (String) The string to process.public static java.lang.String addSiteRootPathURL(java.lang.String s)
s
- (String) The string to process.public static java.lang.Object[] arrayListToObjectArray(java.util.ArrayList<?> al)
al
- (ArrayList) The array list that is to be converted.public static java.lang.String[] arrayListToStringArray(java.util.ArrayList<?> al)
al
- (ArrayList) The array list that is to be converted.public static java.lang.String booleanToYesNo(boolean value)
value
- (boolean) The boolean value.public static java.lang.String escapeRegEx(java.lang.String s)
s
- (String) The string to process.public static int findInArray(java.lang.String[] array, java.lang.String value)
array
- (String[]) The array to search.value
- (String) The value to find.public static java.lang.String formatCurrency(java.math.BigDecimal number)
number
- (BigDecimal) The number to format.public static java.lang.String formatCurrency(java.math.BigDecimal number, boolean fmtzero)
number
- (BigDecimal) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.public static java.lang.String formatCurrency(java.math.BigDecimal number, boolean fmtzero, boolean fmtgrps)
number
- (BigDecimal) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.fmtgrps
- (boolean) true
if grouping separators are
to be included, otherwise false.public static java.lang.String formatCurrency(double number)
number
- (double) The number to format.public static java.lang.String formatCurrency(double number, boolean fmtzero)
number
- (double) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.public static java.lang.String formatCurrency(double number, boolean fmtzero, boolean fmtgrps)
number
- (double) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.fmtgrps
- (boolean) true
if grouping separators are
to be included, otherwise false.public static java.lang.String formatDate(java.util.Date date, int style)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.public static java.lang.String formatDate(java.util.Date date, int style, java.util.Locale locale)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.locale
- (Locale) The desired locale of the formatted date.public static java.lang.String formatDate(java.util.Date date, int style, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.tz
- (TimeZone) The desired timezone for the formatted date.public static java.lang.String formatDate(java.util.Date date, int style, java.util.Locale locale, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.locale
- (Locale) The desired locale of the formatted date.tz
- (TimeZone) The desired timezone for the formatted date.public static java.lang.String formatDateInput(java.util.Date date)
date
- (Date) The date to format.null
.public static java.lang.String formatDateTime(java.util.Date date, int style)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.public static java.lang.String formatDateTime(java.util.Date date, int style, java.util.Locale locale)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.locale
- (Locale) The desired locale of the formatted date.public static java.lang.String formatDateTime(java.util.Date date, int style, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.tz
- (TimeZone) The desired timezone for the formatted date.public static java.lang.String formatDateTime(java.util.Date date, int style, java.util.Locale locale, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted date.locale
- (Locale) The desired locale of the formatted date.tz
- (TimeZone) The desired timezone for the formatted date.public static java.lang.String formatNumber(java.math.BigDecimal number)
number
- (BigDecimal) The number to format.public static java.lang.String formatNumber(java.math.BigDecimal number, boolean fmtzero)
number
- (BigDecimal) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.public static java.lang.String formatNumber(java.math.BigDecimal number, boolean fmtzero, boolean fmtgrps)
number
- (BigDecimal) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.fmtgrps
- (boolean) true
if grouping separators are
to be included, otherwise false.public static java.lang.String formatNumber(double number)
number
- (double) The number to format.public static java.lang.String formatNumber(double number, boolean fmtzero)
number
- (double) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.public static java.lang.String formatNumber(double number, boolean fmtzero, boolean fmtgrps)
number
- (double) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.fmtgrps
- (boolean) true
if grouping separators are
to be included, otherwise false.public static java.lang.String formatNumber(long number)
number
- (long) The number to format.public static java.lang.String formatNumber(long number, boolean fmtzero)
number
- (long) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.public static java.lang.String formatNumber(long number, boolean fmtzero, boolean fmtgrps)
number
- (long) The number to format.fmtzero
- (boolean) true
if zero value numbers are
to be formatted, otherwise false.fmtgrps
- (boolean) true
if grouping separators are
to be included, otherwise false.public static java.lang.String formatString(java.lang.String text, java.lang.String... values)
text
- (String) The text that is to have values substituted
into it.values
- (String) The value(s) that are to be substituted into the
given text. This parm uses the varargs feature and can therefore
be passed as multiple parms (text, value1, value2, value3, valueN)
or as an array (text, values[]).public static java.lang.String formatTime(java.util.Date date, int style)
date
- (Date) The date to format.style
- (int) The desired style of the formatted time.public static java.lang.String formatTime(java.util.Date date, int style, java.util.Locale locale)
date
- (Date) The date to format.style
- (int) The desired style of the formatted time.locale
- (Locale) The desired locale of the formatted time.public static java.lang.String formatTime(java.util.Date date, int style, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted time.tz
- (TimeZone) The desired timezone for the formatted time.public static java.lang.String formatTime(java.util.Date date, int style, java.util.Locale locale, java.util.TimeZone tz)
date
- (Date) The date to format.style
- (int) The desired style of the formatted time.locale
- (Locale) The desired locale of the formatted time.tz
- (TimeZone) The desired timezone for the formatted time.public static java.lang.String formatTimeInput(java.util.Date date)
date
- (Date) The date to format.null
.public static java.lang.String getClassRootName(java.lang.Class<?> clazz)
clazz
- (Class) A class object.private static java.text.DecimalFormat getCurrencyFormatter(int fmtidx)
fmtidx
- (int) The index of the formatter to return. The 1st
formatter (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd formatter (index 1)
is used when grouping separators are not included.public static java.lang.String getCurrencyFormatterPattern(int fmtidx)
fmtidx
- (int) The index of the pattern to return. The 1st
pattern (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd pattern (index 1)
is used when grouping separators are not included.public static java.text.DateFormat getDateFormatter(int style)
style
- (int) The desired style of the formatter.public static java.text.DateFormat getDateFormatter(int style, java.util.Locale locale)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.public static java.text.DateFormat getDateFormatter(int style, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.tz
- (TimeZone) The desired timezone for the formatter.public static java.text.DateFormat getDateFormatter(int style, java.util.Locale locale, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.tz
- (TimeZone) The desired timezone for the formatter.public static java.text.DateFormat getDateTimeFormatter(int style)
style
- (int) The desired style of the formatter.public static java.text.DateFormat getDateTimeFormatter(int style, java.util.Locale locale)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.public static java.text.DateFormat getDateTimeFormatter(int style, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.tz
- (TimeZone) The desired timezone for the formatter.public static java.text.DateFormat getDateTimeFormatter(int style, java.util.Locale locale, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.tz
- (TimeZone) The desired timezone for the formatter.private static java.text.DecimalFormat getDecimalFormatter(int fmtidx)
fmtidx
- (int) The index of the formatter to return. The 1st
formatter (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd formatter (index 1)
is used when grouping separators are not included.public static java.lang.String getDecimalFormatterPattern(int fmtidx)
fmtidx
- (int) The index of the pattern to return. The 1st
pattern (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd pattern (index 1)
is used when grouping separators are not included.private static java.text.NumberFormat getIntegerFormatter(int fmtidx)
fmtidx
- (int) The index of the formatter to return. The 1st
formatter (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd formatter (index 1)
is used when grouping separators are not included.public static java.lang.String getIntegerFormatterPattern(int fmtidx)
fmtidx
- (int) The index of the pattern to return. The 1st
pattern (index 0) is used when grouping separators are to be
included in the formatted results. The 2nd pattern (index 1)
is used when grouping separators are not included.public static java.lang.String getInvokerIdentity(java.lang.Object invokee)
To use, call this method from within the method where you wish to know the invoker's identity. Pass the class object that contains the method being invoked (i.e. "this").
This method determines the invoker's identity by obtaining a stack trace and then searching the stack for the given invokee's entry. The method then returns the next entry in the stack that follows the invokee's entry.
invokee
- (Object) The class object containing the method being
invoked (i.e. "this").public static java.lang.String getInvokerIdentity(java.lang.String invokee)
To use, call this method from within the method where you wish to know the invoker's identity. Pass the name of the class that contains the method being invoked (i.e. "com.dpslink.ecomm.servlet.ReviewCart").
This method determines the invoker's identity by obtaining a stack trace and then searching the stack for the given invokee's entry. The method then returns the next entry in the stack that follows the invokee's entry.
invokee
- (String) The name of the class containing the method
being invoked (i.e. "com.dpslink.ecomm.servlet.ReviewCart").public static java.lang.String getResourceContent(java.lang.String resname)
String
for the given resource file name's content.
Resource files are assumed to reside in a folder that is accessible via
the classpath. File names are assumed to be lower case. Always trims
comments and blank lines from the result.resname
- (String) The name of the resource file to retrieve.public static java.lang.String getResourceContent(java.lang.String resname, boolean trim)
String
for the given resource file name's content.
Resource files are assumed to reside in a folder that is accessible via
the classpath. File names are assumed to be lower case. Always trims
comments from the result. Trimming blank lines is optional.resname
- (String) The name of the resource file to retrieve.trim
- (boolean) true
to trim blank lines from the
result, otherwise false
.public static java.lang.String getResourcePath(java.lang.String resname)
resname
- (String) The name of the resource file to retrieve.null
if no file exists for the specified name. Includes trailing file
separator character.public static java.io.BufferedReader getResourceReader(java.lang.String resname)
BufferedReader
for the given resource file name.
Resource files are assumed to reside in a folder that is accessible via
the classpath. File names are assumed to be lower case.resname
- (String) The name of the resource file to retrieve.null
if no file exists for the specified name.public static java.io.InputStream getResourceStream(java.lang.String resname)
resname
- (String) The name of the resource file to retrieve.null
if no file exists for the specified name.public static java.net.URL getResourceURL(java.lang.String resname)
resname
- (String) The name of the resource file to retrieve.null
if no file exists for the specified name.public static java.util.ArrayList<java.lang.String> getSortedPropertiesList(java.util.Properties props)
props
- (Properties) The properties to process.public static java.text.DateFormat getTimeFormatter(int style)
style
- (int) The desired style of the formatter.public static java.text.DateFormat getTimeFormatter(int style, java.util.Locale locale)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.public static java.text.DateFormat getTimeFormatter(int style, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.tz
- (TimeZone) The desired timezone for the formatter.public static java.text.DateFormat getTimeFormatter(int style, java.util.Locale locale, java.util.TimeZone tz)
style
- (int) The desired style of the formatter.locale
- (Locale) The desired locale of the formatter.tz
- (TimeZone) The desired timezone for the formatter.public static java.util.Properties loadProperties(java.io.File file)
Properties
object that contains the contents of the
given properties file. If the properties file to load cannot be found or
cannot be loaded, this method silently fails and returns an empty properties
object.file
- (File) The file for the properties to load.public static java.util.Properties loadProperties(java.lang.String propfile)
Properties
object that contains the contents of the
given properties file. The properties file to load must be accessible via
the classpath. If the properties file to load cannot be found or cannot
be loaded, this method silently fails and returns an empty properties
object.propfile
- (String) The name of the properties file to load.public static java.lang.String pad(java.lang.String base, int direction, int length, char padChar)
base
- (String) String to be padded.direction
- (int) Pad direction (left or right).length
- (int) The length of the string to return.padChar
- (char) The character that is to be used as a fill
character for the new string.public static java.lang.String padL(java.lang.String base, int length)
base
- (String) String to be padded.length
- (int) The length of the string to return.public static java.lang.String padR(java.lang.String base, int length)
base
- (String) String to be padded.length
- (int) The length of the string to return.public static java.lang.String padWithChar(int length, char character)
length
- (int) The length of the string to return.character
- (char) The character that is to be used as a fill
character for the new string.public static java.util.ArrayList<java.lang.String> parseCSV(java.lang.String line)
line
- (String) The text line to be parsed.String
or null if a parsing error occurred.public static java.util.Date parseDate(java.lang.String date)
Date
object. In order for
the given string to parse correctly, it must conform to the default locale
DateFormat.SHORT format.date
- (String) The string to be parsed.Date
object for the parsed string, or
null
if the given string could not be parsed.public static java.util.Date parseDate(java.lang.String date, java.util.Locale locale)
Date
object. In order for
the given string to parse correctly, it must conform to the given locale's
DateFormat.SHORT format.date
- (String) The string to be parsed.locale
- (Locale) The locale to use for the parsing.Date
object for the parsed string, or
null
if the given string could not be parsed.public static java.util.Date parseDate(java.lang.String date, java.util.TimeZone tz)
Date
object. In order for
the given string to parse correctly, it must conform to the default locale's
DateFormat.SHORT format.date
- (String) The string to be parsed.tz
- (TimeZone) The timezone for the parsing.Date
object for the parsed string, or
null
if the given string could not be parsed.public static java.util.Date parseDate(java.lang.String date, java.util.Locale locale, java.util.TimeZone tz)
Date
object. In order for
the given string to parse correctly, it must conform to the given locale's
DateFormat.SHORT format.date
- (String) The string to be parsed.locale
- (Locale) The locale to use for the parsing.tz
- (TimeZone) The timezone for the parsing.Date
object for the parsed string, or
null
if the given string could not be parsed.public static java.util.Date parseDateInput(java.lang.String date)
Date
object using the
properties "Site.Format.DateInput" definition.date
- (String) The string to be parsed.Date
object for the parsed string, or
null
if the given string could not be parsed.public static double parseDouble(java.lang.String number)
double
value.number
- (String) The string to be parsed.public static <T extends java.lang.Enum<T>> T parseEnum(java.lang.Class<T> clazz, java.lang.String name)
enum
and returns the constant having the
given name.clazz
- (Class) The class for the enum
to parse.name
- (String) The name of the constant to retrieve.null
if no constant could be determined.public static float parseFloat(java.lang.String number)
float
value.number
- (String) The string to be parsed.public static int parseInteger(java.lang.String number)
int
value.number
- (String) The string to be parsed.public static long parseLong(java.lang.String number)
long
value.number
- (String) The string to be parsed.public static short parseShort(java.lang.String number)
short
value.number
- (String) The string to be parsed.public static java.lang.String[] parseString(java.lang.String s, java.lang.String delimiter)
s
- (String) The string to be parsed.delimiter
- (String) The delimiter to be used for the parsing.public static java.util.Date parseTimeInput(java.lang.String time)
Date
object using the
properties "Site.Format.TimeInput" definition.time
- (String) The string to be parsed.Date
object for the parsed string, or
null
if the given string could not be parsed.public static java.lang.String replaceString(java.lang.String s, java.lang.String oldstr, java.lang.String newstr)
s
- (String) The string to process.oldstr
- (String) The substring to find and replace.newstr
- (String) The replacement substring.public static java.math.BigDecimal roundCurrency(double value)
value
- (double) The value to round.public static java.math.BigDecimal roundCurrency(java.math.BigDecimal value)
value
- (BigDecimal) The value to round.public static java.util.ArrayList<java.lang.String> stringToArrayList(java.lang.String s, int maxlen)
s
- (String) The string to process.maxlen
- (int) The maximum length of a collection element's
content.public static char toHexChar(int nibble)
nibble
- (int) the nibble to convert.public static java.lang.String toMixedCase(java.lang.String s)
s
- (String) The string to process.public static java.lang.String trimR(java.lang.String s)
s
- (String) The string to trim.public static java.lang.String truncate(java.lang.String input, int maxLen)
input
- (String) The string to truncate.maxLen
- (int) The maximum length of the string to returnpublic static java.lang.Object[] vectorToObjectArray(java.util.Vector<?> v)
v
- (Vector) The vector that is to be converted.public static java.lang.String[] vectorToStringArray(java.util.Vector<?> v)
v
- (Vector) The vector that is to be converted.public static java.util.ArrayList<java.math.BigDecimal> arrayMath(java.util.ArrayList<java.math.BigDecimal> a1, java.lang.String operator, java.util.ArrayList<java.math.BigDecimal> a2)
a1
- (ArrayList) Operand array 1.operator
- (String) Operation to perform ("+", "-", "*", "/").a2
- (ArrayList) Operand array 2.