Package org.biojava.nbio.core.util
Class PrettyXMLWriter
java.lang.Object
org.biojava.nbio.core.util.PrettyXMLWriter
- All Implemented Interfaces:
XMLWriter
Implementation of XMLWriter which emits nicely formatted documents
to a PrintWriter.
- Since:
- 1.3
- Author:
- Thomas Down
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an un-qualified attribute to an element.void
Add an attribute to an element.void
close()
Close this XMLWriter, and its underlying stream.void
Closes an un-qualified element.void
Closes an elementvoid
declareNamespace
(String nsURI, String prefixHint) Declare a namespace for current and following elements 'prefixHint' is ignored entirely in this implementationprotected void
numericalEntity
(char c) void
Open a new unqualified XML tag.void
Open a new namespace-qualified XML tag.void
Prints some textual content in an element.protected void
printAttributeValue
(String data) protected void
printChars
(String data) void
Prints some textual content, terminated with a newline character.void
Send raw data to the stream.protected void
-
Constructor Details
-
PrettyXMLWriter
-
-
Method Details
-
declareNamespace
Declare a namespace for current and following elements 'prefixHint' is ignored entirely in this implementation- Specified by:
declareNamespace
in interfaceXMLWriter
- Parameters:
nsURI
- The namespace to declareprefixHint
- A suggested prefix-string for this namespace.- Throws:
IOException
-
writeIndent
- Throws:
IOException
-
openTag
Description copied from interface:XMLWriter
Open a new namespace-qualified XML tag.- Specified by:
openTag
in interfaceXMLWriter
- Parameters:
nsURI
- A URI for the namespace to uselocalName
- The name of the tag- Throws:
IOException
-
openTag
Description copied from interface:XMLWriter
Open a new unqualified XML tag. This may also be used if you want to do namespace management yourself, independantly of the XMLWriter- Specified by:
openTag
in interfaceXMLWriter
- Parameters:
qName
- The name of the tag.- Throws:
IOException
-
attribute
Description copied from interface:XMLWriter
Add an attribute to an element. This will throw an exception if it's not called immediately after anopenTag
command.- Specified by:
attribute
in interfaceXMLWriter
- Parameters:
nsURI
- A URI for the namespace to uselocalName
- The name of the attributevalue
- The textual value of the attribute- Throws:
IOException
-
attribute
Description copied from interface:XMLWriter
Add an un-qualified attribute to an element. This will throw an exception if it's not called immediately after anopenTag
command.- Specified by:
attribute
in interfaceXMLWriter
- Parameters:
qName
- The name of the attribute to setvalue
- The textual value of the attribute- Throws:
IOException
-
closeTag
Description copied from interface:XMLWriter
Closes an element- Specified by:
closeTag
in interfaceXMLWriter
- Parameters:
nsURI
- A URI for the namespace to uselocalName
- The name of the tag- Throws:
IOException
-
closeTag
Description copied from interface:XMLWriter
Closes an un-qualified element.- Specified by:
closeTag
in interfaceXMLWriter
- Parameters:
qName
- The tag name- Throws:
IOException
-
println
Description copied from interface:XMLWriter
Prints some textual content, terminated with a newline character.- Specified by:
println
in interfaceXMLWriter
- Throws:
IOException
-
print
Description copied from interface:XMLWriter
Prints some textual content in an element.- Specified by:
print
in interfaceXMLWriter
- Throws:
IOException
-
printRaw
Description copied from interface:XMLWriter
Send raw data to the stream. Mainly useful for things like DOCTYPE declarations. Use with care!- Specified by:
printRaw
in interfaceXMLWriter
- Parameters:
data
- a string of data to include verbatim in the XML stream- Throws:
IOException
-
printChars
- Throws:
IOException
-
printAttributeValue
- Throws:
IOException
-
numericalEntity
- Throws:
IOException
-
close
Description copied from interface:XMLWriter
Close this XMLWriter, and its underlying stream.- Specified by:
close
in interfaceXMLWriter
- Throws:
IOException
-