org.codehaus.staxmate.SMInputFactory Java Examples

The following examples show how to use org.codehaus.staxmate.SMInputFactory. 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: CheckstyleProfileImporter.java    From sonar-checkstyle with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
    final SMInputFactory inputFactory = initStax();
    final RulesProfile profile = RulesProfile.create();
    try {
        final Module checkerModule = loadModule(inputFactory.rootElementCursor(reader)
                .advance());

        for (Module rootModule : checkerModule.modules) {
            final Map<String, String> rootModuleProperties = new HashMap<>(
                    checkerModule.properties);
            rootModuleProperties.putAll(rootModule.properties);

            if (StringUtils.equals(TREEWALKER_MODULE, rootModule.name)) {
                processTreewalker(profile, rootModule, rootModuleProperties, messages);
            }
            else {
                processModule(profile, CHECKER_MODULE + "/", rootModule.name,
                        rootModuleProperties, messages);
            }
        }

    }
    catch (XMLStreamException ex) {
        final String message = "XML is not valid: " + ex.getMessage();
        LOG.error(message, ex);
        messages.addErrorText(message);
    }
    return profile;
}
 
Example #2
Source File: CheckstyleProfileImporter.java    From sonar-checkstyle with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static SMInputFactory initStax() {
    final XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
    xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
    return new SMInputFactory(xmlFactory);
}
 
Example #3
Source File: StaxParser.java    From sonar-clover with Apache License 2.0 5 votes vote down vote up
StaxParser(XmlStreamHandler streamHandler) {
    this.streamHandler = streamHandler;
    XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
    if (xmlFactory instanceof WstxInputFactory) {
        WstxInputFactory wstxInputfactory = (WstxInputFactory) xmlFactory;
        wstxInputfactory.configureForLowMemUsage();
        wstxInputfactory.getConfig().setUndeclaredEntityResolver(new UndeclaredEntitiesXMLResolver());
    }
    xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, false);
    xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
    xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
    inf = new SMInputFactory(xmlFactory);
}