Package org.openxava.util
Class XObjects
java.lang.Object
org.openxava.util.XObjects
Utility class to work with objects.
- Since:
- 4.4, until 4.3 it was named Objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectClone the sent object.static ObjectDoes an deep clone of the sent object.static ObjectAllows to execute dinamically (as in SmallTalk) an static method of an class.static ObjectAllows to execute dinamically (as in SmallTalk) an static method of an class.static Objectexecute(Class theClass, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2) Allows to execute dinamically (as in SmallTalk) an static method of an class.static ObjectAllows to execute dinamically (as in SmallTalk) an method of an object.static ObjectAllows to execute dinamically (as in SmallTalk) an method of an object.static Objectexecute(Object o, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2) Allows to execute dinamically (as in SmallTalk) an method of an object.static Objectexecute(Object o, String methodName, Class argumentClass1, Object arg1, Class argumentClass2, Object arg2, Class argumentClass3, Object arg3) Allows to execute dinamically (as in SmallTalk) an method of an object.static ObjectTry to clone the sent object.
-
Constructor Details
-
XObjects
public XObjects()
-
-
Method Details
-
clone
Clone the sent object.The clone is done using the method
clone()of the sent object if this implementsCloneable- Throws:
CloneNotSupportedException- If the object is not Cloneable.
-
deepClone
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 implementsCloneable.- Returns:
- Clone of the sent object. Does an clon of all levels, complete, deep.
- Throws:
CloneException- Any problem on cloning.
-
execute
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
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
Try to clone the sent object.If it does not win it, then return the original element.
The clone is done using the methodclone()of the sent object, if it implementsCloneable.
-