edu.umd.cs.findbugs.xml
Class OutputStreamXMLOutput

java.lang.Object
  extended by edu.umd.cs.findbugs.xml.OutputStreamXMLOutput
All Implemented Interfaces:
XMLOutput

public class OutputStreamXMLOutput
extends java.lang.Object
implements XMLOutput

Write XML to an output stream.

Author:
David Hovemeyer

Nested Class Summary
private  class OutputStreamXMLOutput.WriterQuoteMetaCharacters
           
 
Field Summary
private  int nestingLevel
           
private  boolean newLine
           
private static java.lang.String OPENING
           
private  java.io.Writer out
           
private static MetaCharacterMap textMetaCharacterMap
           
 
Constructor Summary
OutputStreamXMLOutput(java.io.OutputStream os)
          Constructor.
 
Method Summary
 void beginDocument()
          Begin the XML document.
 void closeTag(java.lang.String tagName)
          Close tag with given name.
private  void emitTag(java.lang.String tagName, boolean close)
           
private  void emitTag(java.lang.String tagName, java.lang.String attributes, boolean close)
           
 void finish()
          Finish writing XML output, closing any underlying resources (such as output streams).
private  void indent()
           
 void openCloseTag(java.lang.String tagName)
          Open and close tag with given name.
 void openCloseTag(java.lang.String tagName, XMLAttributeList attributeList)
          Open and close tag with given name and given attributes.
 void openTag(java.lang.String tagName)
          Open a tag with given name.
 void openTag(java.lang.String tagName, XMLAttributeList attributeList)
          Open a tag with given name and given attributes.
 void writeCDATA(java.lang.String cdata)
          Write a CDATA section to the XML document.
 void writeText(java.lang.String text)
          Write text to the XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPENING

private static final java.lang.String OPENING
See Also:
Constant Field Values

textMetaCharacterMap

private static final MetaCharacterMap textMetaCharacterMap

out

private java.io.Writer out

nestingLevel

private int nestingLevel

newLine

private boolean newLine
Constructor Detail

OutputStreamXMLOutput

public OutputStreamXMLOutput(java.io.OutputStream os)
Constructor.

Parameters:
os - OutputStream to write XML output to
Method Detail

beginDocument

public void beginDocument()
                   throws java.io.IOException
Description copied from interface: XMLOutput
Begin the XML document.

Specified by:
beginDocument in interface XMLOutput
Throws:
java.io.IOException

openTag

public void openTag(java.lang.String tagName)
             throws java.io.IOException
Description copied from interface: XMLOutput
Open a tag with given name.

Specified by:
openTag in interface XMLOutput
Parameters:
tagName - the tag name
Throws:
java.io.IOException

openTag

public void openTag(java.lang.String tagName,
                    XMLAttributeList attributeList)
             throws java.io.IOException
Description copied from interface: XMLOutput
Open a tag with given name and given attributes.

Specified by:
openTag in interface XMLOutput
Parameters:
tagName - the tag name
attributeList - the attributes
Throws:
java.io.IOException

openCloseTag

public void openCloseTag(java.lang.String tagName)
                  throws java.io.IOException
Description copied from interface: XMLOutput
Open and close tag with given name.

Specified by:
openCloseTag in interface XMLOutput
Parameters:
tagName - the tag name
Throws:
java.io.IOException

openCloseTag

public void openCloseTag(java.lang.String tagName,
                         XMLAttributeList attributeList)
                  throws java.io.IOException
Description copied from interface: XMLOutput
Open and close tag with given name and given attributes.

Specified by:
openCloseTag in interface XMLOutput
Parameters:
tagName - the tag name
attributeList - the attributes
Throws:
java.io.IOException

emitTag

private void emitTag(java.lang.String tagName,
                     boolean close)
              throws java.io.IOException
Throws:
java.io.IOException

emitTag

private void emitTag(java.lang.String tagName,
                     java.lang.String attributes,
                     boolean close)
              throws java.io.IOException
Throws:
java.io.IOException

closeTag

public void closeTag(java.lang.String tagName)
              throws java.io.IOException
Description copied from interface: XMLOutput
Close tag with given name.

Specified by:
closeTag in interface XMLOutput
Parameters:
tagName - the tag name
Throws:
java.io.IOException

writeText

public void writeText(java.lang.String text)
               throws java.io.IOException
Description copied from interface: XMLOutput
Write text to the XML document. XML metacharacters are automatically escaped.

Specified by:
writeText in interface XMLOutput
Parameters:
text - the text to write
Throws:
java.io.IOException

writeCDATA

public void writeCDATA(java.lang.String cdata)
                throws java.io.IOException
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 interface XMLOutput
Parameters:
cdata - the character data to write
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException
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.

Specified by:
finish in interface XMLOutput
Throws:
java.io.IOException

indent

private void indent()
             throws java.io.IOException
Throws:
java.io.IOException