view gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttrList.java @ 9416:05405292a7ca

Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author gernotbelger
date Thu, 16 Aug 2018 16:28:03 +0200
parents 84397da33d17
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;
    }
}

http://dive4elements.wald.intevation.org