Add TypedDataItem.
[online-glom:gwt-glom.git] / src / main / java / org / glom / web / shared / TypedDataItem.java
1 /*
2  * Copyright (C) 2011 Openismus GmbH
3  *
4  * This file is part of GWT-Glom.
5  *
6  * GWT-Glom is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with GWT-Glom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 package org.glom.web.shared;
21
22 import org.glom.web.shared.layout.LayoutItemField.GlomFieldType;
23
24 /**
25  * This specialisation of DataItem is used to hold can a primary key item.
26  * 
27  * @author Ben Konrath <ben@bagu.org>
28  */
29 @SuppressWarnings("serial")
30 public class TypedDataItem extends DataItem {
31         private boolean empty = true;
32         private GlomFieldType type = GlomFieldType.TYPE_INVALID;
33
34         public TypedDataItem() {
35         }
36
37         public boolean isEmpty() {
38                 return empty;
39         }
40
41         /*
42          * (non-Javadoc)
43          * 
44          * @see org.glom.web.shared.DataItem#setBoolean(boolean)
45          */
46         @Override
47         public void setBoolean(boolean bool) {
48                 this.empty = false;
49                 this.type = GlomFieldType.TYPE_BOOLEAN;
50                 super.setBoolean(bool);
51         }
52
53         /*
54          * (non-Javadoc)
55          * 
56          * @see org.glom.web.shared.DataItem#setNumber(double)
57          */
58         @Override
59         public void setNumber(double number) {
60                 this.empty = false;
61                 this.type = GlomFieldType.TYPE_NUMERIC;
62                 super.setNumber(number);
63         }
64
65         /*
66          * (non-Javadoc)
67          * 
68          * @see org.glom.web.shared.DataItem#setText(java.lang.String)
69          */
70         @Override
71         public void setText(String text) {
72                 this.empty = false;
73                 this.type = GlomFieldType.TYPE_TEXT;
74                 super.setText(text);
75         }
76
77         /*
78          * (non-Javadoc)
79          * 
80          * @see org.glom.web.shared.DataItem#setText(java.lang.String)
81          */
82         public void setUnknown(String value) {
83                 this.empty = false;
84                 this.type = GlomFieldType.TYPE_INVALID;
85                 super.setText(value);
86         }
87
88         public GlomFieldType getType() {
89                 return type;
90         }
91
92 }