view artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java @ 9101:2c6aba003112

Mini-Bugfix Vegetationszonen-Export
author gernotbelger
date Mon, 28 May 2018 16:39:56 +0200
parents 1ffd38826175
children da0bdbcd6f09
line wrap: on
line source
/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
 * Software engineering by
 *  Björnsen Beratende Ingenieure GmbH
 *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
 *
 * 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.uinfo.commons;

import java.text.NumberFormat;

import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.common.AbstractResultType;
import org.dive4elements.river.utils.Formatter;

/**
 * @author Domenico Nardi Tironi
 *
 */
public abstract class UInfoResultType extends AbstractResultType {

    private static final long serialVersionUID = 1L;

    public UInfoResultType(final String unit, final String csvHeader) {
        super(unit, csvHeader, csvHeader);

    }

    @Override
    public String exportValue(final CallContext context, final Object value) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    protected NumberFormat createFormatter(final CallContext context) {
        // TODO Auto-generated method stub
        return null;
    }

    public static final UInfoResultType salixline = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.salix_line") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
            // digits.
            return Formatter.getSalixLine(context);
        }
    };

    public static final UInfoResultType salixlinehist = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.hist") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
            // digits.
            return Formatter.getSalixLine(context);
        }
    };

    public static final UInfoResultType salixlinescen = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.scen") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
            // digits.
            return Formatter.getSalixLine(context);
        }
    };

    public static final UInfoResultType vegname = new UInfoResultType(null, "uinfo.export.csv.meta.header.veg.name") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            return exportStringValue(value);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            throw new UnsupportedOperationException();
        }
    };

    public static final UInfoResultType vegdauervon = new UInfoResultType(null, "uinfo.export.csv.meta.header.veg.dauervon") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {
            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
            // digits.
            return Formatter.getUeberflutungsdauer(context);
        }
    };

    public static final UInfoResultType vegdauerbis = new UInfoResultType(null, "uinfo.export.csv.meta.header.veg.dauerbis") {
        private static final long serialVersionUID = 1L;

        @Override
        public String exportValue(final CallContext context, final Object value) {

            final double doubleValue = asDouble(value);
            return exportDoubleValue(context, doubleValue);
        }

        @Override
        protected NumberFormat createFormatter(final CallContext context) {
            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
            // digits.
            return Formatter.getUeberflutungsdauer(context);
        }
    };
}

http://dive4elements.wald.intevation.org