view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWQQJRDataSource.java @ 2566:8bacd0ce3704

Partial fix flys/issue637 (wording). flys-artifacts/trunk@4092 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 27 Feb 2012 09:09:54 +0000
parents ecb76933362f
children 87085ccea466
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 WWQQJRDataSource implements JRDataSource
{
    /** The logger used in this exporter.*/
    private static Logger logger = Logger.getLogger(WWQQJRDataSource.class);

    /**
     *
     */
    private ArrayList<String[]> data;
    private HashMap<String, String> metaData;

    private int index = -1;

    /**
     *
     */
    public WWQQJRDataSource()
    {
        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");
        }
        if ("date".equals(fieldName)) {
            value = metaData.get("date");
        }
        if ("calculation".equals(fieldName)) {
            value = metaData.get("calculation");
        }
        if ("reference".equals(fieldName)) {
            value = metaData.get("reference");
        }
        if ("location".equals(fieldName)) {
            value = metaData.get("location");
        }
        if ("km1".equals(fieldName)) {
            value = data.get(index)[0];
        }
        if ("location1".equals(fieldName)) {
            value = data.get(index)[1];
        }
        if ("W1".equals(fieldName)) {
            value = data.get(index)[2];
        }
        if ("Q1".equals(fieldName)) {
            value = data.get(index)[3];
        }
        if ("km2".equals(fieldName)) {
            value = data.get(index)[4];
        }
        if ("location2".equals(fieldName)) {
            value = data.get(index)[5];
        }
        if ("W2".equals(fieldName)) {
            value = data.get(index)[6];
        }
        if ("Q2".equals(fieldName)) {
            value = data.get(index)[7];
        }
        return value;
    }
}

http://dive4elements.wald.intevation.org