ingo@51: package de.intevation.flys.client.shared.model; ingo@51: ingo@51: import java.io.Serializable; ingo@51: import java.util.ArrayList; ingo@51: import java.util.List; ingo@51: ingo@51: /** ingo@51: * @author Ingo Weinzierl ingo@51: */ ingo@51: public class DataList implements Serializable { ingo@51: ingo@51: /** The list of Data objects managed by this list.*/ ingo@51: protected List data; ingo@51: ingo@51: /** The name of the state that this list belongs to.*/ ingo@51: protected String state; ingo@51: ingo@51: /** The name of a UIProvider that is recommended to render this DataList.*/ ingo@51: protected String uiprovider; ingo@51: ingo@51: /** The label that should be used to label data objects.*/ ingo@51: protected String label; ingo@51: ingo@51: ingo@51: /** ingo@51: * The default constructor that creates a new DataList without Data objects ingo@51: * and no UIProvider. ingo@51: */ ingo@51: public DataList() { ingo@51: data = new ArrayList(); ingo@51: } ingo@51: ingo@51: ingo@52: /** ingo@52: * Constructor. ingo@52: * ingo@52: * @param state The name of the state that this list belongs to. ingo@52: * @param size The initial size of the list. ingo@52: */ ingo@51: public DataList(String state, int size) { ingo@51: this.state = state; ingo@51: this.data = new ArrayList(size); ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * A constructor that creates a new DataList without Data objects and no ingo@51: * UIProvider. Size defines the initial size of the list. ingo@51: * ingo@52: * @param state The name of the state that this list belongs to. ingo@51: * @param size The initial size of the list. ingo@52: * @param uiprovider The UIProvider that should be used to render this list. ingo@51: */ ingo@51: public DataList(String state, int size, String uiprovider) { ingo@51: this(state, size); ingo@51: this.uiprovider = uiprovider; ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@52: * A constructor that creates a new DataList without Data objects and no ingo@52: * UIProvider. Size defines the initial size of the list. ingo@52: * ingo@52: * @param state The name of the state that this list belongs to. ingo@52: * @param size The initial size of the list. ingo@52: * @param uiprovider The UIProvider that should be used to render this list. ingo@52: * @param label The label. ingo@52: */ ingo@52: public DataList(String state, int size, String uiprovider, String label) { ingo@52: this(state, size, uiprovider); ingo@52: this.label = label; ingo@52: } ingo@52: ingo@52: ingo@52: /** ingo@51: * Adds a new Data object to the list. ingo@51: * ingo@51: * @param obj The Data object. ingo@51: */ ingo@51: public void add(Data obj) { ingo@51: if (obj != null) { ingo@51: data.add(obj); ingo@51: } ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * Adds a new Data objects to the list. ingo@51: * ingo@51: * @param obj The Data object. ingo@51: */ ingo@51: public void add(Data[] obj) { ingo@51: if (obj != null) { ingo@51: for (Data o: obj) { ingo@51: data.add(o); ingo@51: } ingo@51: } ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * Returns the Data element at position idx. ingo@51: * ingo@51: * @param idx The position of an element that should be returned. ingo@51: * ingo@51: * @return the Data element at position idx. ingo@51: */ ingo@51: public Data get(int idx) { ingo@51: if (idx < size()) { ingo@51: return data.get(idx); ingo@51: } ingo@51: ingo@51: return null; ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@52: * Returns the whole list of Data objects. ingo@52: * ingo@52: * @return the whole list of Data objects. ingo@52: */ ingo@52: public List getAll() { ingo@52: return data; ingo@52: } ingo@52: ingo@52: /** ingo@51: * Returns the number of Data objects in the list. ingo@51: * ingo@51: * @param the number of Data objects in the list. ingo@51: */ ingo@51: public int size() { ingo@51: return data.size(); ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * Returns the name of the state that this list belongs to. ingo@51: * ingo@51: * @return the name of the state that this list belongs to. ingo@51: */ ingo@51: public String getState() { ingo@51: return state; ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * Returns the label for this list. ingo@51: * ingo@51: * @return the label of this list. ingo@51: */ ingo@51: public String getLabel() { ingo@51: return label; ingo@51: } ingo@51: ingo@51: ingo@51: /** ingo@51: * Retrieves the name of a UIProvider or null if no one is recommended. ingo@51: * ingo@51: * @return the name of a UIProvider or null if no one is recommended. ingo@51: */ ingo@51: public String getUIProvider() { ingo@51: return uiprovider; ingo@51: } ingo@51: } ingo@51: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :