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.util.JavaScriptObjectHelper;
13:
14: /**
15: * Field that represents boolean data.
16: *
17: * @author Sanjiv Jivan
18: * @since 0.9
19: */
20: public class BooleanFieldDef extends FieldDef {
21:
22: /**
23: * Construct a new BooleanFieldDef.
24: *
25: * @param name the name of field
26: */
27: public BooleanFieldDef(String name) {
28: this (name, null, null);
29: }
30:
31: /**
32: * Construct a new BooleanFieldDef
33: *
34: * @param name the name of field
35: * @param mapping the field mapping. Depending on the Reader used, mapping could be the array index position or an XPath expression when reading from XML
36: */
37: public BooleanFieldDef(String name, String mapping) {
38: this (name, mapping, null);
39: }
40:
41: /**
42: * Construct a new BooleanFieldDef
43: *
44: * @param name the field name
45: * @param mapping the field mapping. Depending on the Reader used, mapping could be the array index position or an XPath expression when reading from XML
46: */
47: public BooleanFieldDef(String name, int mapping) {
48: this (name, mapping, null);
49: }
50:
51: /**
52: * Construct a new BooleanFieldDef
53: *
54: * @param name the field name
55: * @param mapping the field mapping. Depending on the Reader used, mapping could be the array index position or an XPath expression when readinf from XML
56: * @param converter format the incoming data before processing it
57: */
58: public BooleanFieldDef(String name, int mapping, Converter converter) {
59: this (name, String.valueOf(mapping), converter);
60: }
61:
62: /**
63: * Construct a new BooleanFieldDef
64: *
65: * @param name the field name
66: * @param mapping the field mapping. Depending on the Reader used, mapping could be the array index position or an XPath expression when readinf from XML
67: * @param converter format the incoming data before processing it
68: */
69: public BooleanFieldDef(String name, String mapping,
70: Converter converter) {
71: jsObj = create(name, mapping, converter);
72: }
73:
74: private static JavaScriptObject create(String name, String mapping,
75: Converter converter) {
76: JavaScriptObject jsObj = JavaScriptObjectHelper.createObject();
77: JavaScriptObjectHelper.setAttribute(jsObj, "name", name);
78: JavaScriptObjectHelper.setAttribute(jsObj, "type", "bool");
79: if (mapping != null)
80: JavaScriptObjectHelper.setAttribute(jsObj, "mapping",
81: mapping);
82: if (converter != null)
83: setConverter(jsObj, converter);
84: return jsObj;
85: }
86: }
|