Package edu.umd.cs.findbugs.xml

Examples of edu.umd.cs.findbugs.xml.OutputStreamXMLOutput


    /** protected for testing */
    @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION")
    protected final void writeXml(OutputStream out, Collection<Plugin> plugins, String entryPoint,
            boolean finish) throws IOException {
        OutputStreamXMLOutput xmlOutput = new OutputStreamXMLOutput(out);
        try {
            xmlOutput.beginDocument();

            xmlOutput.startTag("findbugs-invocation");
            xmlOutput.addAttribute("version", Version.RELEASE);
            String applicationName = Version.getApplicationName();
            if (applicationName == null || applicationName.equals("")) {
                int lastDot = entryPoint.lastIndexOf('.');
                if (lastDot == -1) {
                    applicationName = entryPoint;
                } else {
                    applicationName = entryPoint.substring(lastDot + 1);
                }
            }
            xmlOutput.addAttribute("app-name", applicationName);
            String applicationVersion = Version.getApplicationVersion();
            if (applicationVersion == null) {
                applicationVersion = "";
            }
            xmlOutput.addAttribute("app-version", applicationVersion);
            xmlOutput.addAttribute("entry-point", entryPoint);
            xmlOutput.addAttribute("os", SystemProperties.getProperty("os.name", ""));
            xmlOutput.addAttribute("java-version", getMajorJavaVersion());
            Locale locale = Locale.getDefault();
            xmlOutput.addAttribute("language", locale.getLanguage());
            xmlOutput.addAttribute("country", locale.getCountry());
            xmlOutput.addAttribute("uuid", getUuid());
            xmlOutput.stopTag(false);
            for (Plugin plugin : plugins) {
                xmlOutput.startTag("plugin");
                xmlOutput.addAttribute("id", plugin.getPluginId());
                xmlOutput.addAttribute("name", plugin.getShortDescription());
                xmlOutput.addAttribute("version", plugin.getVersion());
                Date date = plugin.getReleaseDate();
                if (date != null) {
                    xmlOutput.addAttribute("release-date", Long.toString(date.getTime()));
                }
                xmlOutput.stopTag(true);
            }

            xmlOutput.closeTag("findbugs-invocation");
            xmlOutput.flush();
        } finally {
            if (finish) {
                xmlOutput.finish();
            }
        }
    }
View Full Code Here


        return project;
    }

    public void writeXML(File f, @CheckForNull BugCollection bugCollection) throws IOException {
        OutputStream out = new FileOutputStream(f);
        XMLOutput xmlOutput = new OutputStreamXMLOutput(out);
        try {
            writeXML(xmlOutput, f, bugCollection);
        } finally {
            xmlOutput.finish();
        }
    }
View Full Code Here

            System.exit(1);
        }
    }

    public void writeAsXML(@WillClose OutputStream out) throws IOException {
        XMLOutput xmlOutput = new OutputStreamXMLOutput(out);

        try {
            xmlOutput.beginDocument();
            xmlOutput.openTag("FindBugsFilter");
            writeBodyAsXML(xmlOutput);
            xmlOutput.closeTag("FindBugsFilter");
        } finally {
            xmlOutput.finish();
        }
    }
View Full Code Here

        }
    }

    public void writeEnabledMatchersAsXML(@WillClose OutputStream out) throws IOException {

        XMLOutput xmlOutput = new OutputStreamXMLOutput(out);

        try {
            xmlOutput.beginDocument();
            xmlOutput.openTag("FindBugsFilter");
            Iterator<Matcher> i = childIterator();
            while (i.hasNext()) {
                Matcher child = i.next();
                if (!disabled.containsKey(child)) {
                    child.writeXML(xmlOutput, false);
                }
            }
            xmlOutput.closeTag("FindBugsFilter");
        } finally {
            xmlOutput.finish();
        }
    }
View Full Code Here

    /**
     * Report statistics as an XML document to given output stream.
     */
    public void reportSummary(@WillClose OutputStream out) throws IOException {
        XMLOutput xmlOutput = new OutputStreamXMLOutput(out);
        try {
            writeXML(xmlOutput);
        } finally {
            xmlOutput.finish();
        }
    }
View Full Code Here

            String token = SystemProperties.getProperty("findbugs.cloud.token");
            if (token != null && token.trim().length() > 0) {
                LOGGER.info("Cloud token specified - uploading new issues, if necessary...");
                cloud.waitUntilNewIssuesUploaded();
            }
            xmlOutput = new OutputStreamXMLOutput(out, "http://findbugs.sourceforge.net/xsl/default.xsl");
        } else {
            xmlOutput = new OutputStreamXMLOutput(out);
        }

        writeXML(xmlOutput);
    }
View Full Code Here

        assertFalse(sm.match(bug));
    }

    private String writeXMLAndGetStringOutput(SourceMatcher matcher, boolean disabled) throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        XMLOutput xmlOutput = new OutputStreamXMLOutput(outputStream);

        matcher.writeXML(xmlOutput, disabled);
        xmlOutput.finish();

        return outputStream.toString().trim();
    }
View Full Code Here

        new NotMatcher().originalMatcher();
    }

    private String writeXMLAndGetStringOutput(NotMatcher notMatcher) throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        XMLOutput xmlOutput = new OutputStreamXMLOutput(outputStream);

        notMatcher.writeXML(xmlOutput, false);
        xmlOutput.finish();

        String xmlOutputCreated = outputStream.toString();
        return xmlOutputCreated;
    }
View Full Code Here

        assertTrue("ageInDays", output.contains("ageInDays="));
    }

    private String writeXML(BugInstance inst, BugCollection bc) throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        XMLOutput out = new OutputStreamXMLOutput(bout);
        inst.writeXML(out, bc, bc.getWithMessages());
        out.finish();
        return new String(bout.toByteArray(), "UTF-8");
    }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.xml.OutputStreamXMLOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.