org.teiid.test.client.ctc
Class XMLQueryVisitationStrategy

java.lang.Object
  extended by org.teiid.test.client.ctc.XMLQueryVisitationStrategy

public class XMLQueryVisitationStrategy
extends java.lang.Object

This program helps in parsing XML Query and Results files into map objects containing individual queries/ResultSets

This program is useful to convert the JDBC ResultSet objects into XML format. We physically walk through the ResultSet object and use JDOM to convert the ResultSets into XML. This also helps convert Exceptions into XML format.


Constructor Summary
XMLQueryVisitationStrategy()
           
 
Method Summary
static org.jdom.Element jdomException(java.lang.Throwable ex, org.jdom.Element exceptionElement)
          Generate XML for an exception in Object form.
 java.util.List parseXMLQueryFile(java.lang.String queryScenarioID, java.io.File queryFile, java.lang.String querySetID)
          Consume an XML Query File and produce a Map containing queries, with queryNames/IDs as Keys.
 ResultsHolder parseXMLResultsFile(java.io.File resultsFile)
          Consume an XML results File and produce a Map containing query results as List objects, with resultNames/IDs as Keys.
 org.jdom.Element parseXMLResultsFile(java.io.File resultsFile, org.jdom.Element parent)
          Consume an XML results File, produce results as JDOM and add results to the given parent.
 org.jdom.Element produceMsg(java.lang.Object object, org.jdom.Element parent)
          Produce a JDOM Element for the instance of any Object.
 org.jdom.Element produceMsg(java.sql.ResultSet object, org.jdom.Element resultsElement)
          Produce a JDOM Element for an instance of a JDBC ResultSet object.
 org.jdom.Element produceResults(java.sql.ResultSet object)
          Produce a JDOM Element for an instance of a JDBC ResultSet object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLQueryVisitationStrategy

public XMLQueryVisitationStrategy()
Method Detail

parseXMLQueryFile

public java.util.List parseXMLQueryFile(java.lang.String queryScenarioID,
                                        java.io.File queryFile,
                                        java.lang.String querySetID)
                                 throws java.io.IOException,
                                        org.jdom.JDOMException
Consume an XML Query File and produce a Map containing queries, with queryNames/IDs as Keys.

Parameters:
queryFile - the XML file object that is to be parsed
Returns:
the List containing quers.
Throws:
org.jdom.JDOMException - if there is an error consuming the message.
java.io.IOException

parseXMLResultsFile

public ResultsHolder parseXMLResultsFile(java.io.File resultsFile)
                                  throws java.io.IOException,
                                         org.jdom.JDOMException
Consume an XML results File and produce a Map containing query results as List objects, with resultNames/IDs as Keys.

Parameters:
resultsFile - the XML file object that is to be parsed
Returns:
the Map containig results.
Throws:
org.jdom.JDOMException - if there is an error consuming the message.
java.io.IOException

parseXMLResultsFile

public org.jdom.Element parseXMLResultsFile(java.io.File resultsFile,
                                            org.jdom.Element parent)
                                     throws java.io.IOException,
                                            org.jdom.JDOMException
Consume an XML results File, produce results as JDOM and add results to the given parent.

Parameters:
resultsFile - the XML file object that is to be parsed
parent - the parent Element to assign results to
Returns:
the modified parent
Throws:
org.jdom.JDOMException - if there is an error consuming the message.
java.io.IOException

jdomException

public static org.jdom.Element jdomException(java.lang.Throwable ex,
                                             org.jdom.Element exceptionElement)
Generate XML for an exception in Object form.

Parameters:
ex -
exceptionElement -
Returns:
The JDOM exception element.

produceResults

public org.jdom.Element produceResults(java.sql.ResultSet object)
                                throws org.jdom.JDOMException,
                                       java.sql.SQLException
Produce a JDOM Element for an instance of a JDBC ResultSet object.

Parameters:
object - for which the JDOM Element is to be produced.
Returns:
the JDOM element of the ResultSet object that was converted to XML.
Throws:
org.jdom.JDOMException - if there is an error producing XML.
org.jdom.JDOMException - if there is an error producing XML.
java.sql.SQLException - if there is an error walking through the ResultSet object.

produceMsg

public org.jdom.Element produceMsg(java.sql.ResultSet object,
                                   org.jdom.Element resultsElement)
                            throws org.jdom.JDOMException,
                                   java.sql.SQLException
Produce a JDOM Element for an instance of a JDBC ResultSet object.

Parameters:
object - for which the JDOM Element is to be produced.
Returns:
the JDOM element of the results object that was converted to XML.
Throws:
org.jdom.JDOMException - if there is an error producing XML.
java.sql.SQLException - if there is an error walking through the ResultSet object.

produceMsg

public org.jdom.Element produceMsg(java.lang.Object object,
                                   org.jdom.Element parent)
                            throws org.jdom.JDOMException,
                                   java.sql.SQLException
Produce a JDOM Element for the instance of any Object.

Parameters:
object - the instance for which the message is to be produced.
parent - the XML element that is to be the parent of the produced XML message.
Returns:
the root element of the XML segment that was produced.
Throws:
org.jdom.JDOMException - if there is an error producing XML.
java.sql.SQLException


Copyright © 2011. All Rights Reserved.