001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.io;
003
004import java.io.IOException;
005
006import org.openstreetmap.josm.data.gpx.GpxData;
007import org.xml.sax.SAXException;
008
009/**
010 * Abstraction of {@code GpxReader}, {@code NmeaReader}, {@code OziWptReader} and {@code RtkLibPosReader}
011 * @since 14010
012 */
013public interface IGpxReader {
014
015    /**
016     * Parse the GPX data.
017     *
018     * @param tryToFinish true, if the reader should return at least part of the GPX
019     * data in case of an error.
020     * @return true if file was properly parsed, false if there was error during
021     * parsing but some data were parsed anyway
022     * @throws SAXException if any SAX parsing error occurs
023     * @throws IOException if any I/O error occurs
024     * @throws UnsupportedOperationException if the format is not supported
025     */
026    boolean parse(boolean tryToFinish) throws SAXException, IOException;
027
028    /**
029     * Replies the GPX data.
030     * @return The GPX data
031     */
032    GpxData getGpxData();
033
034    /**
035     * Returns the number of coordinates that have been successfuly read.
036     * @return the number of coordinates that have been successfuly read
037     * @since 18179
038     */
039    default int getNumberOfCoordinates() {
040        throw new UnsupportedOperationException();
041    }
042}