Class ObjectType

java.lang.Object
org.ofbiz.core.util.ObjectType

public class ObjectType extends Object
Utilities for analyzing and converting Object types in Java - takes advantage of a lot of reflection and other stuff
Since:
2.0
Version:
$Revision: 1.1 $
Author:
Andy Zeneski, David E. Jones, Rene Gielen
  • Field Details

  • Constructor Details

    • ObjectType

      public ObjectType()
  • Method Details

    • loadClass

      public static Class<?> loadClass(String className) throws ClassNotFoundException
      Loads a class with the current thread's context classloader
      Parameters:
      className - The name of the class to load
      Throws:
      ClassNotFoundException
    • loadClass

      public static Class<?> loadClass(String className, ClassLoader loader) throws ClassNotFoundException
      Loads a class with the current thread's context classloader
      Parameters:
      className - The name of the class to load
      Throws:
      ClassNotFoundException
    • getInstance

      public static Object getInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException
      Returns an instance of the specified class
      Parameters:
      className - Name of the class to instantiate
      Throws:
      ClassNotFoundException
      InstantiationException
      IllegalAccessException
    • interfaceOf

      public static boolean interfaceOf(Object obj, String interfaceName) throws ClassNotFoundException
      Tests if an object properly implements the specified interface
      Parameters:
      obj - Object to test
      interfaceName - Name of the interface to test against
      Throws:
      ClassNotFoundException
    • interfaceOf

      public static boolean interfaceOf(Object obj, Object interfaceObject)
      Tests if an object properly implements the specified interface
      Parameters:
      obj - Object to test
      interfaceObject - to test against
    • interfaceOf

      public static boolean interfaceOf(Object obj, Class<?> interfaceClass)
      Tests if an object properly implements the specified interface
      Parameters:
      obj - Object to test
      interfaceClass - Class to test against
    • isOrSubOf

      public static boolean isOrSubOf(Object obj, String parentName) throws ClassNotFoundException
      Tests if an object is an instance of or a sub-class of the parent
      Parameters:
      obj - Object to test
      parentName - Name of the parent class to test against
      Throws:
      ClassNotFoundException
    • isOrSubOf

      public static boolean isOrSubOf(Object obj, Object parentObject)
      Tests if an object is an instance of or a sub-class of the parent
      Parameters:
      obj - Object to test
      parentObject - Object to test against
    • isOrSubOf

      public static boolean isOrSubOf(Object obj, Class<?> parentClass)
      Tests if an object is an instance of or a sub-class of the parent
      Parameters:
      obj - Object to test
      parentClass - Class to test against
    • instanceOf

      public static boolean instanceOf(Object obj, Object typeObject)
      Tests if an object is an instance of a sub-class of or properly implements an interface
      Parameters:
      obj - Object to test
      typeObject - Object to test against
    • instanceOf

      public static boolean instanceOf(Object obj, String typeName)
      Tests if an object is an instance of a sub-class of or properly implements an interface
      Parameters:
      obj - Object to test
      typeName - Type Name to test against
    • instanceOf

      public static boolean instanceOf(Object obj, String typeName, ClassLoader loader)
      Tests if an object is an instance of a sub-class of or properly implements an interface
      Parameters:
      obj - Object to test
      typeName - Type Name to test against
    • instanceOf

      public static boolean instanceOf(Object obj, Class<?> typeClass)
      Tests if an object is an instance of a sub-class of or properly implements an interface
      Parameters:
      obj - Object to test
      typeClass - Class to test against
    • simpleTypeConvert

      public static Object simpleTypeConvert(Object obj, String type, String format, Locale locale) throws GeneralException
      Converts the passed object to the named simple type; supported types include: String, Boolean, Double, Float, Long, Integer, Date (java.sql.Date), Time, Timestamp;
      Parameters:
      obj - Object to convert
      type - Name of type to convert to
      format - Optional (can be null) format string for Date, Time, Timestamp
      locale - Optional (can be null) Locale for formatting and parsing Double, Float, Long, Integer
      Throws:
      GeneralException
    • doRealCompare

      public static Boolean doRealCompare(Object value1, Object value2, String operator, String type, String format, List<String> messages, Locale locale, ClassLoader loader)