1:
31:
32: package ;
33:
34: import ;
35: import ;
36: import ;
37: import ;
38: import ;
39: import ;
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48:
49:
54: public class ReportFormulaContext implements FormulaContext
55: {
56: private FormulaContext backend;
57: private DataRow dataRow;
58: private Object declaringElement;
59:
60: public ReportFormulaContext(final FormulaContext backend,
61: final DataRow dataRow)
62: {
63: this.backend = backend;
64: this.dataRow = dataRow;
65: }
66:
67: public LocalizationContext getLocalizationContext()
68: {
69: return backend.getLocalizationContext();
70: }
71:
72: public Configuration getConfiguration()
73: {
74: return backend.getConfiguration();
75: }
76:
77: public FunctionRegistry getFunctionRegistry()
78: {
79: return backend.getFunctionRegistry();
80: }
81:
82: public TypeRegistry getTypeRegistry()
83: {
84: return backend.getTypeRegistry();
85: }
86:
87: public OperatorFactory getOperatorFactory()
88: {
89: return backend.getOperatorFactory();
90: }
91:
92: public boolean isReferenceDirty(final Object name) throws ContextEvaluationException
93: {
94: try
95: {
96: final DataFlags flags = dataRow.getFlags(String.valueOf(name));
97: if (flags == null)
98: {
99: throw new ContextEvaluationException
100: (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
101: }
102: return flags.isChanged();
103: }
104: catch(Exception e)
105: {
106: throw new ContextEvaluationException
107: (new LibFormulaErrorValue(LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
108: }
109: }
110:
111: public Type resolveReferenceType(final Object name)
112: {
113: return AnyType.TYPE;
114: }
115:
116: public Object resolveReference(final Object name) throws ContextEvaluationException
117: {
118: if (name == null)
119: {
120: throw new NullPointerException();
121: }
122: try
123: {
124: return dataRow.get(String.valueOf(name));
125: }
126: catch (DataSourceException e)
127: {
128: Log.debug ("Error while resolving formula reference: ", e);
129: throw new ContextEvaluationException(new LibFormulaErrorValue
130: (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
131: }
132: }
133:
134: public DataRow getDataRow()
135: {
136: return dataRow;
137: }
138:
139: public void setDataRow(final DataRow dataRow)
140: {
141: this.dataRow = dataRow;
142: }
143:
144: public Object getDeclaringElement()
145: {
146: return declaringElement;
147: }
148:
149: public void setDeclaringElement(final Object declaringElement)
150: {
151: this.declaringElement = declaringElement;
152: }
153: }