org.xml.sax.HandlerBase Java Examples

The following examples show how to use org.xml.sax.HandlerBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test with valid input source, parser should parse the XML document
 * successfully.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(dataProvider = "parser-provider")
public void testParse16(SAXParser saxparser) throws Exception {
    try (FileInputStream instream = new FileInputStream(
            new File(XML_DIR, "parsertest.xml"))) {
        saxparser.parse(instream, new HandlerBase(),
                new File(XML_DIR).toURI().toASCIIString());
    }
}
 
Example #2
Source File: SAXParserImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #3
Source File: SAXParserImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #4
Source File: SAXParserImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #5
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test with valid input stream, parser should parse the XML document
 * successfully.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(dataProvider = "parser-provider")
public void testParse15(SAXParser saxparser) throws Exception {
    try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
            "correct.xml"))) {
        saxparser.parse(instream, new HandlerBase());
    }
}
 
Example #6
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test with an error in XML file, parsing should fail and throw
 * SAXException.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = SAXException.class,
        dataProvider = "parser-provider")
public void testParse13(SAXParser saxparser) throws Exception {
    try (FileInputStream instream = new FileInputStream(new File(
            XML_DIR, "invalid.xml"))) {
        saxparser.parse(instream, new HandlerBase());
    }
}
 
Example #7
Source File: SAXParserImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #8
Source File: SAXParserImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #9
Source File: SAXParserImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #10
Source File: SAXParserImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #11
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test with input source attached an invalid XML, parsing should fail
 * and throw SAXException.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = SAXException.class,
        dataProvider = "parser-provider")
public void testParse20(SAXParser saxparser) throws Exception {
    try(FileInputStream instream = new FileInputStream(new File(XML_DIR,
            "invalid.xml"))) {
        saxparser.parse(new InputSource(instream), new HandlerBase());
    }
}
 
Example #12
Source File: SAXParserImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #13
Source File: SAXParserImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #14
Source File: SAXParserImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException();
    }
    if (hb != null) {
        xmlReader.setDocumentHandler(hb);
        xmlReader.setEntityResolver(hb);
        xmlReader.setErrorHandler(hb);
        xmlReader.setDTDHandler(hb);
        xmlReader.setContentHandler(null);
    }
    xmlReader.parse(is);
}
 
Example #15
Source File: XMLReaderAdapterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * To test the parse method. The specification says that this method
 * will throw an exception if the embedded XMLReader does not support
 * the http://xml.org/sax/features/namespace-prefixes property.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void parse01() throws Exception {
    try (FileInputStream fis = new FileInputStream(XML_DIR + "namespace1.xml")) {
        XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
        if (!xmlReader.getFeature(NM_PREFIXES_PROPERTY)) {
            xmlReader.setFeature(NM_PREFIXES_PROPERTY, true);
        }
        XMLReaderAdapter xmlRA = new XMLReaderAdapter(xmlReader);
        xmlRA.setDocumentHandler(new HandlerBase());
        xmlRA.parse(new InputSource(fis));
    }
}
 
Example #16
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test with input source attached an valid XML, parser should
 * successfully parse the XML document.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(dataProvider = "parser-provider")
public void testParse21(SAXParser saxparser) throws Exception {
    try (FileInputStream instream = new FileInputStream(new File(XML_DIR,
            "correct.xml"))) {
        saxparser.parse(new InputSource(instream), new HandlerBase());
    }
}
 
Example #17
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test case to parse an XML file that uses namespaces.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testParse31() throws Exception {
    try (FileInputStream instream = new FileInputStream(
            new File(XML_DIR, "ns4.xml"))) {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        spf.newSAXParser().parse(instream, new HandlerBase());
    }
}
 
Example #18
Source File: SAXParser.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #19
Source File: SAXParser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #20
Source File: SAXParser.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #21
Source File: SAXParser.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #22
Source File: SAXParser.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #23
Source File: SAXParser.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #24
Source File: SAXParser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #25
Source File: SAXParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #26
Source File: SAXParser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #27
Source File: SAXParser.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #28
Source File: SAXParser.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #29
Source File: SAXParser.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Parse the content given {@link org.xml.sax.InputSource}
 * as XML using the specified
 * {@link org.xml.sax.HandlerBase}.
 * <i> Use of the DefaultHandler version of this method is recommended as
 * the HandlerBase class has been deprecated in SAX 2.0</i>
 *
 * @param is The InputSource containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the <code>InputSource</code> object
 *   is <code>null</code>.
 * @throws IOException If any IO errors occur.
 * @throws SAXException If any SAX errors occur during processing.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputSource is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputSource cannot be null");
    }

    Parser parser = this.getParser();
    if (hb != null) {
        parser.setDocumentHandler(hb);
        parser.setEntityResolver(hb);
        parser.setErrorHandler(hb);
        parser.setDTDHandler(hb);
    }
    parser.parse(is);
}
 
Example #30
Source File: SAXParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Test case with FileInputStream null, parsing should fail and throw
 * IllegalArgumentException.
 *
 * @param saxparser a SAXParser instance.
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = IllegalArgumentException.class,
        dataProvider = "parser-provider")
public void testParse01(SAXParser saxparser) throws Exception {
    FileInputStream instream = null;
    saxparser.parse(instream, new HandlerBase());
}