1:
31:
32: package ;
33:
34: import ;
35: import ;
36: import ;
37: import ;
38: import ;
39: import ;
40: import ;
41: import ;
42: import ;
43:
44:
49: public class RunningExpressionSlot
50: implements ExpressionSlot, ExpressionRuntime
51: {
52: private StaticExpressionRuntimeData staticRuntimeData;
53: private Expression expression;
54: private Object value;
55: private String name;
56: private boolean queried;
57: private DataRow dataRow;
58:
59: public RunningExpressionSlot(final Expression expression,
60: final StaticExpressionRuntimeData runtimeData,
61: final PrecomputeNode precomputeNode)
62: {
63: this.staticRuntimeData = runtimeData;
64: this.expression = expression;
65: this.name = expression.getName();
66: this.expression.setRuntime(this);
67: this.expression.setRuntime(null);
68: }
69:
70: public Expression getExpression()
71: {
72: return expression;
73: }
74:
75: public Object getValue() throws DataSourceException
76: {
77: if (queried == false)
78: {
79:
80: synchronized (expression)
81: {
82: expression.setRuntime(this);
83: value = expression.computeValue();
84: expression.setRuntime(null);
85: }
86: queried = true;
87: }
88: return value;
89: }
90:
91: public String getName()
92: {
93: return name;
94: }
95:
96: public DataRow getDataRow()
97: {
98: return dataRow;
99: }
100:
101: public Object clone() throws CloneNotSupportedException
102: {
103: return super.clone();
104: }
105:
106: public void updateDataRow(final DataRow dataRow)
107: {
108: this.dataRow = dataRow;
109: }
110:
111:
121: public ReportData getData()
122: {
123: return staticRuntimeData.getData();
124: }
125:
126: public Object getDeclaringParent()
127: {
128: return staticRuntimeData.getDeclaringParent();
129: }
130:
131: public Configuration getConfiguration()
132: {
133: return staticRuntimeData.getConfiguration();
134: }
135:
136: public ResourceBundleFactory getResourceBundleFactory()
137: {
138: return staticRuntimeData.getResourceBundleFactory();
139: }
140:
141: public void advance() throws DataSourceException
142: {
143: if (expression instanceof Function)
144: {
145: final Function f = (Function) expression;
146: expression.setRuntime(this);
147: expression = f.advance();
148: f.setRuntime(null);
149: expression.setRuntime(null);
150: }
151: value = null;
152: queried = false;
153: }
154:
155: public boolean isDeepTraversing()
156: {
157: return expression.isDeepTraversing();
158: }
159:
160: public int getCurrentRow()
161: {
162: return staticRuntimeData.getCurrentRow();
163: }
164:
165: public ReportContext getReportContext()
166: {
167: return staticRuntimeData.getReportContext();
168: }
169:
170: public boolean isPreserve()
171: {
172: return expression.isPreserve();
173: }
174: }