|
Last change
on this file was
2,
checked in by dsowen, 21 years ago
|
|
Initial commit.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | * Created on Mar 15, 2005 |
|---|
| 3 | * |
|---|
| 4 | * $Log$ |
|---|
| 5 | * Revision 1.1 2005/08/03 00:35:29 dsowen |
|---|
| 6 | * Initial commit. |
|---|
| 7 | * |
|---|
| 8 | * Revision 1.2 2005/04/10 19:48:29 dowen |
|---|
| 9 | * Renamed package. |
|---|
| 10 | * |
|---|
| 11 | * Revision 1.1 2005/03/19 16:49:20 dowen |
|---|
| 12 | * Initial commit. |
|---|
| 13 | * |
|---|
| 14 | */ |
|---|
| 15 | package ws.fugue88.jpath; |
|---|
| 16 | |
|---|
| 17 | import java.lang.reflect.Field; |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * @author dsowen |
|---|
| 21 | */ |
|---|
| 22 | class FieldProperty implements Property { |
|---|
| 23 | |
|---|
| 24 | FieldProperty(String name, Class clas, String field) |
|---|
| 25 | throws NoSuchFieldException |
|---|
| 26 | { |
|---|
| 27 | _name = name; |
|---|
| 28 | |
|---|
| 29 | _field = clas.getDeclaredField(field); |
|---|
| 30 | _field.setAccessible(true); |
|---|
| 31 | |
|---|
| 32 | _type = _field.getType(); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | public String getName() |
|---|
| 36 | { |
|---|
| 37 | return _name; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | public Class getType() |
|---|
| 41 | { |
|---|
| 42 | return _type; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | public Object getValue(Object that) |
|---|
| 46 | { |
|---|
| 47 | try { |
|---|
| 48 | return _field.get(that); |
|---|
| 49 | } catch(IllegalAccessException e) { |
|---|
| 50 | throw new Error(e); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | public void setValue(Object that, Object value) |
|---|
| 55 | { |
|---|
| 56 | try { |
|---|
| 57 | _field.set(that, value); |
|---|
| 58 | } catch(IllegalAccessException e) { |
|---|
| 59 | throw new Error(e); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | private String _name; |
|---|
| 64 | private Class _type; |
|---|
| 65 | private Field _field; |
|---|
| 66 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.