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

simplify/instrument SAX code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.