|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
public abstract static class 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:
<blockquote> 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, java.lang.reflect.InvocationTargetException { return method.invoke(object); } public void setMethodValue(Object object, Method method, Object value) throws IllegalArgumentException, IllegalAccessException, java.lang.reflect.InvocationTargetException { method.invoke(object, new Object[] {value}); } } </blockquote>
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 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 thispublic static NSKeyValueCoding.ValueAccessor protectedAccessorForPackageNamed(String packageName)
packageName
- the package identified to be operated on
packageName
public static void removeProtectedAccessorForPackageNamed(String packageName)
packageName
.
packageName
- the package identified to be operated onpublic 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 field
object
's field
IllegalArgumentException
IllegalAccessException
public 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 this
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 object
IllegalArgumentException
IllegalAccessException
InvocationTargetException
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 this
IllegalArgumentException
IllegalAccessException
InvocationTargetException
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |