Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTJRDataSource.java @ 3272:31168ac9c7e7
Partial fix for issue694 (heightmarks snap to nearest cross section).
flys-artifacts/trunk@4916 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 10 Jul 2012 15:31:56 +0000 |
parents | 3e5f45a9e052 |
children |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import java.util.ArrayList; import java.util.HashMap; import org.apache.log4j.Logger; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRField; /** * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ public class WQTJRDataSource implements JRDataSource { /** The logger used in this exporter.*/ private static Logger logger = Logger.getLogger(WQTJRDataSource.class); /** * */ private ArrayList<String[]> data; private HashMap<String, String> metaData; private int index = -1; /** * */ public WQTJRDataSource() { data = new ArrayList<String[]>(); metaData = new HashMap<String, String>(); } /** * */ public void addData(String[] data) { this.data.add(data); } /** * */ public void addMetaData(String key, String value) { this.metaData.put(key, value); } /** * */ public boolean next() throws JRException { index++; return (index < data.size()); } /** * */ public Object getFieldValue(JRField field) throws JRException { Object value = ""; String fieldName = field.getName(); if ("river".equals(fieldName)) { value = metaData.get("river"); } else if ("date".equals(fieldName)) { value = metaData.get("date"); } else if ("calculation".equals(fieldName)) { value = metaData.get("calculation"); } else if ("range".equals(fieldName)) { value = data.get(index)[0]; } else if ("W".equals(fieldName)) { value = data.get(index)[1]; } else if ("Q".equals(fieldName)) { value = data.get(index)[2]; } else if ("delta".equals(fieldName)) { value = data.get(index)[3]; } else if ("gaugename".equals(fieldName)) { value = data.get(index)[4]; } return value; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :