Class XObjects

java.lang.Object
org.openxava.util.XObjects

public class XObjects extends Object
Utility class to work with objects.

Since:
4.4, until 4.3 it was named Objects.
  • Constructor Details

    • XObjects

      public XObjects()
  • Method Details

    • clone

      public static Object clone(Object o) throws CloneNotSupportedException
      Clone the sent object.

      The clone is done using the method clone() of the sent object if this implements Cloneable

      Throws:
      CloneNotSupportedException - If the object is not Cloneable.
    • deepClone

      public static Object deepClone(Object source) throws CloneException
      Does an deep clone of the sent object.

      If the argument is null, then returns null.

      Parameters:
      source - Must be serializable. It's not necessary that it implements Cloneable.
      Returns:
      Clone of the sent object. Does an clon of all levels, complete, deep.
      Throws:
      CloneException - Any problem on cloning.
    • execute

      public static Object execute(Object o, String methodName) throws Exception
      Allows to execute dinamically (as in SmallTalk) an method of an object.

      Parameters:
      o - Object where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target object.
    • execute

      public static Object execute(Object o, String methodName, Class argumentClass, Object arg) throws Exception
      Allows to execute dinamically (as in SmallTalk) an method of an object.

      Parameters:
      o - Object where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      argumentClass - Not null.
      arg - Argument value. It can be null.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target object.
    • execute

      public static Object execute(Object o, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2) throws Exception
      Allows to execute dinamically (as in SmallTalk) an method of an object.

      Parameters:
      o - Object where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      argumentClass1 - Not null.
      arg1 - Argument value. It can be null.
      argumentClass2 - Not null.
      arg2 - Argument value. It can be null.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target object.
    • execute

      public static Object execute(Object o, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2, Class argumentClass3, Object arg3) throws Exception
      Allows to execute dinamically (as in SmallTalk) an method of an object.

      Parameters:
      o - Object where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      argumentClass1 - Not null.
      arg1 - Argument value. It can be null.
      argumentClass2 - Not null.
      arg2 - Argument value. It can be null.
      argumentClass3 - Not null.
      arg3 - Argument value. It can be null.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target object.
    • execute

      public static Object execute(Class theClass, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2) throws Exception
      Allows to execute dinamically (as in SmallTalk) an static method of an class.

      Parameters:
      theClass - The class where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      argumentClass1 - Not null.
      arg1 - Argument value. It can be null.
      argumentClass2 - Not null.
      arg2 - Argument value. It can be null.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target class.
    • execute

      public static Object execute(Class theClass, String methodName, Class argumentClass, Object arg) throws Exception
      Allows to execute dinamically (as in SmallTalk) an static method of an class.

      Parameters:
      theClass - The class where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      argumentClass - Not null.
      arg - Argument value. It can be null.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target class.
    • execute

      public static Object execute(Class theClass, String methodName) throws Exception
      Allows to execute dinamically (as in SmallTalk) an static method of an class.

      Parameters:
      theClass - The class where the method will be executed. It cannot be null.
      methodName - Name of the method to execute.
      Returns:
      Result of method execution.
      Throws:
      Exception - Any problem, including exceptions from target method.
      NoSuchMethodException - If the method does not exist in target class.
    • tryClone

      public static Object tryClone(Object o)
      Try to clone the sent object.

      If it does not win it, then return the original element.
      The clone is done using the method clone() of the sent object, if it implements Cloneable.