|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
NSKeyValueCoding.ValueAccessor is an abstract class that establishes a mechanism by which NSKeyValueCoding can operate on object's package access instance variables.
By default, Foundation's implementations of NSKeyValueCoding cannot access package access instance variables. If you have package access instance variables in your NSKeyValueCoding objects, you can make them available to key-value coding in one of the three ways:
set
Key and key
accessor methods for those
instance variables that set and return the instance variable's values.To use NSKeyValueCoding.ValueAccessor's mechanism, simply create a class in your package as follows:
package yourPackage; import java.lang.reflect.*; import com.webobjects.foundation.*; public class KeyValueCodingProtectedAccessor extends NSKeyValueCoding.ValueAccessor { public KeyValueCodingProtectedAccessor() { super(); } public Object fieldValue(Object object, Field field) throws IllegalArgumentException, IllegalAccessException { return field.get(object); } public void setFieldValue(Object object, Field field, Object value) throws IllegalArgumentException, IllegalAccessException { field.set(object, value); } public Object methodValue(Object object, Method method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(object, null); } public void setMethodValue(Object object, Method method, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { method.invoke(object, new Object[] {value}); } }
NSKeyValueCoding
Constructor Summary | |
NSKeyValueCoding.ValueAccessor()
empty constructor is required for subclasses implementing the ValueAccessor interface |
Method Summary | |
abstract Object |
fieldValue(Object object,
Field field)
|
abstract Object |
methodValue(Object object,
Method method)
Uses method to return object 's corresponding
property value. |
static NSKeyValueCoding.ValueAccessor |
protectedAccessorForPackageNamed(String packageName)
|
static void |
removeProtectedAccessorForPackageNamed(String packageName)
Removes (unregisters) the value accessor for the package identified by packageName . |
abstract void |
setFieldValue(Object object,
Field field,
Object value)
Sets object 's field value to value . |
abstract void |
setMethodValue(Object object,
Method method,
Object value)
Uses method to set object 's corresponding
property to value . |
static void |
setProtectedAccessorForPackageNamed(NSKeyValueCoding.ValueAccessor valueAccessor,
String packageName)
Sets the value accessor for the package identified by packageName to valueAccessor . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NSKeyValueCoding.ValueAccessor()
Method Detail |
public abstract Object fieldValue(Object object, Field field) throws IllegalArgumentException, IllegalAccessException
object
- the object whose package access instance
variables are to be operated onfield
- the value of object's fieldobject
's field
IllegalArgumentException
- IllegalAccessException
- public abstract Object methodValue(Object object, Method method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
method
to return object
's corresponding
property value.object
- the object whose package access instance
variables are to be operated onmethod
- instance variables of the objectIllegalArgumentException
- IllegalAccessException
- java.lang.InvocationTargetException
- public static NSKeyValueCoding.ValueAccessor protectedAccessorForPackageNamed(String packageName)
packageName
- the package identified to be operated onpackageName
public static void removeProtectedAccessorForPackageNamed(String packageName)
packageName
.packageName
- the package identified to be operated onpublic abstract void setFieldValue(Object object, Field field, Object value) throws IllegalArgumentException, IllegalAccessException
object
's field
value to value
.object
- the object whose package access instance
variables are to be operated onfield
- object's property whose value is to be setvalue
- object's property identified by field is set to thisIllegalArgumentException
- IllegalAccessException
- public abstract void setMethodValue(Object object, Method method, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
method
to set object
's corresponding
property to value
.object
- the object whose package access instance
variables are to be operated onmethod
- instance variables of the objectvalue
- object's field identified by field
is set to thisIllegalArgumentException
- IllegalAccessException
- java.lang.InvocationTargetException
- public static void setProtectedAccessorForPackageNamed(NSKeyValueCoding.ValueAccessor valueAccessor, String packageName)
packageName
to valueAccessor
.valueAccessor
- the value accessor for the package
identified by packageName
packageName
- the value accessor for the package is identified by this
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |