|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.ObjectUtil
public class ObjectUtil
Outils pour manipuler des objets. Création d'un objet à partir d'une chaîne le décrivant, conversion d'un objet en Object, récupération de méthodes à partir de leur nom, de constructeurs à partir de leurs paramètres...
Created: 4 novembre 2004
| Field Summary | |
|---|---|
protected static Integer |
ZERO
|
protected static Byte |
ZEROB
|
protected static Character |
ZEROC
|
protected static Double |
ZEROD
|
protected static Float |
ZEROF
|
protected static Long |
ZEROL
|
| Method Summary | ||
|---|---|---|
static Object |
call(Object o,
Method m,
String... params)
Call method m with params as String. |
|
protected static Object |
choiceArgument(Class<?> clazz,
List args,
boolean nullIfMissing)
Permet de matcher un type d'argument attendu clazz parmi un ensemble possible de candidat. |
|
static
|
clone(E e)
Clone object by introspection because Cloneable interface don't permit to call clone :(. |
|
protected static Object |
convert(String v,
Class<?> clazz)
|
|
static Object |
create(String classnameAndProperties)
Create new object from string like org.nuiton.Toto(name=machine, int=10) where machine and int is properties on org.nuiton.Toto object. |
|
static
|
deepClone(E e)
Use serialization/deserialization to do deep clone of object |
|
static
|
getConstructor(Class<T> clazz,
int paramNumber)
Get all constructors that support paramNumber as parameters numbers. |
|
static List<Method> |
getMethod(Class<?> clazz,
String methodName,
boolean ignoreCase)
Get all methods with name given in argument without check parameters. |
|
static Object |
getNullValue(Class<?> type)
Obtains the null value for the given type (works too with primitive types). |
|
static Class<?> |
getPrimitiveClass(Class<?> clazz)
Retourne la classe du type primitf associé avec la classe de de l'objet passé en parametre. |
|
static boolean |
isNullValue(boolean value)
|
|
static boolean |
isNullValue(byte value)
|
|
static boolean |
isNullValue(char value)
|
|
static boolean |
isNullValue(double value)
|
|
static boolean |
isNullValue(float value)
|
|
static boolean |
isNullValue(int value)
|
|
static boolean |
isNullValue(Object value)
Tests if the given value is null according to default value for primitive types if nedded. |
|
static boolean |
isPrimitive(Class<?> clazz)
Verifie si la classe est de type primitif. |
|
static
|
newInstance(Class<E> clazz,
Collection<?> args,
boolean nullIfMissing)
Invoke constructor on clazz to create new instance. |
|
static
|
newInstance(Class<T> clazz,
String... params)
Create new instance of clazz, call constructor with params as String. |
|
static Object |
newInstance(String constructorWithParams)
|
|
static Object |
toObject(boolean b)
Method toObject transform a boolean to a Boolean object |
|
static Object |
toObject(byte b)
Method toObject transform a byte to a Byte Object |
|
static Object |
toObject(char c)
Method toObject transform a char to a Character Object |
|
static Object |
toObject(double d)
Method toObject transform a double to a Double object |
|
static Object |
toObject(float f)
Method toObject transform a float to a Float Object |
|
static Object |
toObject(int i)
Method toObject transform an int to an Integer object |
|
static Object |
toObject(long l)
Method toObject transform a long to a Long object |
|
static Object |
toObject(Object o)
Method toObject |
|
static Object |
toObject(short s)
Method toObject transform a short to a Short object |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Integer ZERO
protected static final Character ZEROC
protected static final Float ZEROF
protected static final Long ZEROL
protected static final Double ZEROD
protected static final Byte ZEROB
| Method Detail |
|---|
public static <E> E newInstance(Class<E> clazz,
Collection<?> args,
boolean nullIfMissing)
clazz - class of object to instanciateargs - all possible parameter that constructor can usednullIfMissing - if no suitable class or object found in args,
use null value (no exception)
IllegalArgumentException - if something is wrong during instanciation
protected static Object choiceArgument(Class<?> clazz,
List args,
boolean nullIfMissing)
clazz - le type recherchéargs - la liste des arguments ou des typesnullIfMissing - pour retourner nulle si l'argument n'est pas trouvé
public static Object create(String classnameAndProperties)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchMethodException
classnameAndProperties -
ClassNotFoundException
IllegalAccessException
InstantiationException
NoSuchMethodException
InvocationTargetException
protected static Object convert(String v,
Class<?> clazz)
public static <E extends Cloneable> E clone(E e)
throws CloneNotSupportedException
if (o instanceof Cloneable) {
Object n = ((Cloneable)o).clone();
}
e - object to clone
CloneNotSupportedException - if some error occur during clone
public static <E> E deepClone(E e)
throws CloneNotSupportedException
e - object to clone
CloneNotSupportedException - if some error occur during clone
public static Object call(Object o,
Method m,
String... params)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
InstantiationException
o - object where method must be callm - method to callparams - parameters for method call
IllegalAccessException
IllegalArgumentException
InvocationTargetException
InstantiationException
public static List<Method> getMethod(Class<?> clazz,
String methodName,
boolean ignoreCase)
clazz - where to search methodmethodName - method name to searchignoreCase - if true, ignore difference in method name case
public static Object newInstance(String constructorWithParams)
throws ClassNotFoundException
ClassNotFoundException
public static <T> T newInstance(Class<T> clazz,
String... params)
throws IllegalArgumentException
T - type to instanciateclazz - class to instanciateparams - parameters for constructor call
IllegalArgumentException
public static <T> List<Constructor<T>> getConstructor(Class<T> clazz,
int paramNumber)
T - le type de la classe a inspecterclazz - la classe sur lequel rechercher le constructeurparamNumber - le nombre de parametre souhaite pour le constructeur,
-1 indique que tous les constructeur sont souhaite.
public static Object toObject(Object o)
o - Object to transform
public static Object toObject(char c)
c - the char to transform
public static Object toObject(byte b)
b - the byte to transform
public static Object toObject(short s)
s - the short to transform
public static Object toObject(int i)
i - the int to transform
public static Object toObject(long l)
l - the long to transform
public static Object toObject(float f)
f - the float to transform
public static Object toObject(double d)
d - the double to transform
public static Object toObject(boolean b)
b - the boolean to transform
public static Object getNullValue(Class<?> type)
type - the type to test
null value or default value for primitive typespublic static boolean isNullValue(Object value)
value - the value to test
true if value is null or default value on a primitivepublic static boolean isNullValue(boolean value)
public static boolean isNullValue(byte value)
public static boolean isNullValue(int value)
public static boolean isNullValue(char value)
public static boolean isNullValue(float value)
public static boolean isNullValue(double value)
public static boolean isPrimitive(Class<?> clazz)
clazz - nom de la classe a tester
public static Class<?> getPrimitiveClass(Class<?> clazz)
clazz - la classe dont on souhaite le type primitf
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||