com.ricebridge.xmlman.in
Class XmlResultSet

java.lang.Object
  extended bycom.ricebridge.xmlman.in.XmlResultSet
All Implemented Interfaces:
ResultSet

public class XmlResultSet
extends Object
implements ResultSet

Implementation of a ResultSet to present XML data.

This ResultSet provides much the same interface as a database ResultSet. This implementation assumes that your data is fairly well behaved and attempts direct data type conversions for methods like getInt(java.lang.String). Bad data will cause an exception to be thrown. Refer to ResultSet for method documentation if none is given here.

NOTE: in order to reuse the

The Source Code of this Java class is available under a BSD-style license.


Field Summary
protected  ArrayList iData
          Data as a List of String[] arrays.
protected  boolean iDataHasHeaders
          The first line of the CSV file may contain headers.
protected  DateFormat iDateFormat
          Default data format for date parsing.
protected  boolean iHeadersStored
          Flag to indicate that headers have been loaded.
protected  String[] iRecord
          Current data record.
protected  long iRecordIndex
          index of current record.
protected  XmlResultSetMetaData iXmlRSMD
          ResultSetMetaData provider
 
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
 
Constructor Summary
XmlResultSet()
          Support Class.newInstance() object instantiation.
XmlResultSet(List pData)
          Create a new ResultSet with specified a List of String[] arrays.
 
Method Summary
 boolean absolute(int pRow)
           
 void addRecord(String[] pRecord)
          Set data for ResultSet.
 void afterLast()
           
 void beforeFirst()
           
 void cancelRowUpdates()
           
 void clear()
          Remove all data rows.
 void clearWarnings()
           
 void close()
           
 void deleteRow()
           
 int findColumn(String pColumnName)
           
 boolean first()
           
 Array getArray(int pIndex)
           
 Array getArray(String pColName)
           
 InputStream getAsciiStream(int pColumnIndex)
           
 InputStream getAsciiStream(String pColumnName)
           
 BigDecimal getBigDecimal(int pColumnIndex)
           
 BigDecimal getBigDecimal(int pColumnIndex, int pScale)
           
 BigDecimal getBigDecimal(String pColumnName)
           
 BigDecimal getBigDecimal(String pColumnName, int pScale)
           
 InputStream getBinaryStream(int pColumnIndex)
           
 InputStream getBinaryStream(String pColumnName)
           
 Blob getBlob(int pIndex)
           
 Blob getBlob(String pColName)
           
 boolean getBoolean(int pColumnIndex)
           
 boolean getBoolean(String pColumnName)
           
 byte getByte(int pColumnIndex)
           
 byte getByte(String pColumnName)
           
 byte[] getBytes(int pColumnIndex)
           
 byte[] getBytes(String pColumnName)
           
 Reader getCharacterStream(int pColumnIndex)
           
 Reader getCharacterStream(String pColumnName)
           
 Clob getClob(int pIndex)
           
 Clob getClob(String pColName)
           
 int getConcurrency()
           
 String getCursorName()
           
 Date getDate(int pColumnIndex)
           
 Date getDate(int pColumnIndex, Calendar pCalendar)
          ignores Calendar
 Date getDate(String pColumnName)
           
 Date getDate(String pColumnName, Calendar pCalendar)
           
 double getDouble(int pColumnIndex)
           
 double getDouble(String pColumnName)
           
 int getFetchDirection()
           
 int getFetchSize()
           
 float getFloat(int pColumnIndex)
           
 float getFloat(String pColumnName)
           
 int getInt(int pColumnIndex)
           
 int getInt(String pColumnName)
           
 long getLong(int pColumnIndex)
           
 long getLong(String pColumnName)
           
 ResultSetMetaData getMetaData()
           
 Object getObject(int pColumnIndex)
           
 Object getObject(int pIndex, Map pMap)
           
 Object getObject(String pColumnName)
           
 Object getObject(String pColName, Map pMap)
           
 Ref getRef(int pIndex)
           
 Ref getRef(String pColName)
           
 int getRow()
           
 int getRowCount()
          Get the number of rows.
 short getShort(int pColumnIndex)
           
 short getShort(String pColumnName)
           
 Statement getStatement()
           
 String getString(int pColumnIndex)
           
 String getString(String pColumnName)
           
 Time getTime(int pColumnIndex)
           
 Time getTime(int pColumnIndex, Calendar pCalendar)
          Note: ignores Calendar.
 Time getTime(String pColumnName)
           
 Time getTime(String pColumnName, Calendar pCalendar)
           
 Timestamp getTimestamp(int pColumnIndex)
           
 Timestamp getTimestamp(int pColumnIndex, Calendar pCalendar)
          Note: ignores Calendar.
 Timestamp getTimestamp(String pColumnName)
           
 Timestamp getTimestamp(String pColumnName, Calendar pCalendar)
           
 int getType()
           
 InputStream getUnicodeStream(int pColumnIndex)
           
 InputStream getUnicodeStream(String pColumnName)
           
 URL getURL(int pColumnIndex)
           
 URL getURL(String pColumnName)
           
 SQLWarning getWarnings()
           
 void init()
          Initialise the internal data containers before loading new XML record data.
 void insertRow()
           
 boolean isAfterLast()
           
 boolean isBeforeFirst()
           
 boolean isFirst()
           
 boolean isLast()
           
 boolean last()
           
 void moveToCurrentRow()
           
 void moveToInsertRow()
           
protected  boolean moveToLine()
          Move to correct data line.
 boolean next()
           
 boolean previous()
           
 void refreshRow()
           
 boolean relative(int pRows)
           
 boolean rowDeleted()
           
 boolean rowInserted()
           
 boolean rowUpdated()
           
 void setDataHasHeaders(boolean pDataHasHeaders)
          The first record contains the column names.
 void setDateFormat(DateFormat pDateFormat)
          Specify custom date format.
 void setFetchDirection(int pDirection)
           
 void setFetchSize(int pRows)
           
 void setHeaders(String[] pHeaders)
          Set the column header names.
 String toString()
          String description of object instance.
 void updateArray(int pColumnIndex, Array pArray)
           
 void updateArray(String pColumnName, Array pArray)
           
 void updateAsciiStream(int pColumnIndex, InputStream pInputStream, int pLength)
           
 void updateAsciiStream(String pColumnName, InputStream pInputStream, int pLength)
           
 void updateBigDecimal(int pColumnIndex, BigDecimal pBigDecimal)
           
 void updateBigDecimal(String pColumnName, BigDecimal pBigDecimal)
           
 void updateBinaryStream(int pColumnIndex, InputStream pInputStream, int pLength)
           
 void updateBinaryStream(String pColumnName, InputStream pInputStream, int pLength)
           
 void updateBlob(int pColumnIndex, Blob pBlob)
           
 void updateBlob(String pColumnName, Blob pBlob)
           
 void updateBoolean(int pColumnIndex, boolean pValue)
           
 void updateBoolean(String pColumnName, boolean pValue)
           
 void updateByte(int pColumnIndex, byte pValue)
           
 void updateByte(String pColumnName, byte pValue)
           
 void updateBytes(int pColumnIndex, byte[] pBytes)
           
 void updateBytes(String pColumnName, byte[] pBytes)
           
 void updateCharacterStream(int pColumnIndex, Reader pReader, int pLength)
           
 void updateCharacterStream(String pColumnName, Reader pReader, int pLength)
           
 void updateClob(int pColumnIndex, Clob pValue)
           
 void updateClob(String pColumnName, Clob pValue)
           
 void updateDate(int pColumnIndex, Date pValue)
           
 void updateDate(String pColumnName, Date pValue)
           
 void updateDouble(int pColumnIndex, double pValue)
           
 void updateDouble(String pColumnName, double pValue)
           
 void updateFloat(int pColumnIndex, float pValue)
           
 void updateFloat(String pColumnName, float pValue)
           
 void updateInt(int pColumnIndex, int pValue)
           
 void updateInt(String pColumnName, int pValue)
           
 void updateLong(int pColumnIndex, long pValue)
           
 void updateLong(String pColumnName, long pValue)
           
 void updateNull(int pColumnIndex)
           
 void updateNull(String pColumnName)
           
 void updateObject(int pColumnIndex, Object pValue)
           
 void updateObject(int pColumnIndex, Object pValue, int pScale)
           
 void updateObject(String pColumnName, Object pValue)
           
 void updateObject(String pColumnName, Object pValue, int pScale)
           
 void updateRef(int pColumnIndex, Ref pValue)
           
 void updateRef(String pColumnName, Ref pValue)
           
 void updateRow()
           
 void updateShort(int pColumnIndex, short pValue)
           
 void updateShort(String pColumnName, short pValue)
           
 void updateString(int pColumnIndex, String pValue)
           
 void updateString(String pColumnName, String pValue)
           
 void updateTime(int pColumnIndex, Time pValue)
           
 void updateTime(String pColumnName, Time pValue)
           
 void updateTimestamp(int pColumnIndex, Timestamp pValue)
           
 void updateTimestamp(String pColumnName, Timestamp pValue)
           
 boolean wasNull()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iData

protected ArrayList iData
Data as a List of String[] arrays.


iRecord

protected String[] iRecord
Current data record.


iRecordIndex

protected long iRecordIndex
index of current record.


iDateFormat

protected DateFormat iDateFormat
Default data format for date parsing.


iXmlRSMD

protected XmlResultSetMetaData iXmlRSMD
ResultSetMetaData provider


iDataHasHeaders

protected boolean iDataHasHeaders
The first line of the CSV file may contain headers.


iHeadersStored

protected boolean iHeadersStored
Flag to indicate that headers have been loaded.

Constructor Detail

XmlResultSet

public XmlResultSet()
Support Class.newInstance() object instantiation.


XmlResultSet

public XmlResultSet(List pData)
Create a new ResultSet with specified a List of String[] arrays.

Method Detail

getArray

public Array getArray(String pColName)
               throws SQLException
Specified by:
getArray in interface ResultSet
Throws:
SQLException

getArray

public Array getArray(int pIndex)
               throws SQLException
Specified by:
getArray in interface ResultSet
Throws:
SQLException

getBlob

public Blob getBlob(String pColName)
             throws SQLException
Specified by:
getBlob in interface ResultSet
Throws:
SQLException

getBlob

public Blob getBlob(int pIndex)
             throws SQLException
Specified by:
getBlob in interface ResultSet
Throws:
SQLException

getClob

public Clob getClob(String pColName)
             throws SQLException
Specified by:
getClob in interface ResultSet
Throws:
SQLException

getClob

public Clob getClob(int pIndex)
             throws SQLException
Specified by:
getClob in interface ResultSet
Throws:
SQLException

getObject

public Object getObject(String pColName,
                        Map pMap)
                 throws SQLException
Specified by:
getObject in interface ResultSet
Throws:
SQLException

getObject

public Object getObject(int pIndex,
                        Map pMap)
                 throws SQLException
Specified by:
getObject in interface ResultSet
Throws:
SQLException

getRef

public Ref getRef(String pColName)
           throws SQLException
Specified by:
getRef in interface ResultSet
Throws:
SQLException

getRef

public Ref getRef(int pIndex)
           throws SQLException
Specified by:
getRef in interface ResultSet
Throws:
SQLException

getStatement

public Statement getStatement()
                       throws SQLException
Specified by:
getStatement in interface ResultSet
Throws:
SQLException

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Specified by:
getWarnings in interface ResultSet
Throws:
SQLException

getCursorName

public String getCursorName()
                     throws SQLException
Specified by:
getCursorName in interface ResultSet
Throws:
SQLException

rowDeleted

public boolean rowDeleted()
                   throws SQLException
Specified by:
rowDeleted in interface ResultSet
Throws:
SQLException

rowInserted

public boolean rowInserted()
                    throws SQLException
Specified by:
rowInserted in interface ResultSet
Throws:
SQLException

rowUpdated

public boolean rowUpdated()
                   throws SQLException
Specified by:
rowUpdated in interface ResultSet
Throws:
SQLException

wasNull

public boolean wasNull()
                throws SQLException
Specified by:
wasNull in interface ResultSet
Throws:
SQLException

getFetchDirection

public int getFetchDirection()
                      throws SQLException
Specified by:
getFetchDirection in interface ResultSet
Throws:
SQLException

setFetchDirection

public void setFetchDirection(int pDirection)
                       throws SQLException
Specified by:
setFetchDirection in interface ResultSet
Throws:
SQLException

getFetchSize

public int getFetchSize()
                 throws SQLException
Specified by:
getFetchSize in interface ResultSet
Throws:
SQLException

setFetchSize

public void setFetchSize(int pRows)
                  throws SQLException
Specified by:
setFetchSize in interface ResultSet
Throws:
SQLException

getConcurrency

public int getConcurrency()
                   throws SQLException
Specified by:
getConcurrency in interface ResultSet
Throws:
SQLException

cancelRowUpdates

public void cancelRowUpdates()
                      throws SQLException
Specified by:
cancelRowUpdates in interface ResultSet
Throws:
SQLException

clearWarnings

public void clearWarnings()
                   throws SQLException
Specified by:
clearWarnings in interface ResultSet
Throws:
SQLException

close

public void close()
           throws SQLException
Specified by:
close in interface ResultSet
Throws:
SQLException

deleteRow

public void deleteRow()
               throws SQLException
Specified by:
deleteRow in interface ResultSet
Throws:
SQLException

insertRow

public void insertRow()
               throws SQLException
Specified by:
insertRow in interface ResultSet
Throws:
SQLException

moveToCurrentRow

public void moveToCurrentRow()
                      throws SQLException
Specified by:
moveToCurrentRow in interface ResultSet
Throws:
SQLException

moveToInsertRow

public void moveToInsertRow()
                     throws SQLException
Specified by:
moveToInsertRow in interface ResultSet
Throws:
SQLException

refreshRow

public void refreshRow()
                throws SQLException
Specified by:
refreshRow in interface ResultSet
Throws:
SQLException

updateArray

public void updateArray(String pColumnName,
                        Array pArray)
                 throws SQLException
Specified by:
updateArray in interface ResultSet
Throws:
SQLException

updateArray

public void updateArray(int pColumnIndex,
                        Array pArray)
                 throws SQLException
Specified by:
updateArray in interface ResultSet
Throws:
SQLException

updateAsciiStream

public void updateAsciiStream(String pColumnName,
                              InputStream pInputStream,
                              int pLength)
                       throws SQLException
Specified by:
updateAsciiStream in interface ResultSet
Throws:
SQLException

updateAsciiStream

public void updateAsciiStream(int pColumnIndex,
                              InputStream pInputStream,
                              int pLength)
                       throws SQLException
Specified by:
updateAsciiStream in interface ResultSet
Throws:
SQLException

updateBigDecimal

public void updateBigDecimal(String pColumnName,
                             BigDecimal pBigDecimal)
                      throws SQLException
Specified by:
updateBigDecimal in interface ResultSet
Throws:
SQLException

updateBigDecimal

public void updateBigDecimal(int pColumnIndex,
                             BigDecimal pBigDecimal)
                      throws SQLException
Specified by:
updateBigDecimal in interface ResultSet
Throws:
SQLException

updateBinaryStream

public void updateBinaryStream(String pColumnName,
                               InputStream pInputStream,
                               int pLength)
                        throws SQLException
Specified by:
updateBinaryStream in interface ResultSet
Throws:
SQLException

updateBinaryStream

public void updateBinaryStream(int pColumnIndex,
                               InputStream pInputStream,
                               int pLength)
                        throws SQLException
Specified by:
updateBinaryStream in interface ResultSet
Throws:
SQLException

updateBlob

public void updateBlob(String pColumnName,
                       Blob pBlob)
                throws