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 float data.
16: */
17: public class FloatFieldDef extends FieldDef {
18:
19: /**
20: * Construct a new FloatFieldDef.
21: *
22: * @param name the field name
23: */
24: public FloatFieldDef(String name) {
25: this (name, null, null);
26: }
27:
28: /**
29: * Construct a new FloatFieldDef.
30: *
31: * @param name the field name
32: * @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
33: */
34: public FloatFieldDef(String name, String mapping) {
35: this (name, mapping, null);
36: }
37:
38: /**
39: * Construct a new FloatFieldDef.
40: *
41: * @param name the field name
42: * @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
43: */
44: public FloatFieldDef(String name, int mapping) {
45: this (name, mapping, null);
46: }
47:
48: /**
49: * Construct a new FloatFieldDef.
50: *
51: * @param name the field name
52: * @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
53: * @param converter the field converter
54: */
55: public FloatFieldDef(String name, String mapping,
56: Converter converter) {
57: jsObj = create(name, mapping, converter);
58: }
59:
60: /**
61: * Construct a new FloatFieldDef.
62: *
63: * @param name the field name
64: * @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
65: * @param converter the field converter
66: */
67: public FloatFieldDef(String name, int mapping, Converter converter) {
68: this (name, String.valueOf(mapping), converter);
69: }
70:
71: private static JavaScriptObject create(String name, String mapping,
72: Converter converter) {
73: JavaScriptObject jsObj = JavaScriptObjectHelper.createObject();
74: JavaScriptObjectHelper.setAttribute(jsObj, "name", name);
75: JavaScriptObjectHelper.setAttribute(jsObj, "type", "float");
76: if (mapping != null)
77: JavaScriptObjectHelper.setAttribute(jsObj, "mapping",
78: mapping);
79: if (converter != null)
80: setConverter(jsObj, converter);
81: return jsObj;
82: }
83: }
|