/* ================================================================
* 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.
*
* ----------------------------------------------------------------
* LmwUkmoTimeSeriesParser.java
* ----------------------------------------------------------------
* (C) Copyright 2003, by WL | Delft Hydraulics
*
* Original Author: pelgrim
* Contributor(s):
*
* Changes:
* --------
* 9/24/13 : Version 1 ();
*
*
*/
package nl.wldelft.timeseriesparsers;
import nl.wldelft.fews.system.plugin.dataImport.EaTimeSeriesParser;
import nl.wldelft.util.IOUtils;
import nl.wldelft.util.io.LineReader;
import nl.wldelft.util.io.TextParser;
import nl.wldelft.util.timeseries.TimeSeriesContentHandler;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
public class LmwUkmoTimeSeriesParser implements TextParser<TimeSeriesContentHandler> {
@Override
public void parse(LineReader reader, String virtualFileName, TimeSeriesContentHandler contentHandler) throws Exception {
String text = IOUtils.readText(reader);
String beginString = "<?xml version=\"1.0\"?>";
int begin = text.indexOf(beginString);
String endString = "</EATimeSeriesDataExchangeFormat>";
int end = text.lastIndexOf(endString);
String xml = text.substring(begin, end + endString.length());
InputStream is = new ByteArrayInputStream(xml.getBytes(IOUtils.ASCII_CHARSET));
LineReader xmlReader = new LineReader(is, virtualFileName);
EaTimeSeriesParser eatsp = new EaTimeSeriesParser();
eatsp.parse(xmlReader, virtualFileName, contentHandler);
}
}