|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.util.Introspector
public class Introspector
A class to allow access to the methods "fooType getFoo()" and "void setFoo(fooType)" conventionally seen in objects. Useful when Foo arrives as a run-time String, such as is the case in serialization to/from XML representations.
| Field Summary | |
|---|---|
private java.lang.String |
field
The field whose get/set methods we wish to invoke. |
private java.lang.Class<?> |
theClass
The class whose field we are to operate on. |
| Constructor Summary | |
|---|---|
Introspector(java.lang.Class<?> theClass,
java.lang.String field)
Build a new Introspector for the specified class and field name. |
|
| Method Summary | |
|---|---|
private java.lang.reflect.Method |
getFromStringConverter(java.lang.Class<?> argType)
Get a function that converts from String to a given class. |
private java.lang.reflect.Method |
getGetMethod()
Get a get-method for this Introspector. |
private java.lang.Class<?> |
getMethodReturnType(java.lang.reflect.Method method)
Get the return type from a Method. |
private java.lang.reflect.Method |
getSetMethod(java.lang.Class argType)
Get a set-method for this Introspector. |
java.lang.String |
getter(java.lang.Object obj)
Invoke the get-method for this Introspector. |
private java.lang.reflect.Method |
getToStringConverter(java.lang.Class<?> argType)
Get a function that converts to String from a given class. |
void |
setter(java.lang.Object obj,
java.lang.String value)
Invoke the set-method provided by this Introspector. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.lang.Class<?> theClass
private java.lang.String field
| Constructor Detail |
|---|
public Introspector(java.lang.Class<?> theClass,
java.lang.String field)
throws java.lang.IllegalArgumentException
theClass - The Class of interest.field - The field name within the class of interest.
java.lang.IllegalArgumentException| Method Detail |
|---|
private java.lang.reflect.Method getGetMethod()
throws java.lang.IllegalArgumentException
Method representing getField().
java.lang.IllegalArgumentException
private java.lang.reflect.Method getSetMethod(java.lang.Class argType)
throws java.lang.IllegalArgumentException
argType - A Class that is the argument to
the set-method
Method representing setField().
java.lang.IllegalArgumentException
private java.lang.Class<?> getMethodReturnType(java.lang.reflect.Method method)
throws java.lang.IllegalArgumentException
Method.
method - The Method to examine.
java.lang.IllegalArgumentException
private java.lang.reflect.Method getToStringConverter(java.lang.Class<?> argType)
throws java.lang.IllegalArgumentException
argType - A Class to find a converter for.
java.lang.IllegalArgumentException
private java.lang.reflect.Method getFromStringConverter(java.lang.Class<?> argType)
throws java.lang.IllegalArgumentException
argType - A Class to find a converter for.
IllegalArgumentExcpetion
java.lang.IllegalArgumentException
public java.lang.String getter(java.lang.Object obj)
throws java.lang.IllegalArgumentException
obj - An Object (really of type theClass)
whose get-method is to be invoked.
String containing the result of invoking
the get-method.
java.lang.IllegalArgumentException
public void setter(java.lang.Object obj,
java.lang.String value)
throws java.lang.IllegalArgumentException
obj - An Object (really of type theClass)
whose set-method is to be invoked.value - A String containing the value to be set.
java.lang.IllegalArgumentException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||