teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5861: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5861: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.shared.model; ingo@1527: ingo@1527: ingo@1527: public class IntegerArrayData implements Data { ingo@1527: ingo@1575: public static final String TYPE = "intarray"; ingo@1575: ingo@1575: ingo@1527: protected String label; ingo@1527: protected String description; ingo@1527: raimund@2535: protected IntDataItem[] values; ingo@1527: ingo@1527: ingo@1527: public IntegerArrayData() { ingo@1527: } ingo@1527: ingo@1527: raimund@2535: public IntegerArrayData( raimund@2535: String label, raimund@2535: String description, raimund@2535: IntDataItem[] values raimund@2535: ) { ingo@1527: this.label = label; ingo@1527: this.description = description; ingo@1527: this.values = values; ingo@1527: } ingo@1527: ingo@1527: ingo@1527: /** ingo@1527: * Returns the label of the item. ingo@1527: * ingo@1527: * @return the label. ingo@1527: */ ingo@1527: public String getLabel() { ingo@1527: return label; ingo@1527: } ingo@1527: ingo@1527: ingo@1527: /** ingo@1527: * Returns the description of the item. ingo@1527: * ingo@1527: * @return the description. ingo@1527: */ ingo@1527: public String getDescription() { ingo@1527: return description; ingo@1527: } ingo@1527: ingo@1527: ingo@1527: /** ingo@1527: * Returns the type of the item. ingo@1527: * ingo@1527: * @return the type. ingo@1527: */ ingo@1527: public String getType() { ingo@1527: return "intarray"; ingo@1527: } ingo@1527: ingo@1527: ingo@1527: /** ingo@1527: * Returns a DataItem which value is a string that consists of the integer ingo@1527: * values separated by a ';'. ingo@1527: * ingo@1527: * @return the DataItem. ingo@1527: */ ingo@1527: public DataItem[] getItems() { raimund@2535: return values; ingo@1527: } ingo@1527: ingo@1527: ingo@1527: /** ingo@1595: * Returns the values as array. ingo@1595: * ingo@1595: * @return the values as array. ingo@1595: */ ingo@1595: public int[] getValues() { raimund@2535: int[] data = new int[values.length]; raimund@2535: for (int i = 0; i < values.length; i++) { raimund@2535: data[i] = values[i].getValue(); raimund@2535: } raimund@2535: return data; ingo@1595: } ingo@1595: ingo@1595: ingo@1595: /** raimund@2535: * Returns the values as colon separated string. raimund@2535: * raimund@2535: * @return colon separated string. raimund@2535: */ raimund@2535: public String getStringValue() { raimund@2535: String data = ""; raimund@2535: boolean first = true; raimund@2535: for (int i = 0; i < values.length; i++) { raimund@2535: if (!first) { raimund@2535: data += ";"; raimund@2535: } raimund@2535: data += values[i].getStringValue(); raimund@2535: first = false; raimund@2535: } raimund@2535: return data; raimund@2535: } raimund@2535: raimund@2535: /** ingo@1527: * @return always null. ingo@1527: */ ingo@1527: public DataItem getDefault() { ingo@1527: return null; ingo@1527: } ingo@1527: } ingo@1527: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :