Java 类org.xml.sax.helpers.XMLFilterImpl 实例源码

项目:OpenJSharp    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:OpenJSharp    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:OpenJSharp    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:openjdk-jdk10    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:openjdk-jdk10    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:openjdk-jdk10    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * Set namespaces feature to a value to XMLFilter. it's expected same when
 * obtain it again.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void setFeature01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);

    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setParent(spf.newSAXParser().getXMLReader());
    xmlFilter.setFeature(NAMESPACES, false);
    assertFalse(xmlFilter.getFeature(NAMESPACES));
    xmlFilter.setFeature(NAMESPACES, true);
    assertTrue(xmlFilter.getFeature(NAMESPACES));
}
项目:openjdk9    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:openjdk9    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:openjdk9    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:Java8CN    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:lookaside_java-1.8.0-openjdk    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:infobip-open-jdk-8    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:infobip-open-jdk-8    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:infobip-open-jdk-8    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:OLD-OpenJDK8    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:OLD-OpenJDK8    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:OLD-OpenJDK8    文件:JAXBSource.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:yarg    文件:XmlCopyUtils.java   
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal(contentObject, (XMLFilterImpl) repeater);
    } catch (JAXBException e) {
        // wrap it to a SAXException
        SAXParseException se =
                new SAXParseException(e.getMessage(),
                        null, null, -1, -1, e);

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if (errorHandler != null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
项目:openjdk-icedtea7    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        s2d = new SAX2DOMEx();
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:openjdk-icedtea7    文件:DOMForest.java   
/**
 * Returns a {@link ContentHandler} to feed SAX events into.
 *
 * <p>
 * The client of this class can feed SAX events into the handler
 * to parse a document into this DOM forest.
 *
 * This version requires that the DOM object to be created and registered
 * to the map beforehand.
 */
private ContentHandler getParserHandler( Document dom ) {
    ContentHandler handler = new DOMBuilder(dom,locatorTable,outerMostBindings);
    handler = new WhitespaceStripper(handler,errorReceiver,entityResolver);
    handler = new VersionChecker(handler,errorReceiver,entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);

    if(errorReceiver!=null)
        f.setErrorHandler(errorReceiver);
    if(entityResolver!=null)
        f.setEntityResolver(entityResolver);

    return f;
}
项目:iaf    文件:AbstractXmlValidator.java   
public String validate(Object input, IPipeLineSession session, String logPrefix, XMLReader parser, XMLFilterImpl filter, ValidationContext context) throws XmlValidatorException, PipeRunException, ConfigurationException {

        if (filter!=null) {
            filter.setContentHandler(context.getContentHandler());
            filter.setErrorHandler(context.getErrorHandler());
        } else {
            parser.setContentHandler(context.getContentHandler());
            parser.setErrorHandler(context.getErrorHandler());
        }

        InputSource is = getInputSource(input);

        try {
            parser.parse(is);
        } catch (Exception e) {
            return finalizeValidation(context, session, e);
        }
        return finalizeValidation(context, session, null);
    }
项目:OpenJSharp    文件:DOMForest.java   
/**
     * Returns a {@link org.xml.sax.XMLReader} to parse a document into this DOM forest.
     * <p/>
     * This version requires that the DOM object to be created and registered
     * to the map beforehand.
     */
private XMLReader createReader(Document dom) throws SAXException, ParserConfigurationException {
    XMLReader reader = parserFactory.newSAXParser().getXMLReader();
    DOMBuilder dombuilder = new DOMBuilder(dom, locatorTable, outerMostBindings);
    try {
        reader.setProperty("http://xml.org/sax/properties/lexical-handler", dombuilder);
    } catch(SAXException e) {
        errorReceiver.debug(e.getMessage());
    }

    ContentHandler handler = new WhitespaceStripper(dombuilder, errorReceiver, entityResolver);
    handler = new VersionChecker(handler, errorReceiver, entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);
    if (errorReceiver != null)
        f.setErrorHandler(errorReceiver);
    f.setEntityResolver(entityResolver);

    reader.setContentHandler(f);
    if (errorReceiver != null)
        reader.setErrorHandler(errorReceiver);
    reader.setEntityResolver(entityResolver);
    return reader;
}
项目:OpenJSharp    文件:ModelLoader.java   
/**
 * Parses a RELAX NG grammar into an annotated grammar.
 */
private Model loadRELAXNG() throws SAXException {

    // build DOM forest
    final DOMForest forest = buildDOMForest( new RELAXNGInternalizationLogic() );

    // use JAXP masquerading to validate the input document.
    // DOMForest -> ExtensionBindingChecker -> RNGOM

    XMLReaderCreator xrc = new XMLReaderCreator() {
        public XMLReader createXMLReader() {

            // foreset parser cannot change the receivers while it's working,
            // so we need to have one XMLFilter that works as a buffer
            XMLFilter buffer = new XMLFilterImpl() {
                @Override
                public void parse(InputSource source) throws IOException, SAXException {
                    forest.createParser().parse( source, this, this, this );
                }
            };

            XMLFilter f = new ExtensionBindingChecker(Const.RELAXNG_URI,opt,errorReceiver);
            f.setParent(buffer);

            f.setEntityResolver(opt.entityResolver);

            return f;
        }
    };

    Parseable p = new SAXParseable( opt.getGrammars()[0], errorReceiver, xrc );

    return loadRELAXNG(p);

}
项目:openjdk-jdk10    文件:DOMForest.java   
/**
     * Returns a {@link org.xml.sax.XMLReader} to parse a document into this DOM forest.
     * <p/>
     * This version requires that the DOM object to be created and registered
     * to the map beforehand.
     */
private XMLReader createReader(Document dom) throws SAXException, ParserConfigurationException {
    XMLReader reader = parserFactory.newSAXParser().getXMLReader();
    DOMBuilder dombuilder = new DOMBuilder(dom, locatorTable, outerMostBindings);
    try {
        reader.setProperty("http://xml.org/sax/properties/lexical-handler", dombuilder);
    } catch(SAXException e) {
        errorReceiver.debug(e.getMessage());
    }

    ContentHandler handler = new WhitespaceStripper(dombuilder, errorReceiver, entityResolver);
    handler = new VersionChecker(handler, errorReceiver, entityResolver);

    // insert the reference finder so that
    // included/imported schemas will be also parsed
    XMLFilterImpl f = logic.createExternalReferenceFinder(this);
    f.setContentHandler(handler);
    if (errorReceiver != null)
        f.setErrorHandler(errorReceiver);
    f.setEntityResolver(entityResolver);

    reader.setContentHandler(f);
    if (errorReceiver != null)
        reader.setErrorHandler(errorReceiver);
    reader.setEntityResolver(entityResolver);
    return reader;
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * No exception expected when set a correct content handler.
 */
@Test
public void contentHandler01() {
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setContentHandler(xmlFilter);
    assertNotNull(xmlFilter.getContentHandler());
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * No exception expected when set a correct entity solver.
 */
@Test
public void entity01() {
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setEntityResolver(xmlFilter);
    assertNotNull(xmlFilter.getEntityResolver());
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * No exception expected when set a correct DTD handler.
 */
@Test
public void dtdHandler01() {
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setDTDHandler(xmlFilter);
    assertNotNull(xmlFilter.getDTDHandler());
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * No exception expected when set a correct error handler.
 */
@Test
public void errorHandler01() {
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setErrorHandler(xmlFilter);
    assertNotNull(xmlFilter.getErrorHandler());
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * By default true is expected get namespaces feature.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void getFeature01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();

    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setParent(xmlReader);
    assertTrue(xmlFilter.getFeature(NAMESPACES));
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * By default false is expected get namespaces-prefix feature.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void getFeature02() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setParent(spf.newSAXParser().getXMLReader());
    assertFalse(xmlFilter.getFeature(NAMESPACE_PREFIXES));
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * Set namespaces-prefix feature to a value to XMLFilter. it's expected same
 * when obtain it again.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void setFeature02() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);

    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlFilter.setParent(spf.newSAXParser().getXMLReader());
    xmlFilter.setFeature(NAMESPACE_PREFIXES, false);
    assertFalse(xmlFilter.getFeature(NAMESPACE_PREFIXES));
    xmlFilter.setFeature(NAMESPACE_PREFIXES, true);
    assertTrue(xmlFilter.getFeature(NAMESPACE_PREFIXES));
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * SAXException is expected when parsing a invalid formatted XML file.
 *
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = NullPointerException.class)
public void parse02() throws Exception {
    try(FileInputStream fis = new FileInputStream(XML_DIR + "invalid.xml")) {
        new XMLFilterImpl().parse(new InputSource(fis));
    }
}
项目:openjdk-jdk10    文件:XMLFilterTest.java   
/**
 * No exception when parse a normal XML file.
 *
 * @throws Exception If any errors occur.
 */
@Test(expectedExceptions = NullPointerException.class)
public void parse03() throws Exception {
    try(FileInputStream fis = new FileInputStream(XML_DIR + "correct2.xml")) {
        new XMLFilterImpl().parse(new InputSource(fis));
    }
}
项目:openjdk-jdk10    文件:XMLReaderTest.java   
/**
 * No exception expected when set entity resolver as simple entity resolver.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void entity01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlReader.setEntityResolver(xmlFilter);
    assertEquals(xmlReader.getEntityResolver(), xmlFilter);
}
项目:openjdk-jdk10    文件:XMLReaderTest.java   
/**
 * No exception expected when set DTD handler as simple DTD handler.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void dtdhandler01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlReader.setDTDHandler(xmlFilter);
    assertEquals(xmlReader.getDTDHandler(), xmlFilter);
}
项目:openjdk-jdk10    文件:XMLReaderTest.java   
/**
 * No exception expected when set content handler as simple content handler.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void contenthandler01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    XMLFilterImpl xmlFilter = new XMLFilterImpl();
    xmlReader.setContentHandler(xmlFilter);
    assertEquals(xmlReader.getContentHandler(), xmlFilter);
}
项目:openjdk-jdk10    文件:XMLReaderTest.java   
/**
 * No exception expected when set content handler as simple error handler.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void errorhandler01() throws Exception {
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    XMLReader xmlReader = spf.newSAXParser().getXMLReader();
    xmlReader.setErrorHandler(new XMLFilterImpl());
    assertNotNull(xmlReader.getErrorHandler());
}