view flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightEpochParser.java @ 3955:26685b846a29

Let importer handle gappy single bed height values. flys-backend/trunk@5612 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 27 Sep 2012 10:23:23 +0000
parents 8926571e47fb
children 64b73dc1571c
line wrap: on
line source
package de.intevation.flys.importer.parsers;


import java.math.BigDecimal;

import java.text.ParseException;



import org.apache.log4j.Logger;

import de.intevation.flys.importer.ImportBedHeight;
import de.intevation.flys.importer.ImportBedHeightEpoch;
import de.intevation.flys.importer.ImportBedHeightEpochValue;


public class BedHeightEpochParser extends BedHeightParser {

    private static final Logger log =
        Logger.getLogger(BedHeightEpochParser.class);



    @Override
    protected ImportBedHeight newImportBedHeight(String description) {
        return new ImportBedHeightEpoch(description);
    }


    @Override
    protected void handleDataLine(ImportBedHeight obj, String line) {
        // TODO issue863: find gaps in data, analogous to 'single' case.
        String[] values = line.split(SEPERATOR_CHAR);

        if (values == null || values.length < 2 || values[0].length() == 0 || values[1].length() == 0) {
            //log.warn("Skip invalid data line: " + line);
            return;
        }

        try {
            ImportBedHeightEpochValue value = new ImportBedHeightEpochValue(
                new BigDecimal(nf.parse(values[0]).doubleValue()),
                new BigDecimal(nf.parse(values[1]).doubleValue())
            );

            obj.addValue(value);
        }
        catch (ParseException e) {
            log.warn("Error while parsing number from data row: " + line);
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org