Package org.biojava.nbio.core.util
Class PrettyXMLWriter
- java.lang.Object
-
- org.biojava.nbio.core.util.PrettyXMLWriter
-
- All Implemented Interfaces:
XMLWriter
public class PrettyXMLWriter extends Object implements XMLWriter
Implementation of XMLWriter which emits nicely formatted documents to a PrintWriter.- Since:
- 1.3
- Author:
- Thomas Down
-
-
Constructor Summary
Constructors Constructor Description PrettyXMLWriter(PrintWriter writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattribute(String qName, String value)Add an un-qualified attribute to an element.voidattribute(String nsURI, String localName, String value)Add an attribute to an element.voidclose()Close this XMLWriter, and its underlying stream.voidcloseTag(String qName)Closes an un-qualified element.voidcloseTag(String nsURI, String localName)Closes an elementvoiddeclareNamespace(String nsURI, String prefixHint)Declare a namespace for current and following elements 'prefixHint' is ignored entirely in this implementationprotected voidnumericalEntity(char c)voidopenTag(String qName)Open a new unqualified XML tag.voidopenTag(String nsURI, String localName)Open a new namespace-qualified XML tag.voidprint(String data)Prints some textual content in an element.protected voidprintAttributeValue(String data)protected voidprintChars(String data)voidprintln(String data)Prints some textual content, terminated with a newline character.voidprintRaw(String data)Send raw data to the stream.protected voidwriteIndent()
-
-
-
Constructor Detail
-
PrettyXMLWriter
public PrettyXMLWriter(PrintWriter writer)
-
-
Method Detail
-
declareNamespace
public void declareNamespace(String nsURI, String prefixHint) throws IOException
Declare a namespace for current and following elements 'prefixHint' is ignored entirely in this implementation- Specified by:
declareNamespacein interfaceXMLWriter- Parameters:
nsURI- The namespace to declareprefixHint- A suggested prefix-string for this namespace.- Throws:
IOException
-
writeIndent
protected void writeIndent() throws IOException
- Throws:
IOException
-
openTag
public void openTag(String nsURI, String localName) throws IOException
Description copied from interface:XMLWriterOpen a new namespace-qualified XML tag.- Specified by:
openTagin interfaceXMLWriter- Parameters:
nsURI- A URI for the namespace to uselocalName- The name of the tag- Throws:
IOException
-
openTag
public void openTag(String qName) throws IOException
Description copied from interface:XMLWriterOpen a new unqualified XML tag. This may also be used if you want to do namespace management yourself, independantly of the XMLWriter- Specified by:
openTagin interfaceXMLWriter- Parameters:
qName- The name of the tag.- Throws:
IOException
-
attribute
public void attribute(String nsURI, String localName, String value) throws IOException
Description copied from interface:XMLWriterAdd an attribute to an element. This will throw an exception if it's not called immediately after anopenTagcommand.- Specified by:
attributein interfaceXMLWriter- Parameters:
nsURI- A URI for the namespace to uselocalName- The name of the attributevalue- The textual value of the attribute- Throws:
IOException
-
attribute
public void attribute(String qName, String value) throws IOException
Description copied from interface:XMLWriterAdd an un-qualified attribute to an element. This will throw an exception if it's not called immediately after anopenTagcommand.- Specified by:
attributein interfaceXMLWriter- Parameters:
qName- The name of the attribute to setvalue- The textual value of the attribute- Throws:
IOException
-
closeTag
public void closeTag(String nsURI, String localName) throws IOException
Description copied from interface:XMLWriterCloses an element- Specified by:
closeTagin interfaceXMLWriter- Parameters:
nsURI- A URI for the namespace to uselocalName- The name of the tag- Throws:
IOException
-
closeTag
public void closeTag(String qName) throws IOException
Description copied from interface:XMLWriterCloses an un-qualified element.- Specified by:
closeTagin interfaceXMLWriter- Parameters:
qName- The tag name- Throws:
IOException
-
println
public void println(String data) throws IOException
Description copied from interface:XMLWriterPrints some textual content, terminated with a newline character.- Specified by:
printlnin interfaceXMLWriter- Throws:
IOException
-
print
public void print(String data) throws IOException
Description copied from interface:XMLWriterPrints some textual content in an element.- Specified by:
printin interfaceXMLWriter- Throws:
IOException
-
printRaw
public void printRaw(String data) throws IOException
Description copied from interface:XMLWriterSend raw data to the stream. Mainly useful for things like DOCTYPE declarations. Use with care!- Specified by:
printRawin interfaceXMLWriter- Parameters:
data- a string of data to include verbatim in the XML stream- Throws:
IOException
-
printChars
protected void printChars(String data) throws IOException
- Throws:
IOException
-
printAttributeValue
protected void printAttributeValue(String data) throws IOException
- Throws:
IOException
-
numericalEntity
protected void numericalEntity(char c) throws IOException
- Throws:
IOException
-
close
public void close() throws IOException
Description copied from interface:XMLWriterClose this XMLWriter, and its underlying stream.- Specified by:
closein interfaceXMLWriter- Throws:
IOException
-
-