Class XObjects


  • public class XObjects
    extends java.lang.Object
    Utility class to work with objects.

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

      Constructors 
      Constructor Description
      XObjects()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object clone​(java.lang.Object o)
      Clone the sent object.
      static java.lang.Object deepClone​(java.lang.Object source)
      Does an deep clone of the sent object.
      static java.lang.Object execute​(java.lang.Class theClass, java.lang.String methodName)
      Allows to execute dinamically (as in SmallTalk) an static method of an class.
      static java.lang.Object execute​(java.lang.Class theClass, java.lang.String methodName, java.lang.Class argumentClass, java.lang.Object arg)
      Allows to execute dinamically (as in SmallTalk) an static method of an class.
      static java.lang.Object execute​(java.lang.Class theClass, java.lang.String methodName, java.lang.Class argumentClass1, java.lang.Object arg1, java.lang.Class argumentClass2, java.lang.Object arg2)
      Allows to execute dinamically (as in SmallTalk) an static method of an class.
      static java.lang.Object execute​(java.lang.Object o, java.lang.String methodName)
      Allows to execute dinamically (as in SmallTalk) an method of an object.
      static java.lang.Object execute​(java.lang.Object o, java.lang.String methodName, java.lang.Class argumentClass, java.lang.Object arg)
      Allows to execute dinamically (as in SmallTalk) an method of an object.
      static java.lang.Object execute​(java.lang.Object o, java.lang.String methodName, java.lang.Class argumentClass1, java.lang.Object arg1, java.lang.Class argumentClass2, java.lang.Object arg2)
      Allows to execute dinamically (as in SmallTalk) an method of an object.
      static java.lang.Object execute​(java.lang.Object o, java.lang.String methodName, java.lang.Class argumentClass1, java.lang.Object arg1, java.lang.Class argumentClass2, java.lang.Object arg2, java.lang.Class argumentClass3, java.lang.Object arg3)
      Allows to execute dinamically (as in SmallTalk) an method of an object.
      static java.lang.Object tryClone​(java.lang.Object o)
      Try to clone the sent object.
      • Methods inherited from class java.lang.Object

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

      • XObjects

        public XObjects()
    • Method Detail

      • clone

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

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

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

        public static java.lang.Object deepClone​(java.lang.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 java.lang.Object execute​(java.lang.Object o,
                                               java.lang.String methodName)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target object.
      • execute

        public static java.lang.Object execute​(java.lang.Object o,
                                               java.lang.String methodName,
                                               java.lang.Class argumentClass,
                                               java.lang.Object arg)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target object.
      • execute

        public static java.lang.Object execute​(java.lang.Object o,
                                               java.lang.String methodName,
                                               java.lang.Class argumentClass1,
                                               java.lang.Object arg1,
                                               java.lang.Class argumentClass2,
                                               java.lang.Object arg2)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target object.
      • execute

        public static java.lang.Object execute​(java.lang.Object o,
                                               java.lang.String methodName,
                                               java.lang.Class argumentClass1,
                                               java.lang.Object arg1,
                                               java.lang.Class argumentClass2,
                                               java.lang.Object arg2,
                                               java.lang.Class argumentClass3,
                                               java.lang.Object arg3)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target object.
      • execute

        public static java.lang.Object execute​(java.lang.Class theClass,
                                               java.lang.String methodName,
                                               java.lang.Class argumentClass1,
                                               java.lang.Object arg1,
                                               java.lang.Class argumentClass2,
                                               java.lang.Object arg2)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target class.
      • execute

        public static java.lang.Object execute​(java.lang.Class theClass,
                                               java.lang.String methodName,
                                               java.lang.Class argumentClass,
                                               java.lang.Object arg)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target class.
      • execute

        public static java.lang.Object execute​(java.lang.Class theClass,
                                               java.lang.String methodName)
                                        throws java.lang.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:
        java.lang.Exception - Any problem, including exceptions from target method.
        java.lang.NoSuchMethodException - If the method does not exist in target class.
      • tryClone

        public static java.lang.Object tryClone​(java.lang.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.