001: /*
002: * MyGWT Widget Library
003: * Copyright(c) 2007, MyGWT.
004: * licensing@mygwt.net
005: *
006: * http://mygwt.net/license
007: */
008: package net.mygwt.ui.client.data;
009:
010: import java.util.HashMap;
011: import java.util.Map;
012:
013: import com.google.gwt.user.client.rpc.IsSerializable;
014:
015: /**
016: * Contains the results of a data load operation.
017: */
018: public class LoadResult implements IsSerializable {
019:
020: /**
021: * success specifies if the load was successful. Default value is
022: * <code>true</code>.
023: */
024: public boolean success = true;
025:
026: /**
027: * add specifies if the results should be added.
028: */
029: public boolean add;
030:
031: /**
032: * totalLength specifies the total number of elements. This may not be the
033: * same as the number of elements when implementing paging.
034: */
035: public int totalLength;
036:
037: /**
038: * cursor specifies the current location of the data.
039: */
040: public int cursor;
041:
042: /**
043: * The returned data.
044: */
045: public IsSerializable data;
046:
047: /**
048: * dataMap contains application specific load properties
049: *
050: * @gwt.typeArgs <java.lang.String,com.google.gwt.user.client.rpc.IsSerializable>
051: */
052: public Map dataMap;
053:
054: /**
055: * Creates a new load result instance.
056: */
057: public LoadResult() {
058:
059: }
060:
061: /**
062: * Creates a new load result and sets the success field to <code>true</code>.
063: *
064: * @param data the returned data
065: */
066: public LoadResult(IsSerializable data) {
067: this .data = data;
068: success = true;
069: }
070:
071: /**
072: * Sets the result data.
073: *
074: * @param data the result data
075: */
076: public void setData(IsSerializable data) {
077: this .data = data;
078: }
079:
080: /**
081: * Returns the result data.
082: *
083: * @return the data
084: */
085: public IsSerializable getData() {
086: return data;
087: }
088:
089: /**
090: * Returns the application specific load property for the given name, or
091: * <code>null</code> if it has not been set.
092: *
093: * @param key the name of the property
094: * @return the value or <code>null</code> if it has not been set
095: */
096: public Object getData(String key) {
097: if (dataMap == null)
098: return null;
099: return dataMap.get(key);
100: }
101:
102: /**
103: * Sets the application specific load property with the given name.
104: *
105: * @param key the name of the property
106: * @param config the new value for the property
107: */
108: public void setData(String key, Object config) {
109: if (dataMap == null)
110: dataMap = new HashMap();
111: dataMap.put(key, config);
112: }
113: }
|