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.io.Serializable;
23 import java.util.Date;
25 import org.glom.web.shared.libglom.Field;
28 * This Data Transfer Object (DTO) is used to send a data item between the client and the server.
31 @SuppressWarnings("serial")
32 public class DataItem implements Serializable {
36 private double number;
38 private byte[] imageData; //This is only used locally to recreate database data.
39 private String imageDataUrl; //This is for use as an <img> or GWT Image URL.
46 public String getText() {
50 public void setText(final String text) {
54 public boolean getBoolean() {
58 public void setBoolean(final boolean bool) {
62 public double getNumber() {
66 public void setNumber(final double number) {
70 public Date getDate() {
74 public void setDate(final Date date) {
78 /** This is not used in DataItem instances that are passed from the server to the client.
79 * This is only used locally to recreate database data.
82 public void setImageData(final byte[] imageData) {
83 this.imageData = imageData;
86 public byte[] getImageData() {
90 public String getImageDataUrl() {
92 //For testing: return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
95 public void setImageDataUrl(final String image) {
96 this.imageDataUrl = image;
99 /** This is used by SelfHoster to get data for a database column.
101 * @param type The expected type of the data.
104 public Object getValue(final Field.GlomFieldType type) {
109 return getImageData(); //getImageDataUrl() is for use on the client side only.
114 // TODO: case TYPE_TIME;