org.coode.xml
Class XMLWriterImpl

java.lang.Object
  extended by org.coode.xml.XMLWriterImpl
All Implemented Interfaces:
XMLWriter

public class XMLWriterImpl
extends java.lang.Object
implements XMLWriter

Author: Matthew Horridge
The University Of Manchester
Medical Informatics Group
Date: 30-May-2006

matthew.horridge@cs.man.ac.uk
www.cs.man.ac.uk/~horridgm

Developed as part of the CO-ODE project http://www.co-ode.org


Nested Class Summary
 class XMLWriterImpl.XMLElement
           
 
Constructor Summary
XMLWriterImpl(java.io.Writer writer, XMLWriterNamespaceManager xmlWriterNamespaceManager)
           
XMLWriterImpl(java.io.Writer writer, XMLWriterNamespaceManager xmlWriterNamespaceManager, java.lang.String xmlBase)
           
 
Method Summary
 void endDocument()
          Causes all open elements, including the document root element, to be closed.
 java.lang.String getDefaultNamespace()
           
 XMLWriterNamespaceManager getNamespacePrefixes()
          Gets the Writer's namespace manager.
 java.lang.String getXMLBase()
           
 java.net.URI getXMLBaseAsURI()
           
 void setEncoding(java.lang.String encoding)
          Sets the encoding for the document that the rdfwriter produces.
 void setWrapAttributes(boolean b)
          Causes the current element's attributes to be wrapped in the output.
 void startDocument(java.lang.String rootElementName)
          Starts writing the document.
 void writeAttribute(java.lang.String attr, java.lang.String val)
          Writes an attribute of the last element to be started (that has not been closed).
 void writeComment(java.lang.String commentText)
           
 void writeEndElement()
          Writes the closing tag of the last element to be started.
 void writeStartElement(java.lang.String name)
          Writes the start of an element.
 void writeTextContent(java.lang.String text)
          Writes a text element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLWriterImpl

public XMLWriterImpl(java.io.Writer writer,
                     XMLWriterNamespaceManager xmlWriterNamespaceManager)

XMLWriterImpl

public XMLWriterImpl(java.io.Writer writer,
                     XMLWriterNamespaceManager xmlWriterNamespaceManager,
                     java.lang.String xmlBase)
Method Detail

getDefaultNamespace

public java.lang.String getDefaultNamespace()

getXMLBase

public java.lang.String getXMLBase()
Specified by:
getXMLBase in interface XMLWriter

getXMLBaseAsURI

public java.net.URI getXMLBaseAsURI()

getNamespacePrefixes

public XMLWriterNamespaceManager getNamespacePrefixes()
Description copied from interface: XMLWriter
Gets the Writer's namespace manager.

Specified by:
getNamespacePrefixes in interface XMLWriter
Returns:
The namespace manager.

setEncoding

public void setEncoding(java.lang.String encoding)
Description copied from interface: XMLWriter
Sets the encoding for the document that the rdfwriter produces. The default encoding is "UTF-8".

Specified by:
setEncoding in interface XMLWriter
Parameters:
encoding - The encoding.

setWrapAttributes

public void setWrapAttributes(boolean b)
Description copied from interface: XMLWriter
Causes the current element's attributes to be wrapped in the output.

Specified by:
setWrapAttributes in interface XMLWriter
Parameters:
b - If true then the attributes will be wrapped if they are long. If false then no attribute wrapping will occur.

writeStartElement

public void writeStartElement(java.lang.String name)
                       throws java.io.IOException
Description copied from interface: XMLWriter
Writes the start of an element.

Specified by:
writeStartElement in interface XMLWriter
Parameters:
name - The tag name of the element to be written. This must be a valid QName.
Throws:
java.io.IOException - if there was an IO problem

writeEndElement

public void writeEndElement()
                     throws java.io.IOException
Description copied from interface: XMLWriter
Writes the closing tag of the last element to be started.

Specified by:
writeEndElement in interface XMLWriter
Throws:
java.io.IOException - if there was an IO problem

writeAttribute

public void writeAttribute(java.lang.String attr,
                           java.lang.String val)
Description copied from interface: XMLWriter
Writes an attribute of the last element to be started (that has not been closed).

Specified by:
writeAttribute in interface XMLWriter
Parameters:
attr - The name of the attribute
val - The value of the attribute

writeTextContent

public void writeTextContent(java.lang.String text)
Description copied from interface: XMLWriter
Writes a text element

Specified by:
writeTextContent in interface XMLWriter
Parameters:
text - The text to be written

writeComment

public void writeComment(java.lang.String commentText)
                  throws java.io.IOException
Specified by:
writeComment in interface XMLWriter
Throws:
java.io.IOException

startDocument

public void startDocument(java.lang.String rootElementName)
                   throws java.io.IOException
Description copied from interface: XMLWriter
Starts writing the document. The root element will contain the namespace declarations and xml:base attribute.

Specified by:
startDocument in interface XMLWriter
Parameters:
rootElementName - The name of the root element.
Throws:
java.io.IOException - if there was an IO problem

endDocument

public void endDocument()
                 throws java.io.IOException
Description copied from interface: XMLWriter
Causes all open elements, including the document root element, to be closed.

Specified by:
endDocument in interface XMLWriter
Throws:
java.io.IOException - if there was an IO problem