| java.lang.Object org.zkoss.lang.reflect.Fields
Fields | public class Fields (Code) | | Utilities to access fields.
author: tomyeh |
Method Summary | |
final public static Object | get(Object obj, String name) | final public static Object | getField(Object obj, String name) Returnst the value of the specfied field of the object.
If getField(obj, "a.b.c") is called and obj.getA() or
obj.getA().getB() returns null, the result is null.
However, NullPointerException is thrown if obj is null.
Parameters: name - the field name. | final public static void | set(Object obj, String name, Object val, boolean autoCoerce) | final public static void | setAccessible(AccessibleObject f, boolean accessible) Changes the accessibility without throwing any exception. | final public static void | setField(Object obj, String name, Object val, boolean autoCoerce) Sets the value of the specified field in the object. | final public static void | setField(Object obj, String name, Object val) Sets the value of the specfied field in the object, without
converting the specified val.
It is a shortcut of setField(obj, name, val, false).
Parameters: name - the field name. |
getField | final public static Object getField(Object obj, String name) throws NoSuchMethodException(Code) | | Returnst the value of the specfied field of the object.
If getField(obj, "a.b.c") is called and obj.getA() or
obj.getA().getB() returns null, the result is null.
However, NullPointerException is thrown if obj is null.
Parameters: name - the field name. It can be in form of "a.b.c", but cannotbe an expression. exception: NoSuchMethodException - if no corresponding field. |
setAccessible | final public static void setAccessible(AccessibleObject f, boolean accessible)(Code) | | Changes the accessibility without throwing any exception.
since: 3.0.3 |
setField | final public static void setField(Object obj, String name, Object val, boolean autoCoerce) throws NoSuchMethodException, ModificationException(Code) | | Sets the value of the specified field in the object.
Parameters: autoCoerce - whether to automatically convert val to the properclass that matches the argument of method or field. |
setField | final public static void setField(Object obj, String name, Object val) throws NoSuchMethodException, ModificationException(Code) | | Sets the value of the specfied field in the object, without
converting the specified val.
It is a shortcut of setField(obj, name, val, false).
Parameters: name - the field name. It can be in form of "a.b.c", but cannotbe an expression. |
|
|