fr.umlv.tatoo.runtime.ast
Class XML

java.lang.Object
  extended by fr.umlv.tatoo.runtime.ast.XML

public class XML
extends Object

This class contains static methods usefull for serialize/deserialize an AST.

Author:
Remi

Method Summary
static SAXSource createSAXSource(Node node)
          Returns a SAXSource that can be using as an input of a transform operation on an XML Transformer.
static void serialize(Writer writer, Node node)
          Writes the node and all it's subnode in XML on the writer.
static void transform(Node node, Result result)
          Apply an identity transformation on the AST views as an XML tree.
static Node unserialize(Reader reader, XMLNodeFactory builder)
          De-serialize an XML reader to an AST.
static Node unserialize(Reader reader, XMLNodeFactory builder, StringConverter converter)
          De-serialize an XML reader to an AST.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

serialize

public static void serialize(Writer writer,
                             Node node)
                      throws IOException
Writes the node and all it's subnode in XML on the writer.

Parameters:
writer - the writer used to write the XML tree.
node - the root of the AST.
Throws:
IOException - raised on a error of the underlying writer.
See Also:
createSAXSource(Node), transform(Node,Result)

createSAXSource

public static SAXSource createSAXSource(Node node)
Returns a SAXSource that can be using as an input of a transform operation on an XML Transformer.

Parameters:
node - root of the AST.
Returns:
a SAXSource.
See Also:
transform(Node, Result), Transformer.transform(javax.xml.transform.Source, Result)

transform

public static void transform(Node node,
                             Result result)
                      throws TransformerConfigurationException,
                             TransformerException
Apply an identity transformation on the AST views as an XML tree. This method permits by example to transform an AST to a DOM :
   fr.umlv.tatoo.runtime.ast.Node astToot=...
   DOMResult result=new DOMResult();
   XML.transform(root,result);
   org.w3c.dom.Node domRoot=result.getNode();
  

Parameters:
node - the root of the AST.
result - a transformation result.
Throws:
TransformerConfigurationException - if no transformer available.
TransformerException - if the transformer issue an error.
See Also:
createSAXSource(Node)

unserialize

public static Node unserialize(Reader reader,
                               XMLNodeFactory builder)
                        throws IOException
De-serialize an XML reader to an AST.

Parameters:
reader - the reader containing XML.
builder - the builder used to create AST node.
Returns:
the root of the AST.
Throws:
IOException - if an error occured on the underlying reader.
See Also:
unserialize(Reader,XMLNodeFactory,StringConverter)

unserialize

public static Node unserialize(Reader reader,
                               XMLNodeFactory builder,
                               StringConverter converter)
                        throws IOException
De-serialize an XML reader to an AST.

Parameters:
reader - the reader containing XML.
builder - the builder used to create AST node.
converter - used to transforme XML attribute avlue to AST attibute object.
Returns:
the root of the AST.
Throws:
IOException - if an error occured on the underlying reader.
See Also:
unserialize(Reader,XMLNodeFactory,StringConverter)