PATH |
- Inherits from:
- Object
- Package:
- com.webobjects.foundation
NSKeyValueCoding.ValueAccessor is an abstract class that establishes a mechanism by which NSKeyValueCoding can operate on objects' package access instance variables.
By default, Foundation's implementations of NSKeyValueCoding can't 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:
The best solution is to implement accessor methods or to make the instance variables public. However, if you have a lot of classes with a lot of package access instance variables, you can use the short-term solution that NSKeyValueCoding.ValueAccessor provides until you make the necessary changes to your code.
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(Field field, Object object) throws IllegalArgumentException, IllegalAccessException { return field.get(object); } public void setFieldValue(Field field, Object value, Object object) throws IllegalArgumentException, IllegalAccessException { field.set(object, value); } public Object methodValue(Method method, Object object) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(object, null); } public void setMethodValue(Method method, Object value, Object object) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { method.invoke(object, new Object[] {value}); } }
public NSKeyValueCoding.ValueAccessor()
public static NSKeyValueCoding.ValueAccessor protectedAccessorForPackageNamed( String packageName)
public static void removeProtectedAccessorForPackageNamed( String packageName)
public static void setProtectedAccessorForPackageNamed( NSKeyValueCoding.ValueAccessor accessor, String packageName)
public abstract Object fieldValue( Object object, reflect.Field field) throws IllegalArgumentException, IllegalAccessException
public abstract Object methodValue( Object object, reflect.Method method) throws IllegalArgumentException, IllegalAccessException, reflect.InvocationTargetException
public abstract void setFieldValue( Object object, reflect.Field field, Object value) throws IllegalArgumentException, IllegalAccessException
public abstract void setMethodValue( Object object, reflect.Method method, Object value) throws IllegalArgumentException, IllegalAccessException, reflect.InvocationTargetException
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)