/* ================================================================ * Delft FEWS * ================================================================ * * Project Info: http://www.wldelft.nl/soft/fews/index.html * Project Lead: Karel Heynert (karel.heynert@wldelft.nl) * * (C) Copyright 2003, by WL | Delft Hydraulics * P.O. Box 177 * 2600 MH Delft * The Netherlands * http://www.wldelft.nl * * DELFT-FEWS is a sophisticated collection of modules designed * for building a FEWS customised to the specific requirements * of individual agencies. An open modelling approach allows users * to add their own modules in an efficient way. * * ---------------------------------------------------------------- * TvaTransactionTimeSeriesParser.java * ---------------------------------------------------------------- * (C) Copyright 2003, by WL | Delft Hydraulics * * Original Author: pelgrim * Contributor(s): * * Changes: * -------- * 17-Apr-14 : Version 1 (); * * */ package nl.wldelft.timeseriesparsers; import nl.wldelft.util.io.LineReader; import nl.wldelft.util.io.TextParser; import nl.wldelft.util.timeseries.DefaultTimeSeriesHeader; import nl.wldelft.util.timeseries.TimeSeriesContentHandler; public class TvaTransactionTimeSeriesParser implements TextParser<TimeSeriesContentHandler> { @Override public void parse(LineReader reader, String virtualFileName, TimeSeriesContentHandler contentHandler) throws Exception { DefaultTimeSeriesHeader header = new DefaultTimeSeriesHeader(); for (String[] line = new String[2]; reader.readLine(' ', line) != -1; ) { String parameterId = line[0].substring(0, 2); String locationId = line[0].substring(2, 10); String dateTime = line[0].substring(10, 22); String value = line[1]; header.setParameterId(parameterId); header.setLocationId(locationId); contentHandler.setTime(contentHandler.getDefaultTimeZone(), "yyyyMMddHHmm", dateTime); contentHandler.setValue('.', value); contentHandler.setTimeSeriesHeader(header); contentHandler.applyCurrentFields(); } } }