Changeset 8347 in josm


Ignore:
Timestamp:
2015-05-11T13:50:25+02:00 (9 years ago)
Author:
Don-vip
Message:

simplify/instrument SAX code

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r8318 r8347  
    379379                    InputSource inputSource = new InputSource(reader);
    380380                    NameFinderResultParser parser = new NameFinderResultParser();
    381                     Utils.newSafeSAXParser().parse(inputSource, parser);
     381                    Utils.parseSafeSAX(inputSource, parser);
    382382                    this.data = parser.getResult();
    383383                }
  • trunk/src/org/openstreetmap/josm/io/Capabilities.java

    r8345 r8347  
    272272        public static Capabilities parse(InputSource inputSource) throws SAXException, IOException, ParserConfigurationException {
    273273            CapabilitiesParser parser = new CapabilitiesParser();
    274             Utils.newSafeSAXParser().parse(inputSource, parser);
     274            Utils.parseSafeSAX(inputSource, parser);
    275275            return parser.getCapabilities();
    276276        }
  • trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java

    r8346 r8347  
    8484            progressMonitor.beginTask(tr("Parsing response from server..."));
    8585            InputSource inputSource = new InputSource(new StringReader(diffUploadResponse));
    86             Utils.newSafeSAXParser().parse(inputSource, new Parser());
     86            Utils.parseSafeSAX(inputSource, new Parser());
    8787        } catch(XmlParsingException e) {
    8888            throw e;
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r8345 r8347  
    542542        Parser parser = new Parser();
    543543        try {
    544             Utils.newSafeSAXParser().parse(inputSource, parser);
     544            Utils.parseSafeSAX(inputSource, parser);
    545545            return true;
    546546        } catch (SAXException e) {
  • trunk/src/org/openstreetmap/josm/io/NoteReader.java

    r8287 r8347  
    222222        DefaultHandler parser = new Parser();
    223223        try {
    224             Utils.newSafeSAXParser().parse(inputSource, parser);
     224            Utils.parseSafeSAX(inputSource, parser);
    225225        } catch (ParserConfigurationException e) {
    226226            Main.error(e); // broken SAXException chaining
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java

    r8308 r8347  
    151151            progressMonitor.beginTask("");
    152152            progressMonitor.indeterminateSubTask(tr("Parsing changeset content ..."));
    153             Utils.newSafeSAXParser().parse(source, new Parser());
     153            Utils.parseSafeSAX(source, new Parser());
    154154        } catch(XmlParsingException e) {
    155155            throw e;
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r8291 r8347  
    278278            progressMonitor.indeterminateSubTask(tr("Parsing list of changesets..."));
    279279            InputSource inputSource = new InputSource(new InvalidXmlCharacterFilter(new InputStreamReader(source, StandardCharsets.UTF_8)));
    280             Utils.newSafeSAXParser().parse(inputSource, parser.new Parser());
     280            Utils.parseSafeSAX(inputSource, parser.new Parser());
    281281            return parser.getChangesets();
    282282        } catch(ParserConfigurationException | SAXException e) {
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r8308 r8347  
    9191        progressMonitor.beginTask(tr("Parsing OSM history data ..."));
    9292        try {
    93             Utils.newSafeSAXParser().parse(inputSource, new Parser());
     93            Utils.parseSafeSAX(inputSource, new Parser());
    9494        } catch (ParserConfigurationException e) {
    9595            Main.error(e); // broken SAXException chaining
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r8344 r8347  
    5757                    .getInputStream()) {
    5858                InputSource is = new InputSource(UTFInputStreamReader.create(in));
    59                 Utils.newSafeSAXParser().parse(is, parser);
     59                Utils.parseSafeSAX(is, parser);
    6060                return parser.entries;
    6161            }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8308 r8347  
    5959import org.openstreetmap.josm.Main;
    6060import org.openstreetmap.josm.data.Version;
     61import org.xml.sax.InputSource;
    6162import org.xml.sax.SAXException;
     63import org.xml.sax.helpers.DefaultHandler;
    6264
    6365/**
     
    12271229        return parserFactory.newSAXParser();
    12281230    }
     1231
     1232    /**
     1233     * Parse the content given {@link org.xml.sax.InputSource} as XML using the specified {@link org.xml.sax.helpers.DefaultHandler}.
     1234     * This method uses a secure SAX parser, supporting XML namespaces.
     1235     *
     1236     * @param is The InputSource containing the content to be parsed.
     1237     * @param dh The SAX DefaultHandler to use.
     1238     * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
     1239     * @throws SAXException for SAX errors.
     1240     * @throws IOException if any IO errors occur.
     1241     * @since 8347
     1242     */
     1243    public static void parseSafeSAX(InputSource is, DefaultHandler dh) throws ParserConfigurationException, SAXException, IOException {
     1244        long start = System.currentTimeMillis();
     1245        if (Main.isDebugEnabled()) {
     1246            Main.debug("Starting SAX parsing of "+is+" using "+dh);
     1247        }
     1248        newSafeSAXParser().parse(is, dh);
     1249        if (Main.isDebugEnabled()) {
     1250            Main.debug("SAX parsing done in " + getDurationString(System.currentTimeMillis()-start));
     1251        }
     1252    }
    12291253}
Note: See TracChangeset for help on using the changeset viewer.