Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerArrayData.java @ 2535:d0a9acddbea2
Added an int data item used in int array data and added getter that returns
values as colon separated string to all data types.
flys-client/trunk@4445 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 21 May 2012 08:48:16 +0000 |
parents | e53d773e6992 |
children |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerArrayData.java Fri May 18 12:42:57 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerArrayData.java Mon May 21 08:48:16 2012 +0000 @@ -9,14 +9,18 @@ protected String label; protected String description; - protected int[] values; + protected IntDataItem[] values; public IntegerArrayData() { } - public IntegerArrayData(String label, String description, int[] values) { + public IntegerArrayData( + String label, + String description, + IntDataItem[] values + ) { this.label = label; this.description = description; this.values = values; @@ -60,26 +64,7 @@ * @return the DataItem. */ public DataItem[] getItems() { - if (values == null || values.length == 0) { - return new DataItem[0]; - } - - StringBuilder sb = new StringBuilder(); - boolean first = true; - - for (int value: values) { - if (first) { - sb.append(String.valueOf(value)); - } - else { - sb.append(";" + String.valueOf(value)); - } - } - - String value = sb.toString(); - DataItem item = new DefaultDataItem(value, value, value); - - return new DataItem[] { item }; + return values; } @@ -89,11 +74,33 @@ * @return the values as array. */ public int[] getValues() { - return values; + int[] data = new int[values.length]; + for (int i = 0; i < values.length; i++) { + data[i] = values[i].getValue(); + } + return data; } /** + * Returns the values as colon separated string. + * + * @return colon separated string. + */ + public String getStringValue() { + String data = ""; + boolean first = true; + for (int i = 0; i < values.length; i++) { + if (!first) { + data += ";"; + } + data += values[i].getStringValue(); + first = false; + } + return data; + } + + /** * @return always null. */ public DataItem getDefault() {