Search in sources :

Example 1 with SAXHandler

use of org.jdom.input.SAXHandler in project intellij-community by JetBrains.

the class JDOMUtil method getSaxBuilder.

private static SAXBuilder getSaxBuilder() {
    SoftReference<SAXBuilder> reference = ourSaxBuilder.get();
    SAXBuilder saxBuilder = com.intellij.reference.SoftReference.dereference(reference);
    if (saxBuilder == null) {
        saxBuilder = new SAXBuilder() {

            @Override
            protected void configureParser(XMLReader parser, SAXHandler contentHandler) throws JDOMException {
                super.configureParser(parser, contentHandler);
                try {
                    parser.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
                } catch (Exception ignore) {
                }
            }
        };
        saxBuilder.setEntityResolver(new EntityResolver() {

            @Override
            @NotNull
            public InputSource resolveEntity(String publicId, String systemId) {
                return new InputSource(new CharArrayReader(ArrayUtil.EMPTY_CHAR_ARRAY));
            }
        });
        ourSaxBuilder.set(new SoftReference<SAXBuilder>(saxBuilder));
    }
    return saxBuilder;
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) InputSource(org.xml.sax.InputSource) SAXHandler(org.jdom.input.SAXHandler) EntityResolver(org.xml.sax.EntityResolver) NotNull(org.jetbrains.annotations.NotNull) XMLReader(org.xml.sax.XMLReader)

Aggregations

SAXBuilder (org.jdom.input.SAXBuilder)1 SAXHandler (org.jdom.input.SAXHandler)1 NotNull (org.jetbrains.annotations.NotNull)1 EntityResolver (org.xml.sax.EntityResolver)1 InputSource (org.xml.sax.InputSource)1 XMLReader (org.xml.sax.XMLReader)1