01: package net.sourceforge.orbroker;
02:
03: import net.kildenpedersen.reflect.Reflector;
04:
05: /*
06: * Created on Mar 19, 2004
07: */
08:
09: /**
10: * ArgumentList contains a method or constructors arguments.
11: * @author Nils Kilden-Pedersen
12: */
13: final class ArgumentList extends TypedList {
14:
15: static final ArgumentList NO_ARG;
16: static {
17: NO_ARG = new ArgumentList(0);
18: NO_ARG.close();
19: }
20:
21: private Class[] parmTypes;
22:
23: /**
24: * Constructor.
25: * @param size Initial size
26: */
27: ArgumentList(int size) {
28: super (size);
29: }
30:
31: private ValueType getValueType(int idx) {
32: return (ValueType) super .get(idx);
33: }
34:
35: /**
36: * Add a {@link ValueType} to the list.
37: * @param type The ValueType.
38: */
39: void add(ValueType type) {
40: super .add(type);
41: }
42:
43: /**
44: * Returns the {@link java.lang.Class} array.
45: * No synchronization is used, as it is assumed that
46: * concurrent threads will produce the same result.
47: * @return argument types
48: */
49: Class[] getArgumentTypes() {
50: assert isClosed() : Reflector.getClassName(getClass())
51: + " must be closed when using this operation.";
52:
53: if (this .parmTypes == null) {
54: Class[] parmClasses = new Class[size()];
55: for (int i = 0; i < parmClasses.length; i++) {
56: parmClasses[i] = getValueType(i).getType();
57: }
58: this .parmTypes = parmClasses;
59: }
60:
61: return this .parmTypes;
62: }
63:
64: /**
65: * Get the argument values as array.
66: * @param row
67: * @return array of argument values
68: */
69: Object[] getArgumentValues(ResultRow row) {
70: assert isClosed() : Reflector.getClassName(getClass())
71: + " must be closed when using this operation.";
72:
73: Object[] parmValues = new Object[size()];
74: for (int i = 0; i < parmValues.length; i++) {
75: parmValues[i] = getValueType(i).getValue(row);
76: }
77: return parmValues;
78: }
79: }
|