Search this API

y.io.graphml.output
Class DomXmlWriter

java.lang.Object
  extended by y.io.graphml.output.AbstractXmlWriter
      extended by y.io.graphml.output.DomXmlWriter
All Implemented Interfaces:
XmlWriter

public class DomXmlWriter
extends AbstractXmlWriter

Implementation of interface XmlWriter that used a DOM tree internally to build the serialized graphml representation.

 

Constructor Summary
DomXmlWriter(java.io.OutputStream ostr, java.lang.String encoding)
          Create a new instance that writes the content to the specified stream
DomXmlWriter(javax.xml.transform.Result result)
          Create a new instance that writes the content to the specified Result instance
DomXmlWriter(java.io.Writer w)
          Create a new instance that writes the content to the specified Writer instance
 
Method Summary
protected  void configureTransformer(javax.xml.transform.Transformer transformer)
          Configure the transformer that is used internally to transform the internal DOM tree to the actual result.
protected  XmlNamespaceManager createNamespaceManager()
          Factory method that creates the namespace manager for this instance.
protected  javax.xml.transform.Transformer createTransformer()
          Create the transformer that is used internally to transform the internal DOM tree to the actual result.
 void flushDocument()
          Close the document.
 boolean isWriteXmlDeclaration()
          Whether to write a xml declaration prolog.
 void setWriteXmlDeclaration(boolean writeDecl)
          Whether to write a xml declaration prolog.
protected  void writeAttributeCore(java.lang.String prefix, java.lang.String localName, java.lang.String ns, java.lang.String value)
          The core method that actually writes an attribute.
 XmlWriter writeCData(java.lang.String s)
          Write a CDATA section.
 XmlWriter writeComment(java.lang.String comment)
          Write a XML comment node.
 XmlWriter writeDocumentFragment(org.w3c.dom.DocumentFragment frag)
          Write a document fragment.
 void writeEndDocument()
          Close the output.
protected  void writeEndElementCore()
          The core method that actually writes the end element.
 XmlWriter writeProcessingInstruction(java.lang.String target, java.lang.String pi)
          Write a xml processing instruction.
 XmlWriter writeStartDocument()
          Begin the output process.
protected  void writeStartElementCore(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)
          The core method that actually writes the starting element.
 XmlWriter writeText(java.lang.String s)
          Write a text node.
protected  void writeXmlNode(org.w3c.dom.Node n)
          Directly write an XML node.
 
Methods inherited from class y.io.graphml.output.AbstractXmlWriter
getNamespaceManager, writeAttribute, writeAttribute, writeAttribute, writeAttribute, writeAttribute, writeAttribute, writeEndElement, writeStartElement, writeStartElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomXmlWriter

public DomXmlWriter(java.io.OutputStream ostr,
                    java.lang.String encoding)
             throws GraphMLWriteException
Create a new instance that writes the content to the specified stream

Parameters:
ostr - the stream target of the writer
encoding - The encoding to use.
Throws:
GraphMLWriteException

DomXmlWriter

public DomXmlWriter(java.io.Writer w)
             throws GraphMLWriteException
Create a new instance that writes the content to the specified Writer instance

Parameters:
w - the Writer target of this instance
Throws:
GraphMLWriteException

DomXmlWriter

public DomXmlWriter(javax.xml.transform.Result result)
             throws GraphMLWriteException
Create a new instance that writes the content to the specified Result instance

Parameters:
result - the Result target of this instance
Throws:
GraphMLWriteException
Method Detail

isWriteXmlDeclaration

public boolean isWriteXmlDeclaration()
Whether to write a xml declaration prolog.

By default, this value is true.

Returns:
true iff a xml declaration prolog should be written.
See Also:
setWriteXmlDeclaration(boolean)

setWriteXmlDeclaration

public void setWriteXmlDeclaration(boolean writeDecl)
Whether to write a xml declaration prolog.

By default, this value is true.

Parameters:
writeDecl - true iff a xml declaration prolog should be written.
See Also:
isWriteXmlDeclaration()

writeComment

public XmlWriter writeComment(java.lang.String comment)
Description copied from interface: XmlWriter
Write a XML comment node.

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

writeProcessingInstruction

public XmlWriter writeProcessingInstruction(java.lang.String target,
                                            java.lang.String pi)
Description copied from interface: XmlWriter
Write a xml processing instruction.

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

writeStartDocument

public XmlWriter writeStartDocument()
Description copied from interface: XmlWriter
Begin the output process.

Returns:
The writer instance for further chaining

writeEndDocument

public void writeEndDocument()
Description copied from interface: XmlWriter
Close the output. Attempts to write after this method has been called will have undefined results.


flushDocument

public void flushDocument()
                   throws GraphMLWriteException
Description copied from interface: XmlWriter
Close the document. This is typically used to actually flush the document to an output stream.

Throws:
GraphMLWriteException

configureTransformer

protected void configureTransformer(javax.xml.transform.Transformer transformer)
Configure the transformer that is used internally to transform the internal DOM tree to the actual result.

Parameters:
transformer - The transformer to configure.
See Also:
createTransformer()

createTransformer

protected javax.xml.transform.Transformer createTransformer()
                                                     throws GraphMLWriteException
Create the transformer that is used internally to transform the internal DOM tree to the actual result.

Returns:
The transformer to use.
Throws:
GraphMLWriteException
See Also:
configureTransformer(javax.xml.transform.Transformer)

writeStartElementCore

protected void writeStartElementCore(java.lang.String prefix,
                                     java.lang.String localName,
                                     java.lang.String nsURI)
Description copied from class: AbstractXmlWriter
The core method that actually writes the starting element.

Specified by:
writeStartElementCore in class AbstractXmlWriter
Parameters:
prefix - The prefix or null.
localName - The name of the element.
nsURI - The namespace uri of the element.

writeEndElementCore

protected void writeEndElementCore()
Description copied from class: AbstractXmlWriter
The core method that actually writes the end element.

Specified by:
writeEndElementCore in class AbstractXmlWriter

writeAttributeCore

protected void writeAttributeCore(java.lang.String prefix,
                                  java.lang.String localName,
                                  java.lang.String ns,
                                  java.lang.String value)
Description copied from class: AbstractXmlWriter
The core method that actually writes an attribute.

Specified by:
writeAttributeCore in class AbstractXmlWriter
Parameters:
prefix - The prefix or null.
localName - The name of the element.
ns - The namespace uri of the element.
value - The value of the attribute.

createNamespaceManager

protected XmlNamespaceManager createNamespaceManager()
Factory method that creates the namespace manager for this instance.

Specified by:
createNamespaceManager in class AbstractXmlWriter
Returns:
A new manager instance.

writeText

public XmlWriter writeText(java.lang.String s)
Description copied from interface: XmlWriter
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

writeCData

public XmlWriter writeCData(java.lang.String s)
Description copied from interface: XmlWriter
Write a CDATA section.

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

writeDocumentFragment

public XmlWriter writeDocumentFragment(org.w3c.dom.DocumentFragment frag)
Description copied from interface: XmlWriter
Write a document fragment.

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

writeXmlNode

protected void writeXmlNode(org.w3c.dom.Node n)
Directly write an XML node. This implementation copies the node through calls to AbstractXmlWriter.writeStartElement(String,String,String), AbstractXmlWriter.writeAttribute(String,String) and similar.

Parameters:
n - The node to write.

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