01: /*
02: * FindBugs - Find bugs in Java programs
03: * Copyright (C) 2005, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
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(XMLOutput xmlOutput,
43: String elementName, BugAnnotation annotation,
44: XMLAttributeList attributeList, boolean addMessages)
45: throws IOException {
46:
47: if (addMessages) {
48: xmlOutput.openTag(elementName, attributeList);
49: xmlOutput.openTag(BugAnnotation.MESSAGE_TAG);
50: xmlOutput.writeText(annotation.toString());
51: xmlOutput.closeTag(BugAnnotation.MESSAGE_TAG);
52: xmlOutput.closeTag(elementName);
53: } else {
54: xmlOutput.openCloseTag(elementName, attributeList);
55: }
56:
57: }
58: }
|