Package edu.umd.cs.findbugs.xml
Class Dom4JXMLOutput
java.lang.Object
edu.umd.cs.findbugs.xml.Dom4JXMLOutput
- All Implemented Interfaces:
XMLOutput
XMLOutput class to build all or part of a dom4j tree.
- Author:
- David Hovemeyer
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String name, String value) Add an attribute to a started tag.void
Begin the XML document.void
Close tag with given name.void
finish()
Finish writing XML output, closing any underlying resources (such as output streams).void
openCloseTag
(String tagName) Open and close tag with given name.void
openCloseTag
(String tagName, XMLAttributeList attributeList) Open and close tag with given name and given attributes.void
Open a tag with given name.void
openTag
(String tagName, XMLAttributeList attributeList) Open a tag with given name and given attributes.void
Start a tag, with the intention of adding attributes.void
stopTag
(boolean close) End a started tag.void
write
(XMLWriteable obj) Add given object to the tree.void
writeCDATA
(String cdata) Write a CDATA section to the XML document.void
writeCollection
(Collection<? extends XMLWriteable> collection) Add a Collection of XMLWriteable objects to the tree.void
writeElementList
(String tagName, Collection<String> listValues) Add a list of Strings to document as elements with given tag name to the tree.void
Write text to the XML document.
-
Constructor Details
-
Dom4JXMLOutput
public Dom4JXMLOutput(org.dom4j.Branch topLevel) Constructor.- Parameters:
topLevel
- the Document or Element that is the root of the tree to be built
-
-
Method Details
-
beginDocument
public void beginDocument()Description copied from interface:XMLOutput
Begin the XML document.- Specified by:
beginDocument
in interfaceXMLOutput
-
openTag
Description copied from interface:XMLOutput
Open a tag with given name. -
openTag
Description copied from interface:XMLOutput
Open a tag with given name and given attributes. -
openCloseTag
Description copied from interface:XMLOutput
Open and close tag with given name.- Specified by:
openCloseTag
in interfaceXMLOutput
- Parameters:
tagName
- the tag name
-
openCloseTag
Description copied from interface:XMLOutput
Open and close tag with given name and given attributes.- Specified by:
openCloseTag
in interfaceXMLOutput
- Parameters:
tagName
- the tag nameattributeList
- the attributes
-
startTag
Description copied from interface:XMLOutput
Start a tag, with the intention of adding attributes. Must be followed by stopTag after zero or more addAttribute calls. -
addAttribute
Description copied from interface:XMLOutput
Add an attribute to a started tag. Must follow a call to startTag.- Specified by:
addAttribute
in interfaceXMLOutput
- Parameters:
name
- the attribute name.value
- the attribute value, unescaped.
-
stopTag
public void stopTag(boolean close) Description copied from interface:XMLOutput
End a started tag. Must follow a call to startTag. -
closeTag
Description copied from interface:XMLOutput
Close tag with given name. -
writeText
Description copied from interface:XMLOutput
Write text to the XML document. XML metacharacters are automatically escaped. -
writeCDATA
Description copied from interface:XMLOutput
Write a CDATA section to the XML document. The characters are not escaped in any way.- Specified by:
writeCDATA
in interfaceXMLOutput
- Parameters:
cdata
- the character data to write
-
writeElementList
Add a list of Strings to document as elements with given tag name to the tree.- Parameters:
tagName
- the tag namelistValues
- Collection of String values to add
-
write
Add given object to the tree.- Parameters:
obj
- the object
-
writeCollection
Add a Collection of XMLWriteable objects to the tree.- Parameters:
collection
- Collection of XMLWriteable objects
-
finish
public void finish()Description copied from interface:XMLOutput
Finish writing XML output, closing any underlying resources (such as output streams). A call to this method should always be made, even if one of the XML-generation methods throws an exception. Therefore, a call to this method should be performed in a finally block.
-