Package org.biojava.nbio.core.util
Class PrettyXMLWriter
- java.lang.Object
-
- org.biojava.nbio.core.util.PrettyXMLWriter
-
-
Constructor Summary
Constructors Constructor Description PrettyXMLWriter(java.io.PrintWriter writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attribute(java.lang.String qName, java.lang.String value)
Add an un-qualified attribute to an element.void
attribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value)
Add an attribute to an element.void
close()
Close this XMLWriter, and it's underlying stream.void
closeTag(java.lang.String qName)
Closes an un-qualified element.void
closeTag(java.lang.String nsURI, java.lang.String localName)
Closes an elementvoid
declareNamespace(java.lang.String nsURI, java.lang.String prefixHint)
Hints that a namespace is going to be used in a sub-tree.protected void
numericalEntity(char c)
void
openTag(java.lang.String qName)
Open a new unqualified XML tag.void
openTag(java.lang.String nsURI, java.lang.String localName)
Open a new namespace-qualified XML tag.void
print(java.lang.String data)
Prints some textual content in an element.protected void
printAttributeValue(java.lang.String data)
protected void
printChars(java.lang.String data)
void
println(java.lang.String data)
Prints some textual content, terminated with a newline character.void
printRaw(java.lang.String data)
Send raw data to the stream.protected void
writeIndent()
-
-
-
Method Detail
-
declareNamespace
public void declareNamespace(java.lang.String nsURI, java.lang.String prefixHint) throws java.io.IOException
Description copied from interface:XMLWriter
Hints that a namespace is going to be used in a sub-tree. Use this method to avoid namespaces that are used only in leaf-nodes of a tree being re-defined every time they are used. The XMLWriter will generally try to use the suggested prefix for this namespace, but there is no guarentee of this. In particular, if the namespace is already in use, the current prefix will still be used. Similarly if the suggested prefix has already been used for another namespace, a new one will be auto-generated.- Specified by:
declareNamespace
in interfaceXMLWriter
- Parameters:
nsURI
- The namespace to declareprefixHint
- A suggested prefix-string for this namespace.- Throws:
java.io.IOException
-
writeIndent
protected void writeIndent() throws java.io.IOException
- Throws:
java.io.IOException
-
openTag
public void openTag(java.lang.String nsURI, java.lang.String localName) throws java.io.IOException
Description copied from interface:XMLWriter
Open a new namespace-qualified XML tag.
-
openTag
public void openTag(java.lang.String qName) throws java.io.IOException
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
-
attribute
public void attribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws java.io.IOException
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.
-
attribute
public void attribute(java.lang.String qName, java.lang.String value) throws java.io.IOException
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.
-
closeTag
public void closeTag(java.lang.String nsURI, java.lang.String localName) throws java.io.IOException
Description copied from interface:XMLWriter
Closes an element
-
closeTag
public void closeTag(java.lang.String qName) throws java.io.IOException
Description copied from interface:XMLWriter
Closes an un-qualified element.
-
println
public void println(java.lang.String data) throws java.io.IOException
Description copied from interface:XMLWriter
Prints some textual content, terminated with a newline character.
-
print
public void print(java.lang.String data) throws java.io.IOException
Description copied from interface:XMLWriter
Prints some textual content in an element.
-
printRaw
public void printRaw(java.lang.String data) throws java.io.IOException
Description copied from interface:XMLWriter
Send raw data to the stream. Mainly useful for things like DOCTYPE declarations. Use with care!
-
printChars
protected void printChars(java.lang.String data) throws java.io.IOException
- Throws:
java.io.IOException
-
printAttributeValue
protected void printAttributeValue(java.lang.String data) throws java.io.IOException
- Throws:
java.io.IOException
-
numericalEntity
protected void numericalEntity(char c) throws java.io.IOException
- Throws:
java.io.IOException
-
-