com.mockrunner.jdbc
Class XMLResultSetFactory

java.lang.Object
  extended by com.mockrunner.jdbc.XMLResultSetFactory
All Implemented Interfaces:
ResultSetFactory

public class XMLResultSetFactory
extends java.lang.Object
implements ResultSetFactory

Can be used to create a ResultSet based on a an XML Document of the proper format. You can specify the dialect, for proper parsing of the document. Furthermore you can specify the dialect of the ResultSet, which determines the expected format of the XML Document and whether or not the column entries should be trimmed (default is true). The file can be specified directly or by its name. The class tries to find the file in the absolut or relative path and (if not found) by calling getResource. Note that the file must exist in the local file system and cannot be loaded from inside a jar archive.


Field Summary
static int SYBASE_DIALECT
           
 
Constructor Summary
XMLResultSetFactory(java.io.File file)
           
XMLResultSetFactory(java.lang.String fileName)
           
 
Method Summary
 MockResultSet create(java.lang.String id)
          Makes and returns a MockResultSet created from an existing and valid XML Document.
 MockResultSet createSybaseResultSet(java.lang.String id)
          Return a MockResultSet with proper column names and rows based on the XML Document.
 int getDialect()
          Get the dialect of the XML Document
 boolean getTrim()
          Get whether or not trim is true or false.
 java.io.File getXMLFile()
          Get the File being used to read in the ResultSet.
 void setDialect(int dialect)
          Set the dialect of the XML Document.
 void setTrim(boolean trim)
          Set if the column entries should be trimmed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYBASE_DIALECT

public static final int SYBASE_DIALECT
See Also:
Constant Field Values
Constructor Detail

XMLResultSetFactory

public XMLResultSetFactory(java.lang.String fileName)

XMLResultSetFactory

public XMLResultSetFactory(java.io.File file)
Method Detail

create

public MockResultSet create(java.lang.String id)
Makes and returns a MockResultSet created from an existing and valid XML Document.

Specified by:
create in interface ResultSetFactory
Returns:
a new MockResultSet

getXMLFile

public java.io.File getXMLFile()
Get the File being used to read in the ResultSet. Returns null if the file does not exist.

Returns:
the file

setTrim

public void setTrim(boolean trim)
Set if the column entries should be trimmed. Default is true.

Parameters:
trim -

getTrim

public boolean getTrim()
Get whether or not trim is true or false.


setDialect

public void setDialect(int dialect)
Set the dialect of the XML Document. Can be different for different database systems. Will determine the expected XML format for the ResultSet. SYBASE_DIALECT is the only accepted dialect for now.

Parameters:
dialect - int specifying which createXXXResultSet method to call.

getDialect

public int getDialect()
Get the dialect of the XML Document
Returns:
dialect

createSybaseResultSet

public MockResultSet createSybaseResultSet(java.lang.String id)
Return a MockResultSet with proper column names and rows based on the XML Document.

Returns:
MockResultSet Results read from XML Document.