Mercurial > dive4elements > river
view 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 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.shared.model; import java.io.Serializable; import java.util.ArrayList; import java.util.List; // FIXME: who implements a thing like this?? this is a HashMap!! public class AttrList implements Serializable { private static final long serialVersionUID = 1L; private List<String> keyValues; public AttrList() { this(5); } public AttrList(final int size) { this.keyValues = new ArrayList<String>(size*2); } public int size() { return this.keyValues.size() / 2; } /** * IMPORTANT: necessary for serialization */ public void setKeyValues(final List<String> keyValues) { this.keyValues = keyValues; } public String getKey(final int index) { return this.keyValues.get(index*2); } public String getValue(final int index) { return this.keyValues.get(index*2 + 1); } public String getValue(final String key) { for (int i = 0, N = this.keyValues.size(); i < N; i += 2) { if (this.keyValues.get(i).equals(key)) { return this.keyValues.get(i + 1); } } return null; } public void add(final String key, final String value) { this.keyValues.add(key); this.keyValues.add(value); } public boolean hasAttribute(final String key) { for (int i = 0, N = this.keyValues.size(); i < N; i += 2) { if (this.keyValues.get(i).equals(key)) { return true; } } return false; } }