java.lang.Object | +--com.ibm.commerce.tools.epromotion.util.EproUtil
This Util class provide all the utility methods for epromotion component.
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT IBM copyright notice field. |
static java.text.SimpleDateFormat |
displayDateFormat This format is used for output by default |
static java.text.SimpleDateFormat |
displayTimeFormat This format is used for output by default |
static java.text.SimpleDateFormat |
displayTimestampFormat This format is used for output by default |
static java.lang.String |
jdbcTimestampFormat This format is a default JDBC timestamp escape format without nanoseconds. |
static java.text.SimpleDateFormat[] |
supportedDateFormats These formats supported for converting strings to dates |
static java.text.SimpleDateFormat[] |
supportedTimeFormats These formats supported for converting strings to time |
static java.text.SimpleDateFormat[] |
supportedTimestampFormats These formats supported for converting strings to datetime |
Constructor Summary | |
---|---|
EproUtil() Util constructor comment. |
Method Summary | |
---|---|
static java.lang.String |
dateToString(java.sql.Date date) Returns the date as a String formatted by
the default format
displayDateFormat . |
static java.lang.String |
dateToString(java.sql.Date date, java.lang.String format) Returns the date as a String formatted by
the supplied format A null date is converted to a null
String . |
static java.lang.Object |
doCheckParameterFound(java.util.Map h,
java.lang.String parameterName) Return the value of the key in the Map, if value of the key doesn't exist, throw exception. |
static java.lang.String |
endTag(java.lang.String tagName) Return the XML end tag with tag name included. |
java.lang.String |
getCategoryName(java.lang.String storeId, java.lang.String langId,
java.lang.String catIdentifier) Returns category name in string type by passing its store Id.language Id and identifier |
java.lang.String |
getCatEntryId(java.lang.String partNumber,
java.lang.String dN) Return catentry id in string type by passing its unique index. |
java.lang.String |
getCatGroupId(java.lang.String identifier,
java.lang.String dN) Returns category id in string type by passing its unique index. |
java.lang.String |
getShipModeId(java.lang.String code, java.lang.String carrier,
java.lang.String storeName, java.lang.String ownerDN) Return ship mode id in string type by passing its unique index. |
java.lang.String |
getSKU(java.lang.String catentry_id) Return sku String in string type by passing its catentry_id |
java.lang.String |
getSKUName(java.lang.String langId,
java.lang.String catentry_id) Returns skuName String in string type by passing its catentry_id |
java.util.Vector |
getSKUs(java.util.Vector catentryIds) Returns sku Vector in by passing its catentry_id vector |
java.lang.String |
getSKUType(java.lang.String catentry_id) Returns skuTpe String in string type by passing its catentry_id |
static boolean |
isBlank(java.lang.String s) Takes a string and returns true if it is null, an emptry string, or only contains white space. |
boolean |
isCep() This method checks if current release of product used is CEP. |
static boolean |
isValidDate(java.lang.String s) Returns true if the string is valid date or isBlank(String) ; false otherwise. |
static boolean |
isValidDateFormat(java.lang.String format) Tests if the date format pattern specified is valid. |
static boolean |
isValidTime(java.lang.String s) Returns true if the string is valid date or isBlank(String) ; false otherwise. |
static boolean |
isValidTimestamp(java.lang.String s) Returns true if the string is valid date or isBlank(String) ; false otherwise. |
static java.lang.String |
normalizeDatetime(java.lang.String s) Gets rid of unnecessary punctuation, multiple whitespace and other anomalies in a Datetime string Converts all characters to caps and inserts spaces between digits and letters. |
static java.lang.String |
replaceSubstring(java.lang.String str, java.lang.String substr1,
java.lang.String substr2, int startFromLocation) Utility function used to replace all occurences of substr1 with substr2 in str. |
static void |
requireParameterNotNull(java.lang.String className,
java.lang.String methodName, java.lang.String parameterName,
java.lang.Object object) Clients should call this when they receive a parameter that may not be null. |
static java.lang.String |
spacesToUnderscores(java.lang.String s) Takes a String and converts the blank spaces inside the String to underscores, then returns this new String |
static java.lang.String |
startTag(java.lang.String tagName) Return a XML start tag with given tag name. |
static java.sql.Date |
stringToDate(java.lang.String s) Converts a String to a Date . |
static java.sql.Date |
stringToDate(java.lang.String s, java.lang.String format) Converts a String to a Date using the given
format . |
static java.sql.Time |
stringToTime(java.lang.String s) Converts a String to a Time . |
static java.sql.Time |
stringToTime(java.lang.String s, java.lang.String format) Converts a String to a Time using the given
format . |
static java.sql.Timestamp |
stringToTimestamp(java.lang.String s) Converts a String to a Timestamp . |
static java.sql.Timestamp |
stringToTimestamp(java.lang.String s,
java.lang.String format) Converts a String to a Timestamp using the
given format . |
static java.sql.Timestamp |
stringToTimestamp(java.lang.String s, java.lang.String format,
java.util.Locale lcl) Converts a String to a Timestamp using the
given format and lcl . |
static java.lang.String |
timestampToString(java.util.Date date) Returns the date as a String formatted by
the default format
displayDateFormat . |
static java.lang.String |
timestampToString(java.util.Date date,
java.lang.String format) Returns the date as a String formatted by
the supplied format A null date is converted to a null
String . |
static java.lang.String |
timestampToString(java.sql.Timestamp date) Returns the date as a String formatted by
the default format
displayDateFormat . |
static java.lang.String |
timestampToString(java.sql.Timestamp date,
java.lang.String format) Returns the date as a String formatted by
the supplied format A null date is converted to a null
String . |
static java.lang.String |
timestampToString(java.sql.Timestamp date, java.lang.String format,
java.util.Locale lcl) Returns the date as a String formatted by
the supplied format and locale A null date is converted to a
null String . |
static java.lang.String |
timeToString(java.sql.Time time) Returns the date as a String formatted by
the default format
displayDateFormat . |
static java.lang.String |
timeToString(java.sql.Time time, java.lang.String format) Returns the date as a String formatted by
the supplied format A null date is converted to a null
String . |
static boolean |
toBoolean(java.lang.Object value) Convert Object into a boolean primitive type |
static boolean |
toBoolean(java.lang.String value) Convert String into a boolean primitive type |
static int |
toInt(java.lang.Object value) Convert Object into an int primitive type |
static int |
toInt(java.lang.String value) Convert String into an int primitive type |
static java.util.Vector |
toReversedVector(java.util.Vector originalVector) This method is using to reverse the order of Vector's objects. |
static java.util.Vector |
toVector(java.lang.Object value) This method will convert an Object type of vector into a Vector type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll,
toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
public static java.lang.String jdbcTimestampFormat
public static java.text.SimpleDateFormat displayDateFormat
public static java.text.SimpleDateFormat displayTimeFormat
public static java.text.SimpleDateFormat displayTimestampFormat
public static java.text.SimpleDateFormat[] supportedDateFormats
public static java.text.SimpleDateFormat[] supportedTimeFormats
public static java.text.SimpleDateFormat[] supportedTimestampFormats
Constructor Detail |
---|
public EproUtil()
Method Detail |
---|
public static java.lang.String dateToString(java.sql.Date date)
date
as a String
formatted by the
default format
displayDateFormat
. A null date
is converted to a
null String
.
date
- Datedate
formatted by the default format
displayDateFormat
or null
.public static java.lang.String dateToString(java.sql.Date date, java.lang.String format)
date
as a String
formatted by the
supplied format A null date
is converted to a null
String
.
date
- Dateformat
- format to useString
, or null if the date parameter is
null.java.lang.IllegalArgumentException
- An exception will be
thrown if the format specified by the format
parameter is
invalid.public static java.lang.Object doCheckParameterFound(java.util.Map h, java.lang.String parameterName) throws ParameterNotFoundException
h
- java.util.MapparameterName
- java.lang.String
ParameterNotFoundException
public static java.lang.String endTag(java.lang.String tagName)
tagName
- java.lang.Stringpublic static boolean isBlank(java.lang.String s)
s
- The String to check.public static boolean isValidDate(java.lang.String s)
isBlank(String)
; false otherwise.
s
- String to validatepublic static boolean isValidDateFormat(java.lang.String format)
format
- The format string to test.public static boolean isValidTime(java.lang.String s)
isBlank(String)
; false otherwise.
s
- String to validatepublic static boolean isValidTimestamp(java.lang.String s)
isBlank(String)
; false otherwise.
s
- String to validatepublic static java.lang.String normalizeDatetime(java.lang.String s)
s
- String to normalizepublic static java.lang.String replaceSubstring(java.lang.String str, java.lang.String substr1, java.lang.String substr2, int startFromLocation)
str
- The original stringsubstr1
- The substring to be replaced (all occurences of
it)substr2
- The substring that is inserted in place of
substr1startFromLocation
- The starting location in str (if the whole
string put 0)public static final void requireParameterNotNull(java.lang.String className, java.lang.String methodName, java.lang.String parameterName, java.lang.Object object)
className
- java.lang.StringmethodName
- java.lang.StringparameterName
- java.lang.Stringobject
- java.lang.Objectpublic static java.lang.String spacesToUnderscores(java.lang.String s)
s
- String to convertpublic static java.lang.String startTag(java.lang.String tagName)
tagName
- java.lang.Stringpublic static java.sql.Date stringToDate(java.lang.String s) throws java.text.ParseException
String
to a Date
. Any of the formats
#dateFormat_DASH
, #dateFormat_SLASH
,
#dateFormat_DOT
, #dateFormat_SPACE
, and
#dateFormat_NONE
with 2 or 4 digit years are accepted (2 digit
years have the range 1921-2020). An
isBlank(String)
String
is converted to a
null Date
.
s
- String to parseDate
parsed or null
java.text.ParseException
- thrown if s
is
improperly formatted.public static java.sql.Date stringToDate(java.lang.String s, java.lang.String format) throws java.text.ParseException
String
to a Date
using the given
format
. An
isBlank(String)
String
is converted to a
null Date
.
s
- String to parseformat
- Format to useDate
parsed or null
java.text.ParseException
- if s
is improperly
formatted.java.lang.IllegalArgumentException
- if the format specified
by format
is invalid.public static java.sql.Time stringToTime(java.lang.String s) throws java.text.ParseException
String
to a Time
. Any of the formats
in the supportedTimeFormat array are supported, separated by any puctuation An
isBlank(String)
String
is converted to a
null Time
.
s
- String to parseTime
parsed or null
java.text.ParseException
- thrown if s
is
improperly formatted.public static java.sql.Time stringToTime(java.lang.String s, java.lang.String format) throws java.text.ParseException
String
to a Time
using the given
format
. An
isBlank(String)
String
is converted to a
null Time
.
s
- String to parseformat
- Format to useTime
parsed or null
java.text.ParseException
- if s
is improperly
formatted.java.lang.IllegalArgumentException
- if the format specified
by format
is invalid.public static java.sql.Timestamp stringToTimestamp(java.lang.String s) throws java.text.ParseException
String
to a Timestamp
. Any of the
formats #timestampFormat_DASH
,
#timestampFormat_SLASH
, #timestampFormat_DOT
,
#timestampFormat_SPACE
, and #timestampFormat_NONE
with 2 or 4 digit years are accepted (2 digit years have the range 1921-2020).
An
isBlank(String)
String
is converted to a
null Timestamp
.
s
- String to parseTimestamp
parsed or null
java.text.ParseException
- thrown if s
is
improperly formatted.public static java.sql.Timestamp stringToTimestamp(java.lang.String s, java.lang.String format) throws java.text.ParseException
String
to a Timestamp
using the given
format
. An
isBlank(String)
String
is converted to a
null Timestamp
.
s
- String to parseformat
- Format to useTimestamp
parsed or null
java.text.ParseException
- if s
is improperly
formatted.java.lang.IllegalArgumentException
- if the format specified
by format
is invalid.public static java.sql.Timestamp stringToTimestamp(java.lang.String s, java.lang.String format, java.util.Locale lcl) throws java.text.ParseException
String
to a Timestamp
using the given
format
and lcl
. An
isBlank(String)
String
is converted to a
null Timestamp
.
s
- String to parseformat
- java.lang.Stringlcl
- java.lang.LocaleTimestamp
parsed or null
java.text.ParseException
- if s
is improperly
formatted.java.lang.IllegalArgumentException
- if the format specified
by format
is invalid.public static java.lang.String timestampToString(java.sql.Timestamp date)
date
as a String
formatted by the
default format
displayDateFormat
. A null date
is converted to a
null String
.
date
- Datedate
formatted by the default format
displayDateFormat
or null
.public static java.lang.String timestampToString(java.sql.Timestamp date, java.lang.String format)
date
as a String
formatted by the
supplied format A null date
is converted to a null
String
.
date
- Dateformat
- format to useString
, or null if the date parameter is
null.java.lang.IllegalArgumentException
- An exception will be
thrown if the format specified by the format
parameter is
invalid.public static java.lang.String timestampToString(java.util.Date date)
date
as a String
formatted by the
default format
displayDateFormat
. A null date
is converted to a
null String
.
date
- Datedate
formatted by the default format
displayDateFormat
or null
.public static java.lang.String timestampToString(java.util.Date date, java.lang.String format)
date
as a String
formatted by the
supplied format A null date
is converted to a null
String
.
date
- Dateformat
- format to useString
, or null if the date parameter is
null.java.lang.IllegalArgumentException
- An exception will be
thrown if the format specified by the format
parameter is
invalid.public static java.lang.String timestampToString(java.sql.Timestamp date, java.lang.String format, java.util.Locale lcl)
date
as a String
formatted by the
supplied format and locale A null date
is converted to a
null String
.
date
- Dateformat
- format to uselcl
- java.util.LocaleString
, or null if the date parameter is
null.java.lang.IllegalArgumentException
- An exception will be
thrown if the format specified by the format
parameter is
invalid.public static java.lang.String timeToString(java.sql.Time time)
date
as a String
formatted by the
default format
displayDateFormat
. A null date
is converted to a
null String
.
date
formatted by the default format
displayDateFormat
or null
.public static java.lang.String timeToString(java.sql.Time time, java.lang.String format)
date
as a String
formatted by the
supplied format A null date
is converted to a null
String
.
format
- format to useString
, or null if the date parameter is
null.java.lang.IllegalArgumentException
- An exception will be
thrown if the format specified by the format
parameter is
invalid.public static boolean toBoolean(java.lang.Object value)
value
- java.lang.Objectpublic static boolean toBoolean(java.lang.String value)
value
- java.lang.Stringpublic static int toInt(java.lang.Object value)
value
- java.lang.Objectpublic static int toInt(java.lang.String value)
value
- java.lang.Stringpublic static java.util.Vector toReversedVector(java.util.Vector originalVector)
public static java.util.Vector toVector(java.lang.Object value)
value
- java.lang.Objectpublic java.lang.String getCatEntryId(java.lang.String partNumber, java.lang.String dN) throws ECException
partNumber
- java.lang.StringdN
- java.lang.StringECException
public java.lang.String getShipModeId(java.lang.String code, java.lang.String carrier, java.lang.String storeName, java.lang.String ownerDN) throws ECException
code
- java.lang.Stringcarrier
- java.lang.StringstoreName
- java.lang.StringownerDN
- java.lang.StringFinderException
java.rmi.RemoteException
javax.naming.NamingException
CreateException
ECException
public java.lang.String getSKU(java.lang.String catentry_id) throws ECException
catentry_id
- java.lang.StringECException
public java.lang.String getSKUType(java.lang.String catentry_id) throws ECException
catentry_id
- java.lang.StringECException
public java.lang.String getSKUName(java.lang.String langId, java.lang.String catentry_id) throws ECException
langId
- java.lang.Stringcatentry_id
- java.lang.StringECException
public java.util.Vector getSKUs(java.util.Vector catentryIds) throws ECException
ECException
public java.lang.String getCatGroupId(java.lang.String identifier, java.lang.String dN) throws ECException
identifier
- java.lang.StringdN
- java.lang.StringECException
public java.lang.String getCategoryName(java.lang.String storeId, java.lang.String langId, java.lang.String catIdentifier) throws ECException
storeId
- java.lang.StringlangId
- java.lang.StringcatIdentifier
- java.lang.StringECException
public boolean isCep()