Class ParameterValidationUtil


  • public class ParameterValidationUtil
    extends java.lang.Object
    Validates the parameter value with the given data type and format pattern string. This util class can validate the parameter of the following types:
    • PARAM_TYPE_DATETIME
    • PARAM_TYPE_FLOAT
    • PARAM_TYPE_DECIMAL
    • PARAM_TYPE_BOOLEAN
    • PARAM_TYPE_STRING
    • PARAM_TYPE_INTEGER
    • PARAM_TYPE_DATE
    • PARAM_TYPE_TIME
    See Also:
    DesignChoiceConstants
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getDisplayValue​(java.lang.Object value)
      Gets the display string for the value with default locale and default format, The value must be the valid data type.
      static java.lang.String getDisplayValue​(java.lang.Object value, com.ibm.icu.util.TimeZone timeZone)
      Gets the display string for the value with default locale and default format, The value must be the valid data type.
      static java.lang.String getDisplayValue​(java.lang.String dataType, java.lang.String format, java.lang.Object value)
      Gets the display string for the value with the given data type, format and the default locale defined by the class(Locale.US).
      static java.lang.String getDisplayValue​(java.lang.String dataType, java.lang.String format, java.lang.Object value, com.ibm.icu.util.ULocale locale)
      Gets the display string for the value with the given data type, format, locale.
      static java.lang.String getDisplayValue​(java.lang.String dataType, java.lang.String format, java.lang.Object value, com.ibm.icu.util.ULocale locale, com.ibm.icu.util.TimeZone timeZone)
      Gets the display string for the value with the given data type, format, locale.
      static java.lang.String getDisplayValue​(java.lang.String dataType, java.lang.String format, java.lang.Object value, java.util.Locale locale)
      Gets the display string for the value with the given data type, format, locale.
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value)
      Validates a input parameter value with the given data type, format choice string and a default locale defined by the class(Locale.US).
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value, com.ibm.icu.util.TimeZone timeZone)
      Validates a input parameter value with the given data type, format choice string, using the default locale.
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value, com.ibm.icu.util.ULocale locale)
      Validates a input parameter value with the given data type, format choice string.
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value, com.ibm.icu.util.ULocale locale, com.ibm.icu.util.TimeZone timeZone)
      Validates a input parameter value with the given data type, format choice string.
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value, java.util.Locale locale)
      Validates a input parameter value with the given data type, format choice string.
      static java.lang.Object validate​(java.lang.String dataType, java.lang.String format, java.lang.String value, java.util.Locale locale, com.ibm.icu.util.TimeZone timeZone)
      Validates a input parameter value with the given data type, format choice string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_DATETIME_FORMAT

        public static final java.lang.String DEFAULT_DATETIME_FORMAT
        Default date-time format string.
        See Also:
        Constant Field Values
      • DEFAULT_DATE_FORMAT

        public static final java.lang.String DEFAULT_DATE_FORMAT
        See Also:
        Constant Field Values
      • DEFAULT_TIME_FORMAT

        public static final java.lang.String DEFAULT_TIME_FORMAT
        See Also:
        Constant Field Values
      • DISPLAY_DATE_FORMAT

        public static final java.lang.String DISPLAY_DATE_FORMAT
        See Also:
        Constant Field Values
      • DISPLAY_TIME_FORMAT

        public static final java.lang.String DISPLAY_TIME_FORMAT
        See Also:
        Constant Field Values
    • Constructor Detail

      • ParameterValidationUtil

        public ParameterValidationUtil()
    • Method Detail

      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value,
                                                java.util.Locale locale)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string. The returned value is locale and pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        locale - the locale information
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value,
                                                java.util.Locale locale,
                                                com.ibm.icu.util.TimeZone timeZone)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string. The returned value is locale and pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        locale - the locale information
        timeZone - the time zone information
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value,
                                                com.ibm.icu.util.TimeZone timeZone)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string, using the default locale. The returned value is locale and pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        timeZone - the time zone information
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value,
                                                com.ibm.icu.util.ULocale locale)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string. The returned value is locale and pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        locale - the locale information
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value,
                                                com.ibm.icu.util.ULocale locale,
                                                com.ibm.icu.util.TimeZone timeZone)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string. The returned value is locale and pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        locale - the locale information
        timeZone - the time zone information (only valid for DateTime type)
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • validate

        public static java.lang.Object validate​(java.lang.String dataType,
                                                java.lang.String format,
                                                java.lang.String value)
                                         throws ValidationValueException
        Validates a input parameter value with the given data type, format choice string and a default locale defined by the class(Locale.US). The returned value is pattern dependent. The data type and the format can be one pair of the following:

        Data Type Format Type
        Float/Decimal
        • General Number
        • Currency
        • Fixed
        • Percent
        • Scientific
        • Standard
        • pattern string, such as "###,##0", "###,##0.00 'm/s'", "###.#\';';#" and so on.
        Date time
        • General Date
        • Long Date
        • Medium Date
        • Short Date
        • Long Time
        • Medium Time
        • Short Time
        • pattern string, such as "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss" and so on.
        String
        • Upper case
        • Lower case
        • pattern string, such as "lt!" and so on.
        Parameters:
        dataType - the data type of the value
        format - the format choice string
        value - the input value to validate
        Returns:
        the validated value if the input value is valid for the given data type and format choice string
        Throws:
        ValidationValueException - if the input value is not valid with the given data type and format string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.String dataType,
                                                       java.lang.String format,
                                                       java.lang.Object value,
                                                       java.util.Locale locale)
        Gets the display string for the value with the given data type, format, locale. The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        dataType - the data type of the input value
        format - the format pattern to validate
        value - the input value to validate
        locale - the locale information
        Returns:
        the formatted string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.Object value)
        Gets the display string for the value with default locale and default format, The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        value - the input value to validate
        Returns:
        the formatted string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.Object value,
                                                       com.ibm.icu.util.TimeZone timeZone)
        Gets the display string for the value with default locale and default format, The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        value - the input value to validate
        timeZone - the time zone to use (only for DateTime type)
        Returns:
        the formatted string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.String dataType,
                                                       java.lang.String format,
                                                       java.lang.Object value,
                                                       com.ibm.icu.util.ULocale locale)
        Gets the display string for the value with the given data type, format, locale. The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        dataType - the data type of the input value
        format - the format pattern to validate
        value - the input value to validate
        locale - the locale information
        Returns:
        the formatted string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.String dataType,
                                                       java.lang.String format,
                                                       java.lang.Object value,
                                                       com.ibm.icu.util.ULocale locale,
                                                       com.ibm.icu.util.TimeZone timeZone)
        Gets the display string for the value with the given data type, format, locale. The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        dataType - the data type of the input value
        format - the format pattern to validate
        value - the input value to validate
        locale - the locale information
        Returns:
        the formatted string
      • getDisplayValue

        public static java.lang.String getDisplayValue​(java.lang.String dataType,
                                                       java.lang.String format,
                                                       java.lang.Object value)
        Gets the display string for the value with the given data type, format and the default locale defined by the class(Locale.US). The value must be the valid data type. That is:
        • if data type is PARAM_TYPE_DATETIME, then the value must be java.util.Date.
        • if the data type is PARAM_TYPE_FLOAT, then the value must be java.lang.Double.
        • if the data type is PARAM_TYPE_DECIMAL, then the value must be java.math.BigDecimal.
        • if the data type is PARAM_TYPE_BOOLEAN, then the value must be java.lang.Boolean.
        • if the data type is PARAM_TYPE_STRING, then the value must be java.lang.String.
        Parameters:
        dataType - the data type of the input value
        format - the format pattern to validate
        value - the input value to validate
        Returns:
        the formatted string