2 * Copyright (C) 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
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.
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
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/>.
20 package org.glom.web.shared;
22 import java.util.Date;
24 import org.glom.web.shared.libglom.Field.GlomFieldType;
27 * This specialization of DataItem can hold a primary key item.
29 @SuppressWarnings("serial")
30 public class TypedDataItem extends DataItem {
31 private boolean empty = true;
32 private GlomFieldType type = GlomFieldType.TYPE_INVALID;
33 private String unknown = null;
35 public TypedDataItem() {
38 public boolean isEmpty() {
44 * This is a generic alternative to getNumber(), getText(), etc.
47 public Object getValue() {
55 //TODO: case TYPE_TIME:
60 return getImageData();
62 return "value-with-invalid-type";
64 return "value-with-unknown-type";
68 //TODO: Why is this override necessary?
72 * @see org.glom.web.shared.DataItem#setBoolean(boolean)
75 public void setBoolean(final boolean bool) {
77 this.type = GlomFieldType.TYPE_BOOLEAN;
78 super.setBoolean(bool);
84 * @see org.glom.web.shared.DataItem#setNumber(double)
87 public void setNumber(final double number) {
89 this.type = GlomFieldType.TYPE_NUMERIC;
90 super.setNumber(number);
96 * @see org.glom.web.shared.DataItem#setText(java.lang.String)
99 public void setText(final String text) {
101 this.type = GlomFieldType.TYPE_TEXT;
108 * @see org.glom.web.shared.DataItem#setNumber(double)
111 public void setDate(final Date date) {
113 this.type = GlomFieldType.TYPE_DATE;
117 public void setImageData(final byte[] imageData) {
119 this.type = GlomFieldType.TYPE_IMAGE;
120 super.setImageData(imageData);
123 public void setImageDataUrl(final String image) {
125 this.type = GlomFieldType.TYPE_IMAGE;
126 super.setImageDataUrl(image);
133 * @see org.glom.web.shared.DataItem#setText(java.lang.String)
135 public void setUnknown(final String value) {
137 this.type = GlomFieldType.TYPE_INVALID;
138 this.unknown = value;
141 public String getUnknown() {
145 public GlomFieldType getType() {