KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > BugAnnotationUtil


1 /*
2  * FindBugs - Find bugs in Java programs
3  * Copyright (C) 2005, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package edu.umd.cs.findbugs;
20
21 import java.io.IOException JavaDoc;
22
23 import edu.umd.cs.findbugs.xml.XMLAttributeList;
24 import edu.umd.cs.findbugs.xml.XMLOutput;
25
26 /**
27  * Utility methods for BugAnnotation classes.
28  *
29  * @author David Hovemeyer
30  */

31 public abstract class BugAnnotationUtil {
32     /**
33      * Write a BugAnnotation as XML.
34      *
35      * @param xmlOutput the XMLOutput
36      * @param elementName name of element for BugAnnotation
37      * @param annotation the BugAnnotation
38      * @param attributeList the XML attribute list
39      * @param addMessages true if descriptive messages should be added
40      * @throws IOException
41      */

42     public static void writeXML(
43             XMLOutput xmlOutput,
44             String JavaDoc elementName,
45             BugAnnotation annotation,
46             XMLAttributeList attributeList,
47             boolean addMessages) throws IOException JavaDoc {
48
49         if (addMessages) {
50             xmlOutput.openTag(elementName, attributeList);
51             xmlOutput.openTag(BugAnnotation.MESSAGE_TAG);
52             xmlOutput.writeText(annotation.toString());
53             xmlOutput.closeTag(BugAnnotation.MESSAGE_TAG);
54             xmlOutput.closeTag(elementName);
55         } else {
56             xmlOutput.openCloseTag(elementName, attributeList);
57         }
58
59     }
60 }
61
Popular Tags