1:
31:
32: package ;
33:
34: import ;
35:
36: import ;
37: import ;
38: import ;
39: import ;
40: import ;
41:
42:
47: public class ReportContextImpl implements ReportContext
48: {
49: private static class DataCarrier
50: {
51: private boolean locked;
52: private Object value;
53:
54: private DataCarrier(final Object value)
55: {
56: this.value = value;
57: }
58:
59: public void lock ()
60: {
61: locked = true;
62: }
63:
64: public boolean isLocked()
65: {
66: return locked;
67: }
68:
69: public Object getValue()
70: {
71: return value;
72: }
73:
74: public void setValue(final Object value)
75: {
76: this.value = value;
77: }
78: }
79:
80: private HashMap backend;
81: private String exportDescriptor;
82: private FormulaContext formulaContext;
83: private LayoutControllerFactory layoutControllerFactory;
84: private ResourceBundleFactory resourceBundleFactory;
85: private ReportStructureRoot reportStructureRoot;
86:
87: public ReportContextImpl()
88: {
89: backend = new HashMap();
90: }
91:
92: public void setReportStructureRoot(final ReportStructureRoot reportStructureRoot)
93: {
94: this.reportStructureRoot = reportStructureRoot;
95: }
96:
97: public ReportStructureRoot getReportStructureRoot()
98: {
99: return reportStructureRoot;
100: }
101:
102: public String getExportDescriptor()
103: {
104: return exportDescriptor;
105: }
106:
107: public void setExportDescriptor(final String exportDescriptor)
108: {
109: this.exportDescriptor = exportDescriptor;
110: }
111:
112: public FormulaContext getFormulaContext()
113: {
114: return formulaContext;
115: }
116:
117: public void setFormulaContext(final FormulaContext formulaContext)
118: {
119: this.formulaContext = formulaContext;
120: }
121:
122: public LayoutControllerFactory getLayoutControllerFactory()
123: {
124: return layoutControllerFactory;
125: }
126:
127: public void setLayoutControllerFactory(final LayoutControllerFactory layoutControllerFactory)
128: {
129: this.layoutControllerFactory = layoutControllerFactory;
130: }
131:
132: public void setAttribute(final Object key, final Object value)
133: {
134: final DataCarrier dc = (DataCarrier) backend.get(key);
135: if (dc == null)
136: {
137: if (value == null)
138: {
139: return;
140: }
141:
142: final DataCarrier ndc = new DataCarrier(value);
143: backend.put (key, ndc);
144: return;
145: }
146:
147: if (dc.isLocked())
148: {
149: throw new IllegalStateException("Context-Entry is locked.");
150: }
151: dc.setValue (value);
152: }
153:
154: public void setSystemAttribute(final Object key, final Object value)
155: {
156: final DataCarrier dc = (DataCarrier) backend.get(key);
157: if (dc == null)
158: {
159: if (value == null)
160: {
161: return;
162: }
163:
164: final DataCarrier ndc = new DataCarrier(value);
165: ndc.lock();
166: backend.put (key, ndc);
167: return;
168: }
169:
170: if (dc.isLocked())
171: {
172: throw new IllegalStateException("Context-Entry is locked.");
173: }
174: dc.setValue (value);
175: }
176:
177: public Object getAttribute(final Object key)
178: {
179: final DataCarrier dc = (DataCarrier) backend.get(key);
180: if (dc == null)
181: {
182: return null;
183: }
184: return dc.getValue();
185: }
186:
187: public boolean isSystemAttribute(final Object key)
188: {
189: final DataCarrier dc = (DataCarrier) backend.get(key);
190: if (dc == null)
191: {
192: return false;
193: }
194: return dc.isLocked();
195: }
196:
197: public ResourceBundleFactory getResourceBundleFactory()
198: {
199: return resourceBundleFactory;
200: }
201:
202: public void setResourceBundleFactory(final ResourceBundleFactory resourceBundleFactory)
203: {
204: this.resourceBundleFactory = resourceBundleFactory;
205: }
206: }