Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWSContainer.java @ 6538:de62db0f2035
issue1157: Let CrossSection be able to find out whether it should be active & master.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 04 Jul 2013 11:52:06 +0200 |
parents | af13ceeba52a |
children | e4606eae8ea5 |
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.artifacts.model.map; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; public class HWSContainer { private static Logger logger = Logger.getLogger(HWSContainer.class); private String river; private HWS.TYPE type; private List<HWS> hws; public HWSContainer() { river = null; hws = new ArrayList<HWS>(); } public HWSContainer(String river, HWS.TYPE type, List<HWS> hws) { this.river = river; this.hws = hws; this.type = type; } public void setRiver(String river) { this.river = river; } public String getRiver() { return this.river; } public HWS.TYPE getType() { return type; } public void setType(HWS.TYPE type) { this.type = type; } public List<HWS> getHws() { return hws; } public void addHws(HWS hws) { logger.debug("add hws: " + hws.getName()); this.hws.add(hws); } public void addHws(List<HWS> hws) { this.hws.addAll(hws); } public List<HWS> getOfficialHWS() { if (hws == null || hws.size() == 0) { return new ArrayList<HWS>(); } List<HWS> results = new ArrayList<HWS>(); for (HWS h: hws) { if (h.isOfficial()) { results.add(h); } } return results; } public List<HWS> getHws(String name) { logger.debug("find: " + name + " in " + hws.size() + " elements"); if (hws == null || hws.size() == 0) { return new ArrayList<HWS>(); } List<HWS> results = new ArrayList<HWS>(); for (HWS h: hws) { if (h.getName().equals(name)) { results.add(h); } } logger.debug("found: " + results.size()); return results; } public List<HWS> getHws(List<String> list) { if (hws == null || hws.size() == 0) { return new ArrayList<HWS>(); } List<HWS> results = new ArrayList<HWS>(); for (String name : list) { results.addAll(getHws(name)); } return results; } }