|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.elasticpath.commons.util.impl.UtilityImpl
public final class UtilityImpl
The default implementation of Utility
.
Field Summary |
---|
Fields inherited from interface com.elasticpath.commons.util.Utility |
---|
MAX_ALLOW_EXPRESSIONS_IN_QUERY |
Constructor Summary | |
---|---|
UtilityImpl()
|
Method Summary | |
---|---|
java.lang.String |
array2string(java.lang.Object[] array,
java.lang.String separator)
Convert an array of objects to a string. |
java.lang.String |
bigDecimal2String(java.math.BigDecimal bigDecimalValue)
Convert a BigDecimal object to a String object. |
java.lang.String |
boolean2String(boolean booleanValue)
Convert a boolean value to a String object. |
boolean |
checkLongTextMaxLength(java.lang.String value)
Returns true if the length of the given value <= long text max length. |
boolean |
checkShortTextMaxLength(java.lang.String value)
Returns true if the length of the given value <= short text max length. |
java.util.List |
composeQueries(java.lang.String queryTemplate,
java.lang.String placeHolder,
java.util.Collection values)
Compose queries based on the given query template, place holder and values. |
java.lang.String |
date2String(java.util.Date date)
Convert a Date to a String based on the system default date format. |
java.lang.String |
date2String(java.util.Date date,
java.text.SimpleDateFormat sdf)
Convert a date to a string based on the given date format. |
java.lang.String |
escapeName2UrlFriendly(java.lang.String name)
Returns an escaped name which is URL-friendly. |
java.lang.String |
exception2string(java.lang.Exception exception)
Returns a string with full stack of the given exception. |
java.util.Map |
getCardTypeMap()
Get a map of the supported card types for display in Spring. |
ElasticPath |
getElasticPath()
Returns the elastic path context. |
java.lang.String |
getLocalizedFile(java.lang.String baseDir,
java.lang.String filePath,
java.lang.String fileExtension,
java.util.Locale locale)
Return the localized file path of the given file path. |
java.util.Map |
getMonthMap()
Get a map of the numbers of months of the year for the Spring form input for credit card expiry. |
java.lang.String |
getRandomStringWithLength(int length)
Get a random string with the required length. |
java.lang.String |
getTimeStamp()
Returns a timestamp string. |
java.util.Map |
getYearMap()
Get a map of years for the Spring form input for credit card expiry. |
java.lang.String |
int2String(int intValue)
Convert an int value to a String object. |
boolean |
isAlphaNumeric(java.lang.String string)
Returns true if the given string is all alphanumeric characters. |
boolean |
isValidGuidStr(java.lang.String string)
Returns true if the given string is a valid guid string. |
boolean |
isValidZipPostalCode(java.lang.String zipPostalCode)
Returns true if the given zip postal code is valid. |
java.lang.String |
regexQuote(java.lang.String regexString)
Escapes the provided String as a literal String safe for use as a regular expression. |
void |
setElasticPath(ElasticPath elasticPath)
Sets the elastic path context. |
java.math.BigDecimal |
string2BigDecimal(java.lang.String stringValue)
Convert a String to a BigDecimal object. |
boolean |
string2Boolean(java.lang.String stringValue)
Convert a String to a boolean value . |
java.util.Currency |
string2Currency(java.lang.String stringValue)
Convert a String to a Currency instance. |
java.util.Date |
string2Date(java.lang.String stringValue)
Convert a String to a Date based on the system default date format. |
java.util.Date |
string2Date(java.lang.String dateString,
java.text.SimpleDateFormat sdf)
Convert a date string and return a Date object. |
int |
string2Int(java.lang.String stringValue)
Convert a String to an int value . |
java.util.Locale |
string2Locale(java.lang.String stringValue)
Convert a String to a Locale instance. |
long |
string2Long(java.lang.String stringValue)
Convert a String to an long value. |
Money |
string2Money(java.util.Currency currency,
java.lang.String value)
Convert a String to a Money instance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UtilityImpl()
Method Detail |
---|
public java.lang.String array2string(java.lang.Object[] array, java.lang.String separator)
array2string
in interface Utility
array
- the array of objectsseparator
- the separator
public java.lang.String bigDecimal2String(java.math.BigDecimal bigDecimalValue)
BigDecimal
object to a String
object.
bigDecimal2String
in interface Utility
bigDecimalValue
- the BigDecimal
object
String
objectpublic java.lang.String boolean2String(boolean booleanValue)
boolean
value to a String
object.
boolean2String
in interface Utility
booleanValue
- the boolean
value
String
objectpublic boolean checkLongTextMaxLength(java.lang.String value)
true
if the length of the given value <= long text max length. Otherwise, false
.
checkLongTextMaxLength
in interface Utility
value
- the value to check
true
if the length of the given value <= long text max length. Otherwise, false
.public boolean checkShortTextMaxLength(java.lang.String value)
true
if the length of the given value <= short text max length. Otherwise, false
.
checkShortTextMaxLength
in interface Utility
value
- the value to check
true
if the length of the given value <= short text max length. Otherwise, false
.public java.util.List composeQueries(java.lang.String queryTemplate, java.lang.String placeHolder, java.util.Collection values)
Note: since Oracle only allow 1000 expressions in one query, we have to separate big query over 1000 expressions to multiple queries. This method can be used to create multiple queries for you.
composeQueries
in interface Utility
queryTemplate
- the query templateplaceHolder
- the place holder as a regular expressionvalues
- a list of values to replace the place holder.
public java.lang.String date2String(java.util.Date date)
Date
to a String
based on the system default date format.
date2String
in interface Utility
date
- the date
public java.lang.String date2String(java.util.Date date, java.text.SimpleDateFormat sdf)
date2String
in interface Utility
date
- the datesdf
- the simple date format
public java.lang.String escapeName2UrlFriendly(java.lang.String name)
escapeName2UrlFriendly
in interface Utility
name
- the original name
public java.lang.String exception2string(java.lang.Exception exception)
exception2string
in interface Utility
exception
- the exception
public java.util.Map getCardTypeMap()
getCardTypeMap
in interface Utility
public ElasticPath getElasticPath()
public java.lang.String getLocalizedFile(java.lang.String baseDir, java.lang.String filePath, java.lang.String fileExtension, java.util.Locale locale)
getLocalizedFile
in interface Utility
baseDir
- the base directoryfilePath
- the file path relative the base directoryfileExtension
- the file extensionlocale
- the locale
public java.util.Map getMonthMap()
getMonthMap
in interface Utility
public java.lang.String getRandomStringWithLength(int length)
getRandomStringWithLength
in interface Utility
length
- the length of the string to return
public java.lang.String getTimeStamp()
getTimeStamp
in interface Utility
public java.util.Map getYearMap()
getYearMap
in interface Utility
public java.lang.String int2String(int intValue)
int
value to a String
object.
int2String
in interface Utility
intValue
- the int
value
String
objectpublic boolean isAlphaNumeric(java.lang.String string)
true
if the given string is all alphanumeric characters. Otherwise, false
isAlphaNumeric
in interface Utility
string
- the string
true
if the given string is all alphanumeric characters. Otherwise, false
public boolean isValidGuidStr(java.lang.String string)
true
if the given string is a valid guid string. Otherwise, false
isValidGuidStr
in interface Utility
string
- the string
true
if the given string is a valid guid string. Otherwise, false
public boolean isValidZipPostalCode(java.lang.String zipPostalCode)
true
if the given zip postal code is valid. Otherwise, false
.
isValidZipPostalCode
in interface Utility
zipPostalCode
- the zip postal code.
true
if the given zip postal code is valid. Otherwise, false
.public java.lang.String regexQuote(java.lang.String regexString)
regexQuote
in interface Utility
regexString
- The string to be escaped
public void setElasticPath(ElasticPath elasticPath)
elasticPath
- the elastic path contextpublic java.math.BigDecimal string2BigDecimal(java.lang.String stringValue) throws EpBigDecimalBindException
String
to a BigDecimal
object.
string2BigDecimal
in interface Utility
stringValue
- the string
BigDecimal
object
EpBigDecimalBindException
- if the given string cannot be converted to a BigDecimal
objectpublic boolean string2Boolean(java.lang.String stringValue) throws EpBooleanBindException
String
to a boolean
value .
string2Boolean
in interface Utility
stringValue
- the string
boolean
value
EpBooleanBindException
- if the given string cannot be converted to a boolean
valuepublic java.util.Currency string2Currency(java.lang.String stringValue) throws EpCurrencyBindException
String
to a Currency
instance.
string2Currency
in interface Utility
stringValue
- the string
Currency
instance.
EpCurrencyBindException
- if the given string cannot be converted to a Currency
instancepublic java.util.Date string2Date(java.lang.String stringValue) throws EpDateBindException
String
to a Date
based on the system default date format.
string2Date
in interface Utility
stringValue
- the string
Date
object
EpDateBindException
- if the given string cannot be converted to a Date
objectpublic java.util.Date string2Date(java.lang.String dateString, java.text.SimpleDateFormat sdf) throws EpDateBindException
Date
object.
string2Date
in interface Utility
dateString
- A date string to parsesdf
- The simple date format of the date string.
Date
object if the data string is valid. EpDateBindException
- in case the given string cannot be converted to a Date
objectpublic int string2Int(java.lang.String stringValue) throws EpIntBindException
String
to an int
value .
string2Int
in interface Utility
stringValue
- the string
int
value
EpIntBindException
- if the given string cannot be converted to a int
valuepublic java.util.Locale string2Locale(java.lang.String stringValue) throws EpLocaleBindException
String
to a Locale
instance.
string2Locale
in interface Utility
stringValue
- the string
Locale
instance.
EpLocaleBindException
- if the given string cannot be converted to a Locale
instancepublic long string2Long(java.lang.String stringValue) throws EpLongBindException
String
to an long
value.
string2Long
in interface Utility
stringValue
- the string
long
value
EpLongBindException
- if the given string cannot be converted to an long
valuepublic Money string2Money(java.util.Currency currency, java.lang.String value)
String
to a Money
instance.
string2Money
in interface Utility
currency
- the currencyvalue
- the value
Money
instance
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |