类org.xml.sax.HandlerBase源码实例Demo

下面列出了怎么用org.xml.sax.HandlerBase的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: SAXParserImpl.java
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);
}
 
源代码2 项目: TencentKona-8   文件: SAXParserImpl.java
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);
}
 
源代码3 项目: openjdk-8   文件: SAXParserImpl.java
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);
}
 
源代码4 项目: jdk8u60   文件: SAXParserImpl.java
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);
}
 
源代码5 项目: JDKSourceCode1.8   文件: SAXParserImpl.java
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);
}
 
源代码6 项目: openjdk-jdk8u   文件: SAXParserImpl.java
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);
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: SAXParserImpl.java
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);
}
 
源代码8 项目: openjdk-jdk9   文件: SAXParserImpl.java
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);
}
 
源代码9 项目: openjdk-jdk9   文件: XMLReaderAdapterTest.java
/**
 * 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));
    }
}
 
源代码10 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码11 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码12 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码13 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码14 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码15 项目: openjdk-jdk9   文件: SAXParserTest.java
/**
 * 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());
    }
}
 
源代码16 项目: hottub   文件: SAXParserImpl.java
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);
}
 
源代码17 项目: openjdk-8-source   文件: SAXParserImpl.java
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);
}
 
源代码18 项目: jdk1.8-source-analysis   文件: SAXParser.java
/**
 * 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);
}
 
源代码19 项目: TencentKona-8   文件: SAXParser.java
/**
 * 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);
}
 
源代码20 项目: jdk8u60   文件: SAXParser.java
/**
 * 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);
}
 
源代码21 项目: JDKSourceCode1.8   文件: SAXParser.java
/**
 * 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);
}
 
源代码22 项目: openjdk-jdk8u   文件: SAXParser.java
/**
 * 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);
}
 
源代码23 项目: openjdk-jdk8u-backup   文件: SAXParser.java
/**
 * 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);
}
 
源代码24 项目: openjdk-8   文件: SAXParser.java
/**
 * 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);
}
 
源代码25 项目: Bytecoder   文件: SAXParser.java
/**
 * 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);
}
 
源代码26 项目: openjdk-8-source   文件: SAXParser.java
/**
 * 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);
}
 
源代码27 项目: openjdk-jdk9   文件: SAXParser.java
/**
 * 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);
}
 
源代码28 项目: Java8CN   文件: SAXParser.java
/**
 * 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);
}
 
源代码29 项目: hottub   文件: SAXParser.java
/**
 * 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);
}
 
源代码30 项目: jdk1.8-source-analysis   文件: SAXParser.java
/**
 * <p>Parse the content of the given {@link java.io.InputStream}
 * instance 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>.</p>
 *
 * @param is InputStream containing the content to be parsed.
 * @param hb The SAX HandlerBase to use.
 *
 * @throws IllegalArgumentException If the given InputStream is null.
 * @throws SAXException If parse produces a SAX error.
 * @throws IOException If an IO error occurs interacting with the
 *   <code>InputStream</code>.
 *
 * @see org.xml.sax.DocumentHandler
 */
public void parse(InputStream is, HandlerBase hb)
    throws SAXException, IOException {
    if (is == null) {
        throw new IllegalArgumentException("InputStream cannot be null");
    }

    InputSource input = new InputSource(is);
    this.parse(input, hb);
}