Mercurial > dive4elements > river
view backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/FlowDepthColumnParser.java @ 9709:b74f817435fe
comment removed
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Wed, 27 Jan 2021 11:47:38 +0100 |
parents | 31549fdfaf4f |
children |
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.importer.sinfo.parsers; import java.io.File; import org.apache.log4j.Logger; import org.dive4elements.river.importer.ImportRiver; import org.dive4elements.river.importer.common.AbstractParser; import org.dive4elements.river.importer.common.ParsingState; import org.dive4elements.river.importer.sinfo.importitem.FlowDepthColumnSeriesImport; import org.dive4elements.river.importer.sinfo.importitem.FlowDepthKmLineImport; import org.dive4elements.river.importer.sinfo.importitem.FlowDepthSeriesImport; import org.dive4elements.river.model.sinfo.FlowDepthColumn; import org.dive4elements.river.model.sinfo.FlowDepthValue; /** * Reads and parses a column of a flow depth file * * @author Matthias Schäfer * */ public class FlowDepthColumnParser extends AbstractParser<FlowDepthColumn, FlowDepthValue, FlowDepthKmLineImport, FlowDepthColumnSeriesImport> { /***** FIELDS *****/ private static final Logger log = Logger.getLogger(FlowDepthColumnParser.class); private final FlowDepthSeriesImport parent; private final int colIndex; private final String colName; /***** CONSTRUCTORS *****/ public FlowDepthColumnParser(final File importPath, final File rootRelativePath, final ImportRiver river, final FlowDepthSeriesImport parent, final int colIndex, final String colName) { super(importPath, rootRelativePath, river); this.parent = parent; this.colIndex = colIndex; this.colName = colName; } /***** METHODS *****/ @Override protected Logger getLog() { return log; } @Override protected void logStartInfo() { getLog().info(String.format("Start parsing column %d '%s':;'%s'", this.colIndex + 1, this.colName, this.rootRelativePath)); } @Override protected boolean handleMetaOther() { this.headerParsingState = ParsingState.IGNORE; return false; } @Override protected FlowDepthColumnSeriesImport createSeriesImport(final String filename) { return new FlowDepthColumnSeriesImport(filename, this.parent, this.colName, this.rootRelativePath); } @Override protected FlowDepthKmLineImport createKmLineImport(final Double km, final String[] values) { final Number value = parseDoubleCheckNull(values, this.colIndex); if ((value == null) || Double.isNaN(value.doubleValue())) { logLineWarning("Column %d: " + INVALID_VALUE_ERROR_FORMAT, this.colIndex + 1, "depth"); return null; } return new FlowDepthKmLineImport(km, value.doubleValue()); } }