Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.selesse.jxlint.report;
 
The XmlReporter provides a basic XML report. The schema is:
<issues>
     <issue name severity message category summary explanation location />
 </issues>
 
public class XmlReporter extends Reporter {
    public XmlReporter(PrintStream outProgramSettings programSettingsList<LintErrorlintErrorList) {
        super(outprogramSettingslintErrorList);
    }
    @Override
    public void printHeader() {
        .println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        .println("<issues>");
    }
    @Override
    public void printCategoryHeader(Enum<?> category) {
    }
    @Override
    public void printError(LintError error) {
        LintRule violatedRule = error.getViolatedRule();
        .println("    <issue");
        List<StringoutputBuffer = Lists.newArrayList(
                "        name=\"" + xmlEncode(violatedRule.getName()) + "\"",
                "        severity=\"" + xmlEncode(EnumUtils.toHappyString(violatedRule.getSeverity())) + "\"",
                "        message=\"" + xmlEncode(error.getMessage()) + "\"",
                "        category=\"" + xmlEncode(violatedRule.getCategory().toString()) + "\"",
                "        summary=\"" + xmlEncode(violatedRule.getSummary()) + "\"",
                "        explanation=\"" + xmlEncode(violatedRule.getDetailedDescription()) + "\"",
                "        location=\"" + xmlEncode(error.getFile().getAbsolutePath()) + "\"",
                "    />"
        );
        .println(Joiner.on("\n").join(outputBuffer));
    }
    private String xmlEncode(String string) {
        return XmlEscapers.xmlAttributeEscaper().escape(string);
    }
    @Override
    public void printFooter() {
        .println("</issues>");
    }
New to GrepCode? Check out our FAQ X