01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08:
09: package com.gwtext.client.data;
10:
11: import com.google.gwt.core.client.JavaScriptObject;
12: import com.gwtext.client.core.JsObject;
13: import com.gwtext.client.util.JavaScriptObjectHelper;
14:
15: /**
16: * Base abstract reader class. A Reader class defines the metadata of the data that needs to be read. The actual
17: * datasource is defined as by a {@link DataProxy} implmentation. A {@link Store} is build using a Reader and a DataProxy and is capable of
18: * actually reading the data out of the data source into {@link Record} objects. Several widgets like {@link com.gwtext.client.widgets.form.ComboBox} and
19: * {@link com.gwtext.client.widgets.grid.GridPanel} are backed by {@link Store} to provide the "model" for the widget.
20: */
21: public abstract class Reader extends JsObject {
22: protected JavaScriptObject configJS = JavaScriptObjectHelper
23: .createObject();
24:
25: protected RecordDef recordDef;
26:
27: public RecordDef getRecordDef() {
28: return recordDef;
29: }
30:
31: public void setRecordDef(RecordDef recordDef) {
32: this .recordDef = recordDef;
33: }
34:
35: public JavaScriptObject getJsObj() {
36: if (jsObj == null) {
37: if (recordDef == null) {
38: throw new IllegalStateException(
39: "You must specify a RecordDef for this reader");
40: }
41: jsObj = create(configJS, recordDef.getJsObj());
42: }
43: return jsObj;
44: }
45:
46: protected JavaScriptObject create(JavaScriptObject config,
47: JavaScriptObject recordDef) {
48: return null;
49: }
50: }
|