Class ObjectUtils


  • public final class ObjectUtils
    extends java.lang.Object
    Property utilities
    Version:
    $Id: ObjectUtils.java,v 1.2 2004/08/26 12:33:17 thlee Exp $ $Name: $
    Author:
    TiongHiang Lee (thlee@onemindsoft.org)
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ObjectUtils()
      Constructor
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean toBool​(java.lang.Object value, boolean def)
      Convert the object the boolean, return the default if it cannot be converted
      static double toDouble​(java.lang.Object value, double def)
      Convert the object to double, or return the default if it cannot be converted
      static float toFloat​(java.lang.Object value, float def)
      Convert the object to float, or return the default if it cannot be converted
      static int toInt​(java.lang.Object value, int def)
      Convert the object to int, or return the default if it cannot be converted
      static long toLong​(java.lang.Object value, long def)
      Convert the object to long, or return the default if it cannot be converted
      • Methods inherited from class java.lang.Object

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

      • ObjectUtils

        private ObjectUtils()
        Constructor
    • Method Detail

      • toBool

        public static final boolean toBool​(java.lang.Object value,
                                           boolean def)
        Convert the object the boolean, return the default if it cannot be converted
        Parameters:
        value - the value
        def - the default
        Returns:
        the converted value, or def if value is null
      • toInt

        public static int toInt​(java.lang.Object value,
                                int def)
        Convert the object to int, or return the default if it cannot be converted
        Parameters:
        value - the value
        def - the default
        Returns:
        the converted int, or default if it cannot be converted
      • toLong

        public static long toLong​(java.lang.Object value,
                                  long def)
        Convert the object to long, or return the default if it cannot be converted
        Parameters:
        value - the value
        def - the default
        Returns:
        the converted int, or default if it cannot be converted
      • toFloat

        public static float toFloat​(java.lang.Object value,
                                    float def)
        Convert the object to float, or return the default if it cannot be converted
        Parameters:
        value - the value
        def - the default
        Returns:
        the converted int, or default if it cannot be converted
      • toDouble

        public static double toDouble​(java.lang.Object value,
                                      double def)
        Convert the object to double, or return the default if it cannot be converted
        Parameters:
        value - the value
        def - the default
        Returns:
        the converted int, or default if it cannot be converted