com.ibm.commerce.tools.epromotion.util
Class EproUtil

java.lang.Object
  |
  +--com.ibm.commerce.tools.epromotion.util.EproUtil

public final class EproUtil
extends java.lang.Object

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 Dateusing 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 Timeusing 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 Timestampusing 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 Timestampusing 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
IBM copyright notice field.
See Also:
Constant Field Values

jdbcTimestampFormat

public static java.lang.String jdbcTimestampFormat
This format is a default JDBC timestamp escape format without nanoseconds. Note that java.text.SimpleDataFormat does not allow for the nanoseconds component of a Timestamp object. This format could be used filter out the nanoseconds from the Timestamp object read by JDBC.

displayDateFormat

public static java.text.SimpleDateFormat displayDateFormat
This format is used for output by default

displayTimeFormat

public static java.text.SimpleDateFormat displayTimeFormat
This format is used for output by default

displayTimestampFormat

public static java.text.SimpleDateFormat displayTimestampFormat
This format is used for output by default

supportedDateFormats

public static java.text.SimpleDateFormat[] supportedDateFormats
These formats supported for converting strings to dates

supportedTimeFormats

public static java.text.SimpleDateFormat[] supportedTimeFormats
These formats supported for converting strings to time

supportedTimestampFormats

public static java.text.SimpleDateFormat[] supportedTimestampFormats
These formats supported for converting strings to datetime
Constructor Detail

EproUtil

public EproUtil()
Util constructor comment.
Method Detail

dateToString

public static java.lang.String dateToString(java.sql.Date date)
Returns the date as a String formatted by the default format displayDateFormat. A null date is converted to a null String.
Parameters:
date - Date
Returns:
date formatted by the default format displayDateFormat or null.

dateToString

public 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.
Parameters:
date - Date
format - format to use
Returns:
A formatted String, or null if the date parameter is null.
Throws:
java.lang.IllegalArgumentException - An exception will be thrown if the format specified by the format parameter is invalid.

doCheckParameterFound

public static java.lang.Object doCheckParameterFound(java.util.Map h,
                                                     java.lang.String parameterName)
                                              throws ParameterNotFoundException
Return the value of the key in the Map, if value of the key doesn't exist, throw exception.
Parameters:
h - java.util.Map
parameterName - java.lang.String
Returns:
java.lang.Object
Throws:
ParameterNotFoundException

endTag

public static java.lang.String endTag(java.lang.String tagName)
Return the XML end tag with tag name included.
Parameters:
tagName - java.lang.String
Returns:
java.lang.String

isBlank

public 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.
Parameters:
s - The String to check.
Returns:
true if the s parameter is empty; false otherwise.

isValidDate

public static boolean isValidDate(java.lang.String s)
Returns true if the string is valid date or isBlank(String); false otherwise.
Parameters:
s - String to validate
Returns:
true if the date is valid

isValidDateFormat

public static boolean isValidDateFormat(java.lang.String format)
Tests if the date format pattern specified is valid.
Parameters:
format - The format string to test.
Returns:
true if the format parameter contains a valid formatting string; false otherwise.

isValidTime

public static boolean isValidTime(java.lang.String s)
Returns true if the string is valid date or isBlank(String); false otherwise.
Parameters:
s - String to validate
Returns:
true if the date is valid

isValidTimestamp

public static boolean isValidTimestamp(java.lang.String s)
Returns true if the string is valid date or isBlank(String); false otherwise.
Parameters:
s - String to validate
Returns:
true if the date is valid

normalizeDatetime

public 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.
Parameters:
s - String to normalize
Returns:
java.lang.String a right format of date-time

replaceSubstring

public 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.
Parameters:
str - The original string
substr1 - The substring to be replaced (all occurences of it)
substr2 - The substring that is inserted in place of substr1
startFromLocation - The starting location in str (if the whole string put 0)
Returns:
A new string where all occurences of substr1 are replaced with substr1 starting at given location of str.

requireParameterNotNull

public static final 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.
Parameters:
className - java.lang.String
methodName - java.lang.String
parameterName - java.lang.String
object - java.lang.Object

spacesToUnderscores

public 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
Parameters:
s - String to convert
Returns:
java.lang.String

startTag

public static java.lang.String startTag(java.lang.String tagName)
Return a XML start tag with given tag name.
Parameters:
tagName - java.lang.String
Returns:
java.lang.String

stringToDate

public static java.sql.Date stringToDate(java.lang.String s)
                                  throws java.text.ParseException
Converts a 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.
Parameters:
s - String to parse
Returns:
the Date parsed or null
Throws:
java.text.ParseException - thrown if s is improperly formatted.

stringToDate

public static java.sql.Date stringToDate(java.lang.String s,
                                         java.lang.String format)
                                  throws java.text.ParseException
Converts a String to a Dateusing the given format. An isBlank(String) String is converted to a null Date.
Parameters:
s - String to parse
format - Format to use
Returns:
the Date parsed or null
Throws:
java.text.ParseException - if s is improperly formatted.
java.lang.IllegalArgumentException - if the format specified by format is invalid.

stringToTime

public static java.sql.Time stringToTime(java.lang.String s)
                                  throws java.text.ParseException
Converts a 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.
Parameters:
s - String to parse
Returns:
the Time parsed or null
Throws:
java.text.ParseException - thrown if s is improperly formatted.

stringToTime

public static java.sql.Time stringToTime(java.lang.String s,
                                         java.lang.String format)
                                  throws java.text.ParseException
Converts a String to a Timeusing the given format. An isBlank(String) String is converted to a null Time.
Parameters:
s - String to parse
format - Format to use
Returns:
the Time parsed or null
Throws:
java.text.ParseException - if s is improperly formatted.
java.lang.IllegalArgumentException - if the format specified by format is invalid.

stringToTimestamp

public static java.sql.Timestamp stringToTimestamp(java.lang.String s)
                                            throws java.text.ParseException
Converts a 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.
Parameters:
s - String to parse
Returns:
the Timestamp parsed or null
Throws:
java.text.ParseException - thrown if s is improperly formatted.

stringToTimestamp

public static java.sql.Timestamp stringToTimestamp(java.lang.String s,
                                                   java.lang.String format)
                                            throws java.text.ParseException
Converts a String to a Timestampusing the given format. An isBlank(String) String is converted to a null Timestamp.
Parameters:
s - String to parse
format - Format to use
Returns:
the Timestamp parsed or null
Throws:
java.text.ParseException - if s is improperly formatted.
java.lang.IllegalArgumentException - if the format specified by format is invalid.

stringToTimestamp

public static java.sql.Timestamp stringToTimestamp(java.lang.String s,
                                                   java.lang.String format,
                                                   java.util.Locale lcl)
                                            throws java.text.ParseException
Converts a String to a Timestampusing the given format and lcl. An isBlank(String) String is converted to a null Timestamp.
Parameters:
s - String to parse
format - java.lang.String
lcl - java.lang.Locale
Returns:
the Timestamp parsed or null
Throws:
java.text.ParseException - if s is improperly formatted.
java.lang.IllegalArgumentException - if the format specified by format is invalid.

timestampToString

public static java.lang.String timestampToString(java.sql.Timestamp date)
Returns the date as a String formatted by the default format displayDateFormat. A null date is converted to a null String.
Parameters:
date - Date
Returns:
date formatted by the default format displayDateFormat or null.

timestampToString

public 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.
Parameters:
date - Date
format - format to use
Returns:
A formatted String, or null if the date parameter is null.
Throws:
java.lang.IllegalArgumentException - An exception will be thrown if the format specified by the format parameter is invalid.

timestampToString

public static java.lang.String timestampToString(java.util.Date date)
Returns the date as a String formatted by the default format displayDateFormat. A null date is converted to a null String.
Parameters:
date - Date
Returns:
date formatted by the default format displayDateFormat or null.

timestampToString

public 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.
Parameters:
date - Date
format - format to use
Returns:
A formatted String, or null if the date parameter is null.
Throws:
java.lang.IllegalArgumentException - An exception will be thrown if the format specified by the format parameter is invalid.

timestampToString

public 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.
Parameters:
date - Date
format - format to use
lcl - java.util.Locale
Returns:
A formatted String, or null if the date parameter is null.
Throws:
java.lang.IllegalArgumentException - An exception will be thrown if the format specified by the format parameter is invalid.

timeToString

public static java.lang.String timeToString(java.sql.Time time)
Returns the date as a String formatted by the default format displayDateFormat. A null date is converted to a null String.
Returns:
date formatted by the default format displayDateFormat or null.

timeToString

public 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.
Parameters:
format - format to use
Returns:
A formatted String, or null if the date parameter is null.
Throws:
java.lang.IllegalArgumentException - An exception will be thrown if the format specified by the format parameter is invalid.

toBoolean

public static boolean toBoolean(java.lang.Object value)
Convert Object into a boolean primitive type
Parameters:
value - java.lang.Object
Returns:
a boolean value

toBoolean

public static boolean toBoolean(java.lang.String value)
Convert String into a boolean primitive type
Parameters:
value - java.lang.String
Returns:
a boolean value

toInt

public static int toInt(java.lang.Object value)
Convert Object into an int primitive type
Parameters:
value - java.lang.Object
Returns:
an int value

toInt

public static int toInt(java.lang.String value)
Convert String into an int primitive type
Parameters:
value - java.lang.String
Returns:
an int value

toReversedVector

public static java.util.Vector toReversedVector(java.util.Vector originalVector)
This method is using to reverse the order of Vector's objects.
Returns:
reversed Vecter java.util.Vector

toVector

public static java.util.Vector toVector(java.lang.Object value)
This method will convert an Object type of vector into a Vector type.
Parameters:
value - java.lang.Object
Returns:
java.util.Vector

getCatEntryId

public java.lang.String getCatEntryId(java.lang.String partNumber,
                                      java.lang.String dN)
                               throws ECException
Return catentry id in string type by passing its unique index.
Parameters:
partNumber - java.lang.String
dN - java.lang.String
Returns:
catentryId java.lang.String
Throws:
ECException

getShipModeId

public java.lang.String getShipModeId(java.lang.String code,
                                      java.lang.String carrier,
                                      java.lang.String storeName,
                                      java.lang.String ownerDN)
                               throws ECException
Return ship mode id in string type by passing its unique index. code, carrier, store Identifier, org DN,
Parameters:
code - java.lang.String
carrier - java.lang.String
storeName - java.lang.String
ownerDN - java.lang.String
Returns:
shipmodeId java.lang.String
Throws:
FinderException
java.rmi.RemoteException
javax.naming.NamingException
CreateException
ECException

getSKU

public java.lang.String getSKU(java.lang.String catentry_id)
                        throws ECException
Return sku String in string type by passing its catentry_id
Parameters:
catentry_id - java.lang.String
Returns:
sku java.lang.String
Throws:
ECException

getSKUType

public java.lang.String getSKUType(java.lang.String catentry_id)
                            throws ECException
Returns skuTpe String in string type by passing its catentry_id
Parameters:
catentry_id - java.lang.String
Returns:
skuType java.lang.String
Throws:
ECException

getSKUName

public java.lang.String getSKUName(java.lang.String langId,
                                   java.lang.String catentry_id)
                            throws ECException
Returns skuName String in string type by passing its catentry_id
Parameters:
langId - java.lang.String
catentry_id - java.lang.String
Returns:
skuName java.lang.String
Throws:
ECException

getSKUs

public java.util.Vector getSKUs(java.util.Vector catentryIds)
                         throws ECException
Returns sku Vector in by passing its catentry_id vector
Returns:
catEntryIds java.util.Vector
Throws:
ECException

getCatGroupId

public java.lang.String getCatGroupId(java.lang.String identifier,
                                      java.lang.String dN)
                               throws ECException
Returns category id in string type by passing its unique index.
Parameters:
identifier - java.lang.String
dN - java.lang.String
Returns:
categoryId java.lang.String
Throws:
ECException

getCategoryName

public java.lang.String getCategoryName(java.lang.String storeId,
                                        java.lang.String langId,
                                        java.lang.String catIdentifier)
                                 throws ECException
Returns category name in string type by passing its store Id.language Id and identifier
Parameters:
storeId - java.lang.String
langId - java.lang.String
catIdentifier - java.lang.String
Returns:
categoryName java.lang.String
Throws:
ECException

isCep

public boolean isCep()
This method checks if current release of product used is CEP. Returns true if CEP else returns false
Returns:
boolean