Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttrList.java @ 9227:84397da33d17
Allow to control specific behaviour in TwinDatacagePanel
Implemented client logic of 'intelligent datacage filtering' for SINFO
author | gernotbelger |
---|---|
date | Wed, 04 Jul 2018 18:28:08 +0200 |
parents | 4b29bb2c785f |
children |
comparison
equal
deleted
inserted
replaced
9226:83aee0942eae | 9227:84397da33d17 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.shared.model; | 9 package org.dive4elements.river.client.shared.model; |
10 | 10 |
11 import java.io.Serializable; | |
12 import java.util.ArrayList; | |
11 import java.util.List; | 13 import java.util.List; |
12 import java.util.ArrayList; | |
13 | 14 |
14 import java.io.Serializable; | 15 // FIXME: who implements a thing like this?? this is a HashMap!! |
15 | |
16 public class AttrList implements Serializable | 16 public class AttrList implements Serializable |
17 { | 17 { |
18 protected List<String> keyValues; | 18 private static final long serialVersionUID = 1L; |
19 | |
20 private List<String> keyValues; | |
19 | 21 |
20 public AttrList() { | 22 public AttrList() { |
21 this(5); | 23 this(5); |
22 } | 24 } |
23 | 25 |
24 public AttrList(int size) { | 26 public AttrList(final int size) { |
25 keyValues = new ArrayList<String>(size*2); | 27 this.keyValues = new ArrayList<String>(size*2); |
26 } | 28 } |
27 | 29 |
28 public int size() { | 30 public int size() { |
29 return keyValues != null ? keyValues.size()/2 : null; | 31 return this.keyValues.size() / 2; |
30 } | 32 } |
31 | 33 |
32 public String getKey(int index) { | 34 /** |
33 return keyValues.get(index*2); | 35 * IMPORTANT: necessary for serialization |
36 */ | |
37 public void setKeyValues(final List<String> keyValues) { | |
38 this.keyValues = keyValues; | |
34 } | 39 } |
35 | 40 |
36 public String getValue(int index) { | 41 public String getKey(final int index) { |
37 return keyValues.get(index*2 + 1); | 42 return this.keyValues.get(index*2); |
38 } | 43 } |
39 | 44 |
40 public void add(String key, String value) { | 45 public String getValue(final int index) { |
41 keyValues.add(key); | 46 return this.keyValues.get(index*2 + 1); |
42 keyValues.add(value); | |
43 } | 47 } |
44 | 48 |
45 public boolean hasAttribute(String key) { | 49 public String getValue(final String key) { |
46 for (int i = 0, N = keyValues.size(); i < N; i += 2) { | 50 for (int i = 0, N = this.keyValues.size(); i < N; i += 2) { |
47 if (keyValues.get(i).equals(key)) { | 51 if (this.keyValues.get(i).equals(key)) { |
52 return this.keyValues.get(i + 1); | |
53 } | |
54 } | |
55 return null; | |
56 } | |
57 | |
58 public void add(final String key, final String value) { | |
59 this.keyValues.add(key); | |
60 this.keyValues.add(value); | |
61 } | |
62 | |
63 public boolean hasAttribute(final String key) { | |
64 for (int i = 0, N = this.keyValues.size(); i < N; i += 2) { | |
65 if (this.keyValues.get(i).equals(key)) { | |
48 return true; | 66 return true; |
49 } | 67 } |
50 } | 68 } |
51 return false; | 69 return false; |
52 } | 70 } |
53 } | 71 } |
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |