Package edu.umd.cs.findbugs.xml

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


    @Override
    public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException {
        String classname = getClassName();
        String sourcePath = getSourcePath();

        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("classname", classname);
        if (isPrimary) {
            attributeList.addAttribute("primary", "true");
        }

        int n = getStartLine(); // start/end are now optional (were too many
        // "-1"s in the xml)
        if (n >= 0) {
            attributeList.addAttribute("start", String.valueOf(n));
        }
        n = getEndLine();
        if (n >= 0) {
            attributeList.addAttribute("end", String.valueOf(n));
        }
        n = getStartBytecode(); // startBytecode/endBytecode haven't been set
        // for a while now
        if (n >= 0) {
            attributeList.addAttribute("startBytecode", String.valueOf(n));
        }
        n = getEndBytecode();
        if (n >= 0) {
            attributeList.addAttribute("endBytecode", String.valueOf(n));
        }

        if (isSourceFileKnown()) {
            attributeList.addAttribute("sourcefile", sourceFile);
            attributeList.addAttribute("sourcepath", sourcePath);
            Project project = myProject.get();
            if (project != null) {
                try {
                    SourceFinder mySourceFinder = project.getSourceFinder();
                    String fullPath = new File(mySourceFinder.findSourceFile(this).getFullFileName()).getCanonicalPath();
                    String myRelativeSourceBase = relativeSourceBase.get();
                    if (fullPath.startsWith(myRelativeSourceBase) && fullPath.length() > myRelativeSourceBase.length()) {
                        attributeList.addAttribute("relSourcepath", fullPath.substring(myRelativeSourceBase.length() + 1));
                    }
                } catch (IOException e) {
                    assert true;
                }
            }
        }

        String role = getDescription();
        if (!role.equals(DEFAULT_ROLE)) {
            attributeList.addAttribute("role", getDescription());
        }
        if (synthetic) {
            attributeList.addAttribute("synthetic", "true");
        }
        if (addMessages) {
            xmlOutput.openTag(ELEMENT_NAME, attributeList);
            xmlOutput.openTag("Message");
            xmlOutput.writeText(this.toString());
View Full Code Here


        writeXML(xmlOutput, false, false);
    }

    @Override
    public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException {
        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("classname", getClassName())
                .addAttribute("name", getFieldName()).addAttribute("signature", getFieldSignature());
        if (fieldSourceSig != null) {
            attributeList.addAttribute("sourceSignature", fieldSourceSig);
        }
        attributeList.addAttribute("isStatic", String.valueOf(isStatic()));
        if (isPrimary) {
            attributeList.addAttribute("primary", "true");
        }

        String role = getDescription();
        if (!role.equals(DEFAULT_ROLE)) {
            attributeList.addAttribute("role", role);
        }

        xmlOutput.openTag(ELEMENT_NAME, attributeList);
        getSourceLines().writeXML(xmlOutput, addMessages, false);
        if (addMessages) {
View Full Code Here

        }
        BugCode bugCode = pattern.getBugCode();
        return bugCode.getCWEid();
    }
    public void writeXML(XMLOutput xmlOutput, BugCollection bugCollection, boolean addMessages) throws IOException {
        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("type", type).addAttribute("priority",
                String.valueOf(priority));

        // Always add the rank attribute.
        attributeList.addAttribute("rank", Integer.toString(getBugRank()));

        BugPattern pattern = getBugPattern();

        // The bug abbreviation and pattern category are
        // emitted into the XML for informational purposes only.
        // (The information is redundant, but might be useful
        // for processing tools that want to make sense of
        // bug instances without looking at the plugin descriptor.)
        attributeList.addAttribute("abbrev", pattern.getAbbrev());
        attributeList.addAttribute("category", pattern.getCategory());

        if (addMessages) {
            // Add a uid attribute, if we have a unique id.

            attributeList.addAttribute("instanceHash", getInstanceHash());
            attributeList.addAttribute("instanceOccurrenceNum", Integer.toString(getInstanceOccurrenceNum()));
            attributeList.addAttribute("instanceOccurrenceMax", Integer.toString(getInstanceOccurrenceMax()));

            int cweid = getCWEid();
            if (cweid != 0) {
                attributeList.addAttribute("cweid", Integer.toString(cweid));
            }
        } else if (oldInstanceHash != null && !isInstanceHashConsistent()) {
            attributeList.addAttribute("oldInstanceHash", oldInstanceHash);
        }
        if (firstVersion > 0) {
            attributeList.addAttribute("first", Long.toString(firstVersion));
        }
        if (lastVersion >= 0) {
            attributeList.addAttribute("last", Long.toString(lastVersion));
        }
        if (introducedByChangeOfExistingClass) {
            attributeList.addAttribute("introducedByChange", "true");
        }
        if (removedByChangeOfPersistingClass) {
            attributeList.addAttribute("removedByChange", "true");
        }

        if (bugCollection != null) {
            Cloud cloud = bugCollection.getCloudLazily();
            if (cloud != null && cloud.communicationInitiated()) {
                long firstSeen = cloud.getFirstSeen(this);
                attributeList.addAttribute("firstSeen", firstSeenXMLFormat().format(firstSeen));
                int reviews = cloud.getNumberReviewers(this);
                UserDesignation consensus = cloud.getConsensusDesignation(this);
                if (!cloud.isInCloud(this)) {
                    attributeList.addAttribute("isInCloud", "false");
                }
                if (reviews > 0) {
                    attributeList.addAttribute("reviews", Integer.toString(reviews));

                    if (consensus != UserDesignation.UNCLASSIFIED) {
                        attributeList.addAttribute("consensus", consensus.toString());
                    }

                }
                if (addMessages) {
                    int ageInDays = ageInDays(bugCollection, firstSeen);
                    attributeList.addAttribute("ageInDays", Integer.toString(ageInDays));
                    if (reviews > 0 && consensus != UserDesignation.UNCLASSIFIED) {
                        if (consensus.score() < 0) {
                            attributeList.addAttribute("notAProblem", "true");
                        }
                        if (consensus.score() > 0) {
                            attributeList.addAttribute("shouldFix", "true");
                        }
                    }

                }
            } else if (hasXmlProps()) {
                XmlProps props = getXmlProps();

                if (props.firstSeen != null) {
                    attributeList.addOptionalAttribute("firstSeen", firstSeenXMLFormat().format(props.firstSeen));
                }
                if (props.reviewCount > 0) {
                    if (props.consensus != null) {
                        attributeList.addOptionalAttribute("consensus", props.consensus);
                    }
                    attributeList.addAttribute("reviews", Integer.toString(props.reviewCount));
                }
                if (!props.isInCloud()) {
                    attributeList.addAttribute("isInCloud", "false");
                }
                if (addMessages) {
                    UserDesignation consesus = UserDesignation.valueOf(props.consensus);
                    if (consesus.shouldFix()) {
                        attributeList.addAttribute("shouldFix", "true");
                    } else if (consesus.notAProblem()) {
                        attributeList.addAttribute("notAProblem", "true");
                    }

                    if (props.firstSeen != null) {
                        int ageInDays = ageInDays(bugCollection, props.firstSeen.getTime());
                        attributeList.addAttribute("ageInDays", Integer.toString(ageInDays));
                    }
                }
            }
        }
View Full Code Here

     */
    @Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openCloseTag(
                ELEMENT_NAME,
                new XMLAttributeList().addAttribute("sequence", String.valueOf(sequence))
                .addAttribute("timestamp", String.valueOf(timestamp)).addAttribute("release", releaseName)
                .addAttribute("codeSize", String.valueOf(codeSize))
                .addAttribute("numClasses", String.valueOf(numClasses)));
    }
View Full Code Here

    public void writeXML(XMLOutput xmlOutput) throws IOException {
    }

    @Override
    public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException {
        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("classname", getClassName())
                .addAttribute("name", getMethodName()).addAttribute("signature", getMethodSignature())
                .addAttribute("isStatic", String.valueOf(isStatic()));
        if (isPrimary) {
            attributeList.addAttribute("primary", "true");
        }

        String role = getDescription();
        if (!role.equals(DEFAULT_ROLE)) {
            attributeList.addAttribute("role", role);
        }

        if (sourceLines == null && !addMessages) {
            xmlOutput.openCloseTag(ELEMENT_NAME, attributeList);
        } else {
View Full Code Here

     * edu.umd.cs.findbugs.xml.XMLWriteable#writeXML(edu.umd.cs.findbugs.xml
     * .XMLOutput)
     */
    @Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openTag(ELEMENT_NAME, new XMLAttributeList().addAttribute("class", className));
        for (Iterator<String> i = featureIterator(); i.hasNext();) {
            String feature = i.next();
            xmlOutput.openCloseTag(FEATURE_ELEMENT_NAME, new XMLAttributeList().addAttribute("value", feature));
        }
        xmlOutput.closeTag(ELEMENT_NAME);
    }
View Full Code Here

    }

    public void writeXML(XMLOutput xmlOutput, @CheckForNull File destination, @CheckForNull BugCollection bugCollection)
            throws IOException {
        {
            XMLAttributeList attributeList = new XMLAttributeList();

            if (getProjectName() != null) {
                attributeList = attributeList.addAttribute(PROJECTNAME_ATTRIBUTE_NAME, getProjectName());
            }
            xmlOutput.openTag(BugCollection.PROJECT_ELEMENT_NAME, attributeList);
        }

        if (destination != null) {
            String base = destination.getParent();
            writeElementList(xmlOutput, JAR_ELEMENT_NAME, convertToRelative(analysisTargets, base));
            writeElementList(xmlOutput, AUX_CLASSPATH_ENTRY_ELEMENT_NAME, convertToRelative(auxClasspathEntryList, base));
            writeElementList(xmlOutput, SRC_DIR_ELEMENT_NAME, convertToRelative(srcDirList, base));
            List<String> cwdStrings = new ArrayList<String>();
            for (File file : currentWorkingDirectoryList) {
                cwdStrings.add(file.getPath());
            }
            XMLOutputUtil.writeElementList(xmlOutput, WRK_DIR_ELEMENT_NAME, convertToRelative(cwdStrings, base));
        } else {
            // TODO to allow relative paths: refactor the code which uses null
            // file arguments
            writeElementList(xmlOutput, JAR_ELEMENT_NAME, analysisTargets);
            writeElementList(xmlOutput, AUX_CLASSPATH_ENTRY_ELEMENT_NAME, auxClasspathEntryList);
            writeElementList(xmlOutput, SRC_DIR_ELEMENT_NAME, srcDirList);
            XMLOutputUtil.writeFileList(xmlOutput, WRK_DIR_ELEMENT_NAME, currentWorkingDirectoryList);
        }

        if (!suppressionFilter.isEmpty()) {
            xmlOutput.openTag("SuppressionFilter");
            suppressionFilter.writeBodyAsXML(xmlOutput);
            xmlOutput.closeTag("SuppressionFilter");
        }

        for(Map.Entry<String, Boolean> e : enabledPlugins.entrySet()) {
            String pluginId = e.getKey();
            Boolean enabled = e.getValue();
            Plugin plugin = Plugin.getByPluginId(pluginId);
            if (plugin == null || enabled == null) {
                continue;
            }
            XMLAttributeList pluginAttributeList = new XMLAttributeList();
            pluginAttributeList.addAttribute(PLUGIN_ID_ATTRIBUTE_NAME, plugin.getPluginId());
            pluginAttributeList.addAttribute(PLUGIN_STATUS_ELEMENT_NAME, enabled.toString());
            xmlOutput.openCloseTag(PLUGIN_ELEMENT_NAME, pluginAttributeList);
        }
        CloudPlugin cloudPlugin = bugCollection == null ? null : CloudFactory.getCloudPlugin(bugCollection);
        if (cloudPlugin != null) {
            String id = cloudPlugin.getId();
View Full Code Here

        writeXML(xmlOutput, false, false);
    }

    @Override
    public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException {
        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("value", String.valueOf(value));

        String role = getDescription();
        if (!role.equals(DEFAULT_ROLE)) {
            attributeList.addAttribute("role", role);
        }

        BugAnnotationUtil.writeXML(xmlOutput, ELEMENT_NAME, this, attributeList, addMessages);
    }
View Full Code Here

        return "Method(" + super.toString() + ")";
    }

    @Override
    public void writeXML(XMLOutput xmlOutput, boolean disabled) throws IOException {
        XMLAttributeList attributes = new XMLAttributeList().addAttribute("name", name.getSpec());
        if (signature != null) {
            attributes
            .addOptionalAttribute("signature", signature.getSpec()).addOptionalAttribute("role", role);
        }
        if (disabled) {
            attributes.addAttribute("disabled", "true");
        }
        xmlOutput.openCloseTag("Method", attributes);
    }
View Full Code Here

        writeXML(xmlOutput, false, false);
    }

    @Override
    public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException {
        XMLAttributeList attributeList = new XMLAttributeList().addAttribute("value", value);

        String role = getDescription();
        if (!role.equals(DEFAULT_ROLE)) {
            attributeList.addAttribute("role", role);
        }

        BugAnnotationUtil.writeXML(xmlOutput, ELEMENT_NAME, this, attributeList, addMessages);
    }
View Full Code Here

TOP

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

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.