public void parse(Reader xmlReader) throws XMLStreamException { if (isoControlCharsAwareParser) { throw new IllegalStateException("Method call not supported when isoControlCharsAwareParser=true"); } parse(inf.rootElementCursor(xmlReader)); }
public void parse(InputStream xmlInput) throws XMLStreamException { xmlInput = isoControlCharsAwareParser ? new ISOControlCharAwareInputStream(xmlInput) : xmlInput; parse(inf.rootElementCursor(xmlInput)); }
/** * Loads rules by reading the XML input stream. The reader is not closed by the method, so it * should be handled by the caller. * @since 4.3 */ public void load(RulesDefinition.NewRepository repo, Reader reader) { XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // just so it won't try to load DTD in if there's DOCTYPE xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); SMInputFactory inputFactory = new SMInputFactory(xmlFactory); try { SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); rootC.advance(); // <rules> SMInputCursor rulesC = rootC.childElementCursor("rule"); while (rulesC.getNext() != null) { // <rule> processRule(repo, rulesC); } } catch (XMLStreamException e) { throw new IllegalStateException("XML is not valid", e); } }
public List<Rule> parse(Reader reader) { XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // just so it won't try to load DTD in if there's DOCTYPE xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); SMInputFactory inputFactory = new SMInputFactory(xmlFactory); try { SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); rootC.advance(); // <rules> List<Rule> rules = new ArrayList<>(); SMInputCursor rulesC = rootC.childElementCursor("rule"); while (rulesC.getNext() != null) { // <rule> Rule rule = Rule.create(); rules.add(rule); processRule(rule, rulesC); } return rules; } catch (XMLStreamException e) { throw new SonarException("XML is not valid", e); } }
SMHierarchicCursor root = inputFactory.rootElementCursor(new StringReader(duplicationsData));
public List<RuleDebt> importXML(Reader xml, ValidationMessages validationMessages) { List<RuleDebt> ruleDebts = newArrayList(); try { SMInputFactory inputFactory = initStax(); SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml); // advance to <sqale> cursor.advance(); SMInputCursor rootCursor = cursor.childElementCursor(CHARACTERISTIC); while (rootCursor.getNext() != null) { process(ruleDebts, validationMessages, rootCursor); } cursor.getStreamReader().closeCompletely(); } catch (XMLStreamException e) { throw new IllegalStateException("XML is not valid", e); } return ruleDebts; }
List<Rule> rules = Lists.newArrayList(); SMInputFactory inputFactory = initStax(); SMHierarchicCursor rootC = inputFactory.rootElementCursor(backup);
public RulesProfile parse(Reader reader, ValidationMessages messages) { RulesProfile profile = RulesProfile.create(); SMInputFactory inputFactory = initStax(); try { SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); rootC.advance(); // <profile> SMInputCursor cursor = rootC.childElementCursor(); while (cursor.getNext() != null) { String nodeName = cursor.getLocalName(); if (StringUtils.equals("rules", nodeName)) { SMInputCursor rulesCursor = cursor.childElementCursor("rule"); processRules(rulesCursor, profile, messages); } else if (StringUtils.equals("name", nodeName)) { profile.setName(StringUtils.trim(cursor.collectDescendantText(false))); } else if (StringUtils.equals("language", nodeName)) { profile.setLanguage(StringUtils.trim(cursor.collectDescendantText(false))); } } } catch (XMLStreamException e) { messages.addErrorText("XML is not valid: " + e.getMessage()); } checkProfile(profile, messages); return profile; }
public void parse(File xmlFile) throws XMLStreamException { try(FileInputStream input = new FileInputStream(xmlFile)) { parse(inf.rootElementCursor(input)); } catch (IOException e) { throw new XMLStreamException(e); } }
public void parse(Reader xmlReader) throws XMLStreamException { if (isoControlCharsAwareParser) { throw new IllegalStateException("Method call not supported when isoControlCharsAwareParser=true"); } parse(inf.rootElementCursor(xmlReader)); }
public void parse(File xmlFile) throws XMLStreamException { try (FileInputStream input = new FileInputStream(xmlFile)) { parse(inf.rootElementCursor(input)); } catch (IOException e) { throw new XMLStreamException(e); } }
public void parse(File xmlFile) throws XMLStreamException { try(FileInputStream input = new FileInputStream(xmlFile)) { parse(inf.rootElementCursor(input)); } catch (IOException e) { throw new XMLStreamException(e); } }
public void parse(File xmlFile) throws XMLStreamException { try(FileInputStream input = new FileInputStream(xmlFile)) { parse(inf.rootElementCursor(input)); } catch (IOException e) { throw new XMLStreamException(e); } }
public void parse(Reader xmlReader) throws XMLStreamException { if (isoControlCharsAwareParser) { throw new SonarException("Method call not supported when isoControlCharsAwareParser=true"); } parse(inf.rootElementCursor(xmlReader)); }
public void parse(InputStream xmlInput) throws XMLStreamException { xmlInput = isoControlCharsAwareParser ? new ISOControlCharAwareInputStream(xmlInput) : xmlInput; parse(inf.rootElementCursor(xmlInput)); }
public void parse(InputStream xmlInput) throws XMLStreamException { xmlInput = isoControlCharsAwareParser ? new ISOControlCharAwareInputStream(xmlInput) : xmlInput; parse(inf.rootElementCursor(xmlInput)); }
private Collection<String> getAllRuleKeysFromFile(InputStream inputStream) { SMInputFactory inputFactory = ZapUtils.newStaxParser(); try { SMHierarchicCursor rootC = inputFactory.rootElementCursor(inputStream); SMInputCursor rulesCursor = rootC.advance(); return processRules(rulesCursor); } catch (XMLStreamException e) { throw new IllegalStateException("XML is not valid", e); } }
public void parse(InputStream xmlInput) throws XMLStreamException { SMHierarchicCursor rootCursor = inf.rootElementCursor(xmlInput); try { streamHandler.stream(rootCursor); } finally { rootCursor.getStreamReader().closeCompletely(); } }
public void parse(InputStream xmlInput) throws XMLStreamException { SMHierarchicCursor rootCursor = inf.rootElementCursor(xmlInput); try { streamHandler.stream(rootCursor); } finally { rootCursor.getStreamReader().closeCompletely(); } }
private void processRoot(InputStreamReader reader, SMInputFactory inputFactory) throws XMLStreamException { SMHierarchicCursor rootCursor = inputFactory.rootElementCursor(reader); rootCursor.advance(); SMInputCursor charCursor = rootCursor.childElementCursor("chc"); while (charCursor.getNext() != null) { SMInputCursor subCharCursor = charCursor.childElementCursor("chc"); while (subCharCursor.getNext() != null) { processSubChar(subCharCursor); } } }