Source code: com/webobjects/woextensions/KeyValueCodingProtectedAccessor.java
1 /*
2 * Copyright (C) NetStruxr, Inc. All rights reserved.
3 *
4 * This software is published under the terms of the NetStruxr
5 * Public Software License version 0.5, a copy of which has been
6 * included with this distribution in the LICENSE.NPL file. */
7 package com.webobjects.woextensions;
8
9 import java.lang.reflect.*;
10 import com.webobjects.foundation.*;
11
12 public class KeyValueCodingProtectedAccessor extends NSKeyValueCoding.ValueAccessor {
13
14 public KeyValueCodingProtectedAccessor() { super(); }
15
16 public Object fieldValue(Object object, Field field) throws IllegalArgumentException, IllegalAccessException {
17 return field.get(object);
18 }
19
20 public void setFieldValue(Object object, Field field, Object value) throws IllegalArgumentException, IllegalAccessException {
21 field.set(object, value);
22 }
23
24 public Object methodValue(Object object, Method method) throws IllegalArgumentException, IllegalAccessException,
25 InvocationTargetException {
26 return method.invoke(object, null);
27 }
28
29 public void setMethodValue(Object object, Method method, Object value) throws IllegalArgumentException, IllegalAccessException,
30 InvocationTargetException {
31 method.invoke(object, new Object[] {value});
32 }
33 }