01: /*
02: * $Id: FieldEnumeration.java,v 1.2 2002/09/16 08:05:04 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil.script.compiler;
11:
12: import java.lang.reflect.Field;
13: import anvil.java.util.BindingEnumeration;
14: import anvil.core.Any;
15:
16: public class FieldEnumeration implements BindingEnumeration {
17:
18: private Object _instance;
19: private BindingEnumeration _enumeration;
20:
21: public FieldEnumeration(Object instance,
22: BindingEnumeration enumeration) {
23: _instance = instance;
24: _enumeration = enumeration;
25: }
26:
27: public boolean hasMoreElements() {
28: return _enumeration.hasMoreElements();
29: }
30:
31: public Object nextKey() {
32: return _enumeration.nextKey();
33: }
34:
35: public Object nextElement() {
36: Field field = (Field) _enumeration.nextElement();
37: try {
38: return (Any) field.get(_instance);
39: } catch (Exception e) {
40: return Any.UNDEFINED;
41: }
42: }
43:
44: }
|