|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flat502.rox.marshal.ClassDescriptor
public class ClassDescriptor
Defines an interface for accessing members of a Java
Class
consistently.
An instance of this class provides uniform access to members of a Java Class. Whether or not the member is a public field or only through methods is opaque to the caller.
This class guarantees a singleton instance per Class.
As such instances of this class are only available via
the static factory method
.
The set of members on a given class is defined as
all non-transient public fields and all properties
(in the Introspector
sense) accessible via either a public getter or setter
method. If there is an overlap (i.e. a setter or getter
exists for a public field) methods are given precedence.
Method Summary | |
---|---|
java.lang.Class |
getGetterType(java.lang.String name)
|
static ClassDescriptor |
getInstance(java.lang.Class clazz)
Static factory method for creating instances of this class. |
java.lang.Class |
getSetterType(java.lang.String name)
|
java.util.Iterator |
getters()
Provides an Iterator over the getters on the represented
Class . |
java.lang.Object |
getValue(java.lang.Object target,
java.lang.String name)
Gets the value of the named property. |
java.util.Iterator |
setters()
Provides an Iterator over the setters on the represented
Class . |
void |
setValue(java.lang.Object target,
java.lang.String name,
java.lang.Object value)
Sets the value of the named property. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public void setValue(java.lang.Object target, java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
No type coercion beyond that provided by
Field.set(java.lang.Object, java.lang.Object)
or
Method.invoke(java.lang.Object, java.lang.Object[])
is performed.
target
- The object on which the named property should be set.name
- The name of the property to set.value
- The value to set the named property to.
java.lang.IllegalArgumentException
- if target
or name
are null
, or
if the Class
represented by this instance differs to
target
's.
java.lang.IllegalAccessException
- if the field or method associated with the named
property is inaccessible.
java.lang.reflect.InvocationTargetException
- if an exception is raised while invoking a setter.public java.lang.Object getValue(java.lang.Object target, java.lang.String name) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
target
- The object on which the named property should be set.name
- The name of the property to set.
java.lang.IllegalArgumentException
- if target
or name
are null
, or
if the Class
represented by this instance differs to
target
's.
java.lang.IllegalAccessException
- if the field or method associated with the named
property is inaccessible.
java.lang.reflect.InvocationTargetException
- if an exception is raised while invoking a setter.public java.util.Iterator getters()
Iterator
over the getters on the represented
Class
.
The iterator returns String
instances on each
iteration. These instances name the readable properties on
the represented Class.
Iterator
over the getters available on the
represented Class
.public java.util.Iterator setters()
Iterator
over the setters on the represented
Class
.
The iterator returns String
instances on each
iteration. These instances name the writeable properties on
the represented Class.
Iterator
over the setters available on the
represented Class
.public java.lang.Class getGetterType(java.lang.String name)
public java.lang.Class getSetterType(java.lang.String name)
public static ClassDescriptor getInstance(java.lang.Class clazz) throws java.beans.IntrospectionException
Multiple invocations of this method with the same Class
instance are guaranteed to return the same instance.
clazz
- The class for which a ClassDescriptor
is required.
ClassDescriptor
instance associated with the
given class.
java.beans.IntrospectionException
- if an error ocurrs while introspecting the given class.
java.lang.IllegalArgumentException
- if the parameter is null
.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |