Keel 2.1RC2

org.keel.comm
Class ModelResponseSerializer

java.lang.Object
  extended byorg.keel.comm.ModelResponseSerializer

public class ModelResponseSerializer
extends java.lang.Object

Author:
Michael Nash Return a DOM Element representing a ModelResponse, serialized to XML $Date: 2004/05/11 20:31:08 $ $Revision: 1.2 $

Field Summary
private static int count
           
 
Constructor Summary
private ModelResponseSerializer()
           
 
Method Summary
private static org.w3c.dom.Element createValidNameElement(org.w3c.dom.Document xmldoc, java.lang.String name)
          Special wrapper around createElement to ensure we don't try to create an element with an invalid name.
private static void handleAttributes(ResponseElement re, org.w3c.dom.Element e, org.w3c.dom.Document xmldoc, boolean useElementNames, java.lang.String rootPath)
           
private static void handleNested(ResponseElement re, org.w3c.dom.Element e, org.w3c.dom.Document xmldoc, boolean useElementNames, java.lang.String rootDir)
          Handle nested ResponseElements, creating the appropriate nested tree of XML elements
static org.w3c.dom.Document serialize(KeelResponse res, java.lang.String modelName)
           
static org.w3c.dom.Document serialize(KeelResponse res, java.lang.String modelName, java.lang.String rootPath)
          Serialize a ModelResponse in a DOM Document
private static void serialize(ResponseElement re, org.w3c.dom.Element parent, org.w3c.dom.Document xmldoc, boolean elementNames, java.lang.String rootDir)
          Internal method to serialize each ResponseElement
private static void serializeBinaryWrapper(org.w3c.dom.Document xmldoc, org.w3c.dom.Element parent, BinaryWrapper bw, java.lang.String rootPath)
           
private static void serializeContents(org.w3c.dom.Document xmldoc, org.w3c.dom.Element parent, java.lang.Object c)
           
static java.lang.String serializeToString(KeelResponse res, java.lang.String modelName)
          Return the serialized ModelResponse as a formatted String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

private static int count
Constructor Detail

ModelResponseSerializer

private ModelResponseSerializer()
Method Detail

serialize

public static org.w3c.dom.Document serialize(KeelResponse res,
                                             java.lang.String modelName)
                                      throws javax.xml.parsers.ParserConfigurationException,
                                             org.xml.sax.SAXException
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

serialize

public static org.w3c.dom.Document serialize(KeelResponse res,
                                             java.lang.String modelName,
                                             java.lang.String rootPath)
                                      throws javax.xml.parsers.ParserConfigurationException,
                                             org.xml.sax.SAXException
Serialize a ModelResponse in a DOM Document

Parameters:
res - The ModelResponse to be serialized
modelName - The name of the Model that generated this response (it's shorthand, not it's class name)
Returns:
Document The DOM Document containing the serialized response
Throws:
javax.xml.parsers.ParserConfigurationException - If the XML Parser configuration is incorrect
org.xml.sax.SAXException - If an XML error occurrs during serialization

serializeToString

public static java.lang.String serializeToString(KeelResponse res,
                                                 java.lang.String modelName)
                                          throws javax.xml.parsers.ParserConfigurationException,
                                                 org.xml.sax.SAXException,
                                                 java.io.IOException
Return the serialized ModelResponse as a formatted String

Parameters:
res - The ModelResponse to be serialized
modelName - The name of the model called
Returns:
String The Response formatted as an XML String
Throws:
javax.xml.parsers.ParserConfigurationException - If the XML Parser configuration was bad
org.xml.sax.SAXException - If there is an error during serialization
java.io.IOException - If there is an error during formatting/serializing

serialize

private static void serialize(ResponseElement re,
                              org.w3c.dom.Element parent,
                              org.w3c.dom.Document xmldoc,
                              boolean elementNames,
                              java.lang.String rootDir)
                       throws org.xml.sax.SAXException
Internal method to serialize each ResponseElement

Parameters:
re - The ResponseElement to serialize
parent - The parent Element
xmldoc - The top-level document
elementNames - Use element names (or generic names) for each sub- element?
Throws:
org.xml.sax.SAXException - If an XML error occurrs during serialization

handleAttributes

private static void handleAttributes(ResponseElement re,
                                     org.w3c.dom.Element e,
                                     org.w3c.dom.Document xmldoc,
                                     boolean useElementNames,
                                     java.lang.String rootPath)
                              throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

handleNested

private static void handleNested(ResponseElement re,
                                 org.w3c.dom.Element e,
                                 org.w3c.dom.Document xmldoc,
                                 boolean useElementNames,
                                 java.lang.String rootDir)
                          throws org.xml.sax.SAXException
Handle nested ResponseElements, creating the appropriate nested tree of XML elements

Parameters:
re - The ResponseElement to serialize
e - The element of which this new element will be a child
xmldoc - The top-level document
useElementNames - Use the name of each ResponseElement or generic names?
Throws:
org.xml.sax.SAXException - If an XML error occurs during serialization

createValidNameElement

private static org.w3c.dom.Element createValidNameElement(org.w3c.dom.Document xmldoc,
                                                          java.lang.String name)
Special wrapper around createElement to ensure we don't try to create an element with an invalid name. If so, use a temporary name and warn.

Parameters:
xmldoc -
name -
Returns:
Element

serializeContents

private static void serializeContents(org.w3c.dom.Document xmldoc,
                                      org.w3c.dom.Element parent,
                                      java.lang.Object c)

serializeBinaryWrapper

private static void serializeBinaryWrapper(org.w3c.dom.Document xmldoc,
                                           org.w3c.dom.Element parent,
                                           BinaryWrapper bw,
                                           java.lang.String rootPath)

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.