Class ConvertUtils

java.lang.Object
com.webmethods.caf.faces.convert.ConvertUtils

public class ConvertUtils extends Object
Helper functions for converting values.
  • Constructor Details

    • ConvertUtils

      public ConvertUtils()
  • Method Details

    • isTrue

      public static boolean isTrue(Object o)
      True if o is Boolean.TRUE or "true" or "TRUE". False if o is null or any other value.
    • isFalse

      public static boolean isFalse(Object o)
      True if o is Boolean.FALSE or "false" or "FALSE". False if o is null or any other value.
    • toString

      public static String toString(Object o)
      Converts o to a string. If o is null, returns empty string ("").
    • toString

      public static String toString(FacesContext context, UIComponent component, Object value) throws ConverterException
      Converts specified component value to a string, using component's converter. Nulls are converted to empty strings ("").
      Parameters:
      context - Current context.
      component - Component for which to conver the value.
      value - Value to convert.
      Returns:
      String representation of value.
      Throws:
      ConverterException
    • isEmpty

      public static boolean isEmpty(String s)
      True if s is null or empty string (""); false otherwise.
    • intValue

      public static int intValue(Object o, int defaultValue)
      Converts o to an int. If o is null or not convertable, returns defaultValue.
    • doubleValue

      public static double doubleValue(Object o, double defaultValue)
      Converts o to a double. If o is null or not convertable, returns defaultValue.
    • isPrimitiveType

      public static boolean isPrimitiveType(String type)
      True if type name is a primitive type (ie "boolean").
    • getPrimitiveType

      public static Class<?> getPrimitiveType(String type)
      Gets class for primitive type name (ie Boolean for "boolean").
    • getLocalFromToString

      public static Locale getLocalFromToString(String sLocale)
      Convert an Locale.toString() text to a Locale Object.
      Parameters:
      sLocale - from a Locale.toString() output.
      Returns:
      a Locale Object. Throws NullPointerException if input is null.