Search this API

y.io.graphml.output
Interface XmlWriter

All Known Implementing Classes:
AbstractXmlWriter, DomXmlWriter

public interface XmlWriter

Abstraction of XML output classes that provide a consistent way to write XML elements to some output.

 

Method Summary
 void flushDocument()
          Close the document.
 XmlNamespaceManager getNamespaceManager()
          Gets the XmlNamespaceManager manager associated with this writer.
 XmlWriter writeAttribute(GraphMLXmlAttribute attribute)
          Write an XML attribute from the given attribute struct.
 XmlWriter writeAttribute(java.lang.String localName, boolean value)
          Convenience method to directly write a boolean valued XML attribute.
 XmlWriter writeAttribute(java.lang.String localName, double value)
          Convenience method to directly write a double valued XML attribute.
 XmlWriter writeAttribute(java.lang.String localName, long value)
          Convenience method to directly write a integer valued XML attribute.
 XmlWriter writeAttribute(java.lang.String localName, java.lang.String value)
          Write a XML attribute node.
 XmlWriter writeAttribute(java.lang.String prefix, java.lang.String localName, java.lang.String ns, java.lang.String value)
          Write a XML attribute node.
 XmlWriter writeCData(java.lang.String content)
          Write a CDATA section.
 XmlWriter writeComment(java.lang.String comment)
          Write a XML comment node.
 XmlWriter writeDocumentFragment(org.w3c.dom.DocumentFragment fragment)
          Write a document fragment.
 void writeEndDocument()
          Close the output.
 XmlWriter writeEndElement()
          Close a XML element previously opened with writeStartElement(String,String) or writeStartElement(String,String,String).
 XmlWriter writeProcessingInstruction(java.lang.String target, java.lang.String data)
          Write a xml processing instruction.
 XmlWriter writeStartDocument()
          Begin the output process.
 XmlWriter writeStartElement(java.lang.String localName, java.lang.String ns)
          Begin a new XML element with given parameters.
 XmlWriter writeStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String ns)
          Begin a new XML element with given parameters.
 XmlWriter writeText(java.lang.String s)
          Write a text node.
 

Method Detail

writeComment

XmlWriter writeComment(java.lang.String comment)
Write a XML comment node.

Parameters:
comment - The content of the comment
Returns:
The writer instance for further chaining

writeEndDocument

void writeEndDocument()
Close the output. Attempts to write after this method has been called will have undefined results.


writeStartElement

XmlWriter writeStartElement(java.lang.String prefix,
                            java.lang.String localName,
                            java.lang.String ns)
Begin a new XML element with given parameters. All subsequent output is attached to this element until writeEndElement() has been called or a new element has been started.

Parameters:
prefix - The namespace prefix to use for this element
localName - The local name of this element
ns - The namespace of this element
Returns:
The writer instance for further chaining

writeStartElement

XmlWriter writeStartElement(java.lang.String localName,
                            java.lang.String ns)
Begin a new XML element with given parameters.

All subsequent output is attached to this element until writeEndElement() has been called or a new element has been started.

The if the namespace is declared in an enclosing scope, the prefix is used from this declaration, otherwise the namespace is declared as default namespace for this element.

Parameters:
localName - The local name of this element
ns - The namespace of this element
Returns:
The writer instance for further chaining

writeAttribute

XmlWriter writeAttribute(java.lang.String prefix,
                         java.lang.String localName,
                         java.lang.String ns,
                         java.lang.String value)
Write a XML attribute node. The attribute is attached to the closest open XML element that has been started with writeStartElement(String,String) or writeStartElement(String,String,String).

Parameters:
prefix - The namespace prefix of the attribute
localName - The local name of the attribute
ns - The namespace URI of this attribute
value - The value of this attribute
Returns:
The writer instance for further chaining

writeDocumentFragment

XmlWriter writeDocumentFragment(org.w3c.dom.DocumentFragment fragment)
Write a document fragment.

Parameters:
fragment - The fragment.
Returns:
The writer instance for further chaining

writeProcessingInstruction

XmlWriter writeProcessingInstruction(java.lang.String target,
                                     java.lang.String data)
Write a xml processing instruction.

Parameters:
target - The target of the PI
data - The data of the PI
Returns:
The writer instance for further chaining

writeCData

XmlWriter writeCData(java.lang.String content)
Write a CDATA section.

Parameters:
content - The content of the CDATA section
Returns:
The writer instance for further chaining

writeEndElement

XmlWriter writeEndElement()
Close a XML element previously opened with writeStartElement(String,String) or writeStartElement(String,String,String).

Returns:
The writer instance for further chaining

writeStartDocument

XmlWriter writeStartDocument()
Begin the output process.

Returns:
The writer instance for further chaining

flushDocument

void flushDocument()
                   throws GraphMLWriteException
Close the document. This is typically used to actually flush the document to an output stream.

Throws:
GraphMLWriteException

getNamespaceManager

XmlNamespaceManager getNamespaceManager()
Gets the XmlNamespaceManager manager associated with this writer.

Returns:
The namespace manager.

writeText

XmlWriter writeText(java.lang.String s)
Write a text node. The string value of s will be correctly escaped

Parameters:
s - The string that gets written as XML text
Returns:
The writer instance for further chaining

writeAttribute

XmlWriter writeAttribute(java.lang.String localName,
                         java.lang.String value)
Write a XML attribute node. The attribute is attached to the closest open XML element that has been started with writeStartElement(String,String) or writeStartElement(String,String,String).

Parameters:
localName - The local name of the attribute
value - The value of this attribute
Returns:
The writer instance for further chaining

writeAttribute

XmlWriter writeAttribute(GraphMLXmlAttribute attribute)
Write an XML attribute from the given attribute struct.

Parameters:
attribute - Encapsulates the current attribute values.
Returns:
The writer instance writer for writer chaining.

writeAttribute

XmlWriter writeAttribute(java.lang.String localName,
                         double value)
Convenience method to directly write a double valued XML attribute.

Parameters:
localName - The local name of the attribute
value - The value of this attribute
Returns:
The writer instance for further chaining

writeAttribute

XmlWriter writeAttribute(java.lang.String localName,
                         long value)
Convenience method to directly write a integer valued XML attribute.

Parameters:
localName - The local name of the attribute
value - The value of this attribute
Returns:
The writer instance for further chaining

writeAttribute

XmlWriter writeAttribute(java.lang.String localName,
                         boolean value)
Convenience method to directly write a boolean valued XML attribute.

Parameters:
localName - The local name of the attribute
value - The value of this attribute
Returns:
The writer instance for further chaining

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.