|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.csvman.CsvResultSet
Implementation of a ResultSet to present CSV 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.
The Source Code of this Java class is available under a BSD-style license.
| Field Summary | |
protected CsvResultSetMetaData |
iCsvRSMD
ResultSetMetaData provider |
protected ArrayList |
iData
Data as a List of String[] arrays. |
protected DateFormat |
iDateFormat
Default data format for date parsing. |
protected String[] |
iLine
Current line of data. |
protected long |
iLineIndex
index of current line. |
| 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 | |
CsvResultSet()
Create a new empty ResultSet. |
|
CsvResultSet(ArrayList pData,
boolean pHasHeaders,
int pExpectedNumFields)
Create a new ResultSet from CSV data. |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected ArrayList iData
List of String[] arrays.
protected String[] iLine
protected long iLineIndex
protected DateFormat iDateFormat
protected CsvResultSetMetaData iCsvRSMD
| Constructor Detail |
public CsvResultSet(ArrayList pData,
boolean pHasHeaders,
int pExpectedNumFields)
ResultSet from CSV data.
When pHasHeaders is true, the first line of data is used as the names of the columns
and getMetaData() will return these column names.
When pHasHeaders is false, default names of the form Column X are generated.
pData - List of String[]pHasHeaders - first row is headerspublic CsvResultSet()
ResultSet.
Initialise with setData(java.util.ArrayList, boolean, int)
| Method Detail |
public Array getArray(String pColName)
throws SQLException
getArray in interface ResultSetSQLException
public Array getArray(int pIndex)
throws SQLException
getArray in interface ResultSetSQLException
public Blob getBlob(String pColName)
throws SQLException
getBlob in interface ResultSetSQLException
public Blob getBlob(int pIndex)
throws SQLException
getBlob in interface ResultSetSQLException
public Clob getClob(String pColName)
throws SQLException
getClob in interface ResultSetSQLException
public Clob getClob(int pIndex)
throws SQLException
getClob in interface ResultSetSQLException
public Object getObject(String pColName,
Map pMap)
throws SQLException
getObject in interface ResultSetSQLException
public Object getObject(int pIndex,
Map pMap)
throws SQLException
getObject in interface ResultSetSQLException
public Ref getRef(String pColName)
throws SQLException
getRef in interface ResultSetSQLException
public Ref getRef(int pIndex)
throws SQLException
getRef in interface ResultSetSQLException
public Statement getStatement()
throws SQLException
getStatement in interface ResultSetSQLException
public SQLWarning getWarnings()
throws SQLException
ResultSet.getWarnings().
getWarnings in interface ResultSetSQLException
public String getCursorName()
throws SQLException
ResultSet.getCursorName().
getCursorName in interface ResultSetSQLException
public boolean rowDeleted()
throws SQLException
ResultSet.rowDeleted().
rowDeleted in interface ResultSetSQLException
public boolean rowInserted()
throws SQLException
ResultSet.rowInserted().
rowInserted in interface ResultSetSQLException
public boolean rowUpdated()
throws SQLException
ResultSet.rowUpdated().
rowUpdated in interface ResultSetSQLException
public boolean wasNull()
throws SQLException
ResultSet.wasNull().
wasNull in interface ResultSetSQLException
public int getFetchDirection()
throws SQLException
ResultSet.getFetchDirection().
getFetchDirection in interface ResultSetSQLException
public void setFetchDirection(int pDirection)
throws SQLException
ResultSet.setFetchDirection(int).
setFetchDirection in interface ResultSetSQLException
public int getFetchSize()
throws SQLException
ResultSet.getFetchSize().
getFetchSize in interface ResultSetSQLException
public void setFetchSize(int pRows)
throws SQLException
ResultSet.setFetchSize(int).
setFetchSize in interface ResultSetSQLException
public int getConcurrency()
throws SQLException
ResultSet.getConcurrency().
getConcurrency in interface ResultSetSQLException
public int getType()
throws SQLException
ResultSet.getType().
getType in interface ResultSetSQLException
public void cancelRowUpdates()
throws SQLException
ResultSet.cancelRowUpdates().
cancelRowUpdates in interface ResultSetSQLException
public void clearWarnings()
throws SQLException
ResultSet.clearWarnings().
clearWarnings in interface ResultSetSQLException
public void close()
throws SQLException
ResultSet.close().
close in interface ResultSetSQLException
public void deleteRow()
throws SQLException
ResultSet.deleteRow().
deleteRow in interface ResultSetSQLException
public void insertRow()
throws SQLException
ResultSet.insertRow().
insertRow in interface ResultSetSQLException
public void moveToCurrentRow()
throws SQLException
ResultSet.moveToCurrentRow().
moveToCurrentRow in interface ResultSetSQLException
public void moveToInsertRow()
throws SQLException
ResultSet.moveToInsertRow().
moveToInsertRow in interface ResultSetSQLException
public void refreshRow()
throws SQLException
ResultSet.refreshRow().
refreshRow in interface ResultSetSQLException
public void updateArray(String pColumnName,
Array pArray)
throws SQLException
ResultSet.updateArray(int, java.sql.Array).
updateArray in interface ResultSetSQLException
public void updateArray(int pColumnIndex,
Array pArray)
throws SQLException
ResultSet.updateArray(int, java.sql.Array).
updateArray in interface ResultSetSQLException
public void updateAsciiStream(String pColumnName,
InputStream pInputStream,
int pLength)
throws SQLException
ResultSet.updateAsciiStream(int, java.io.InputStream, int).
updateAsciiStream in interface ResultSetSQLException
public void updateAsciiStream(int pColumnIndex,
InputStream pInputStream,
int pLength)
throws SQLException
ResultSet.updateAsciiStream(int, java.io.InputStream, int).
updateAsciiStream in interface ResultSetSQLException
public void updateBigDecimal(String pColumnName,
BigDecimal pBigDecimal)
throws SQLException
ResultSet.updateBigDecimal(int, java.math.BigDecimal).
updateBigDecimal in interface ResultSetSQLException
public void updateBigDecimal(int pColumnIndex,
BigDecimal pBigDecimal)
throws SQLException
ResultSet.updateBigDecimal(int, java.math.BigDecimal).
updateBigDecimal in interface ResultSetSQLException
public void updateBinaryStream(String pColumnName,
InputStream pInputStream,
int pLength)
throws SQLException
ResultSet.updateBinaryStream(int, java.io.InputStream, int).
updateBinaryStream in interface ResultSetSQLException
public void updateBinaryStream(int pColumnIndex,
InputStream pInputStream,
int pLength)
throws SQLException
ResultSet.updateBinaryStream(int, java.io.InputStream, int).
updateBinaryStream in interface ResultSetSQLException
public void updateBlob(String pColumnName,
Blob pBlob)
throws SQLException
ResultSet.updateBlob(int, java.sql.Blob).
updateBlob in interface ResultSetSQLException
public void updateBlob(int pColumnIndex,
Blob pBlob)
throws SQLException
ResultSet.updateBlob(int, java.sql.Blob).
updateBlob in interface ResultSetSQLException
public void updateBoolean(String pColumnName,
boolean pValue)
throws SQLException
ResultSet.updateBoolean(int, boolean).
updateBoolean in interface ResultSetSQLException
public void updateBoolean(int pColumnIndex,
boolean pValue)
throws SQLException
ResultSet.updateBoolean(int, boolean).
updateBoolean in interface ResultSetSQLException
public void updateByte(String pColumnName,
byte pValue)
throws SQLException
ResultSet.updateByte(int, byte).
updateByte in interface ResultSetSQLException
public void updateByte(int pColumnIndex,
byte pValue)
throws SQLException
ResultSet.updateByte(int, byte).
updateByte in interface ResultSetSQLException
public void updateBytes(String pColumnName,
byte[] pBytes)
throws SQLException
ResultSet.updateBytes(int, byte[]).
updateBytes in interface ResultSetSQLException
public void updateBytes(int pColumnIndex,
byte[] pBytes)
throws SQLException
ResultSet.updateBytes(int, byte[]).
updateBytes in interface ResultSetSQLException
public void updateCharacterStream(String pColumnName,
Reader pReader,
int pLength)
throws SQLException
ResultSet.updateCharacterStream(int, java.io.Reader, int).
updateCharacterStream in interface ResultSetSQLException
public void updateCharacterStream(int pColumnIndex,
Reader pReader,
int pLength)
throws SQLException
ResultSet.updateCharacterStream(int, java.io.Reader, int).
updateCharacterStream in interface ResultSetSQLException
public void updateClob(String pColumnName,
Clob pValue)
throws SQLException
ResultSet.updateClob(int, java.sql.Clob).
updateClob in interface ResultSetSQLException
public void updateClob(int pColumnIndex,
Clob pValue)
throws SQLException
ResultSet.updateClob(int, java.sql.Clob).
updateClob in interface ResultSetSQLException
public void updateDate(String pColumnName,
Date pValue)
throws SQLException
ResultSet.updateDate(int, java.sql.Date).
updateDate in interface ResultSetSQLException
public void updateDate(int pColumnIndex,
Date pValue)
throws SQLException
ResultSet.updateDate(int, java.sql.Date).
updateDate in interface ResultSetSQLException
public void updateDouble(String pColumnName,
double pValue)
throws SQLException
ResultSet.updateDouble(int, double).
updateDouble in interface ResultSetSQLException
public void updateDouble(int pColumnIndex,
double pValue)
throws SQLException
ResultSet.updateDouble(int, double).
updateDouble in interface ResultSetSQLException
public void updateFloat(String pColumnName,
float pValue)
throws SQLException
ResultSet.updateFloat(int, float).
updateFloat in interface ResultSetSQLException
public void updateFloat(int pColumnIndex,
float pValue)
throws SQLException
ResultSet.updateFloat(int, float).
updateFloat in interface ResultSetSQLException
public void updateInt(String pColumnName,
int pValue)
throws SQLException
ResultSet.updateInt(int, int).
updateInt in interface ResultSetSQLException
public void updateInt(int pColumnIndex,
int pValue)
throws SQLException
ResultSet.updateInt(int, int).
updateInt in interface ResultSetSQLException
public void updateLong(String pColumnName,
long pValue)
throws SQLException
ResultSet.updateLong(int, long).
updateLong in interface ResultSetSQLException
public void updateLong(int pColumnIndex,
long pValue)
throws SQLException
ResultSet.updateLong(int, long).
updateLong in interface ResultSetSQLException
public void updateNull(String pColumnName)
throws SQLException
ResultSet.updateNull(int).
updateNull in interface ResultSetSQLException
public void updateNull(int pColumnIndex)
throws SQLException
ResultSet.updateNull(int).
updateNull in interface ResultSetSQLException
public void updateObject(String pColumnName,
Object pValue)
throws SQLException
ResultSet.updateObject(int, java.lang.Object).
updateObject in interface ResultSetSQLException
public void updateObject(String pColumnName,
Object pValue,
int pScale)
throws SQLException
ResultSet.updateObject(int, java.lang.Object).
updateObject in interface ResultSetSQLException
public void updateObject(int pColumnIndex,
Object pValue)
throws SQLException
ResultSet.updateObject(int, java.lang.Object).
updateObject in interface ResultSetSQLException
public void updateObject(int pColumnIndex,
Object pValue,
int pScale)
throws SQLException
ResultSet.updateObject(int, java.lang.Object).
updateObject in interface ResultSetSQLException
public void updateRef(String pColumnName,
Ref pValue)
throws SQLException
ResultSet.updateRef(int, java.sql.Ref).
updateRef in interface ResultSetSQLException
public void updateRef(int pColumnIndex,
Ref pValue)
throws SQLException
ResultSet.updateRef(int, java.sql.Ref).
updateRef in interface ResultSetSQLException
public void updateRow()
throws SQLException
ResultSet.updateRow().
updateRow in interface ResultSetSQLException
public void updateShort(String pColumnName,
short pValue)
throws SQLException
ResultSet.updateShort(int, short).
updateShort in interface ResultSetSQLException
public void updateShort(int pColumnIndex,
short pValue)
throws SQLException
ResultSet.updateShort(int, short).
updateShort in interface ResultSetSQLException
public void updateString(String pColumnName,
String pValue)
throws SQLException
ResultSet.updateString(int, java.lang.String).
updateString in interface ResultSetSQLException
public void updateString(int pColumnIndex,
String pValue)
throws SQLException
ResultSet.updateString(int, java.lang.String).
updateString in interface ResultSetSQLException
public void updateTime(String pColumnName,
Time pValue)
throws SQLException
ResultSet.updateTime(int, java.sql.Time).
updateTime in interface ResultSetSQLException
public void updateTime(int pColumnIndex,
Time pValue)
throws SQLException
ResultSet.updateTime(int, java.sql.Time).
updateTime in interface ResultSetSQLException
public void updateTimestamp(String pColumnName,
Timestamp pValue)
throws SQLException
ResultSet.updateTimestamp(int, java.sql.Timestamp).
updateTimestamp in interface ResultSetSQLException
public void updateTimestamp(int pColumnIndex,
Timestamp pValue)
throws SQLException
ResultSet.updateTimestamp(int, java.sql.Timestamp).
updateTimestamp in interface ResultSetSQLException
public void setData(ArrayList pData,
boolean pHasHeaders,
int pExpectedNumFields)
ResultSet.
pData - List of String[] arrays containing datapHasHeaders - first line of data is headers
public ResultSetMetaData getMetaData()
throws SQLException
ResultSet.getMetaData().
getMetaData in interface ResultSetSQLException
public int findColumn(String pColumnName)
throws SQLException
ResultSet.findColumn(java.lang.String).
findColumn in interface ResultSetSQLException
public boolean absolute(int pRow)
throws SQLException
ResultSet.absolute(int).
absolute in interface ResultSetSQLException
public boolean first()
throws SQLException
ResultSet.first().
first in interface ResultSetSQLException
public boolean last()
throws SQLException
ResultSet.last().
last in interface ResultSetSQLException
public boolean isAfterLast()
throws SQLException
ResultSet.isAfterLast().
isAfterLast in interface ResultSetSQLException
public boolean isBeforeFirst()
throws SQLException
ResultSet.isBeforeFirst().
isBeforeFirst in interface ResultSetSQLException
public boolean isFirst()
throws SQLException
ResultSet.isFirst().
isFirst in interface ResultSetSQLException
public boolean isLast()
throws SQLException
ResultSet.isLast().
isLast in interface ResultSetSQLException
public boolean next()
throws SQLException
ResultSet.next().
next in interface ResultSetSQLException
public boolean previous()
throws SQLException
ResultSet.previous().
previous in interface ResultSetSQLException
public boolean relative(int pRows)
throws SQLException
ResultSet.relative(int).
relative in interface ResultSetSQLException
public int getRow()
throws SQLException
ResultSet.getRow().
getRow in interface ResultSetSQLException
public void afterLast()
throws SQLException
ResultSet.afterLast().
afterLast in interface ResultSetSQLException
public void beforeFirst()
throws SQLException
ResultSet.beforeFirst().
beforeFirst in interface ResultSetSQLException
public BigDecimal getBigDecimal(String pColumnName)
throws SQLException
ResultSet.getBigDecimal(int).
getBigDecimal in interface ResultSetSQLException
public BigDecimal getBigDecimal(String pColumnName,
int pScale)
throws SQLException
ResultSet.getBigDecimal(int).
getBigDecimal in interface ResultSetSQLException
public BigDecimal getBigDecimal(int pColumnIndex)
throws SQLException
ResultSet.getBigDecimal(int).
getBigDecimal in interface ResultSetSQLException
public BigDecimal getBigDecimal(int pColumnIndex,
int pScale)
throws SQLException
ResultSet.getBigDecimal(int).
getBigDecimal in interface ResultSetSQLException
public Object getObject(String pColumnName)
throws SQLException
ResultSet.getObject(int).
getObject in interface ResultSetSQLException
public Object getObject(int pColumnIndex)
throws SQLException
ResultSet.getObject(int).
getObject in interface ResultSetSQLException
public String getString(String pColumnName)
throws SQLException
ResultSet.getString(int).
getString in interface ResultSetSQLException
public String getString(int pColumnIndex)
throws SQLException
ResultSet.getString(int).
getString in interface ResultSetSQLException
public boolean getBoolean(String pColumnName)
throws SQLException
ResultSet.getBoolean(int).
getBoolean in interface ResultSetSQLException
public boolean getBoolean(int pColumnIndex)
throws SQLException
ResultSet.getBoolean(int).
getBoolean in interface ResultSetSQLException
public byte getByte(String pColumnName)
throws SQLException
ResultSet.getByte(int).
getByte in interface ResultSetSQLException
public byte getByte(int pColumnIndex)
throws SQLException
ResultSet.getByte(int).
getByte in interface ResultSetSQLException
public byte[] getBytes(String pColumnName)
throws SQLException
ResultSet.getBytes(int).
getBytes in interface ResultSetSQLException
public byte[] getBytes(int pColumnIndex)
throws SQLException
ResultSet.getBytes(int).
getBytes in interface ResultSetSQLException
public double getDouble(String pColumnName)
throws SQLException
ResultSet.getDouble(int).
getDouble in interface ResultSetSQLException
public double getDouble(int pColumnIndex)
throws SQLException
ResultSet.getDouble(int).
getDouble in interface ResultSetSQLException
public float getFloat(String pColumnName)
throws SQLException
ResultSet.getFloat(int).
getFloat in interface ResultSetSQLException
public float getFloat(int pColumnIndex)
throws SQLException
ResultSet.getFloat(int).
getFloat in interface ResultSetSQLException
public int getInt(String pColumnName)
throws SQLException
ResultSet.getInt(int).
getInt in interface ResultSetSQLException
public int getInt(int pColumnIndex)
throws SQLException
ResultSet.getInt(int).
getInt in interface ResultSetSQLException
public InputStream getAsciiStream(String pColumnName)
throws SQLException
ResultSet.getAsciiStream(int).
getAsciiStream in interface ResultSetSQLException
public InputStream getAsciiStream(int pColumnIndex)
throws SQLException
ResultSet.getAsciiStream(int).
getAsciiStream in interface ResultSetSQLException
public InputStream getBinaryStream(String pColumnName)
throws SQLException
ResultSet.getBinaryStream(int).
getBinaryStream in interface ResultSetSQLException
public InputStream getBinaryStream(int pColumnIndex)
throws SQLException
ResultSet.getBinaryStream(int).
getBinaryStream in interface ResultSetSQLException
public InputStream getUnicodeStream(String pColumnName)
throws SQLException
ResultSet.getUnicodeStream(int).
getUnicodeStream in interface ResultSetSQLException
public InputStream getUnicodeStream(int pColumnIndex)
throws SQLException
ResultSet.getUnicodeStream(int).
getUnicodeStream in interface ResultSetSQLException
public Reader getCharacterStream(String pColumnName)
throws SQLException
ResultSet.getCharacterStream(int).
getCharacterStream in interface ResultSetSQLException
public Reader getCharacterStream(int pColumnIndex)
throws SQLException
ResultSet.getCharacterStream(int).
getCharacterStream in interface ResultSetSQLException
public URL getURL(String pColumnName)
throws SQLException
ResultSet.getURL(int).
getURL in interface ResultSetSQLException
public URL getURL(int pColumnIndex)
throws SQLException
ResultSet.getURL(int).
getURL in interface ResultSetSQLException
public Date getDate(String pColumnName)
throws SQLException
ResultSet.getDate(int).
getDate in interface ResultSetSQLException
public Date getDate(String pColumnName,
Calendar pCalendar)
throws SQLException
ResultSet.getDate(int).
getDate in interface ResultSetSQLException
public Date getDate(int pColumnIndex)
throws SQLException
ResultSet.getDate(int).
getDate in interface ResultSetSQLException
public Date getDate(int pColumnIndex,
Calendar pCalendar)
throws SQLException
ResultSet.getDate(int). Ignores pCalendar.
getDate in interface ResultSetSQLException
public Time getTime(String pColumnName)
throws SQLException
ResultSet.getTime(int).
getTime in interface ResultSetSQLException
public Time getTime(String pColumnName,
Calendar pCalendar)
throws SQLException
ResultSet.getTime(int).
getTime in interface ResultSetSQLException
public Time getTime(int pColumnIndex)
throws SQLException
ResultSet.getTime(int).
getTime in interface ResultSetSQLException
public Time getTime(int pColumnIndex,
Calendar pCalendar)
throws SQLException
ResultSet.getTime(int). Ignores Calendar.
getTime in interface ResultSetSQLException
public Timestamp getTimestamp(String pColumnName)
throws SQLException
ResultSet.getTimestamp(int).
getTimestamp in interface ResultSetSQLException
public Timestamp getTimestamp(String pColumnName,
Calendar pCalendar)
throws SQLException
ResultSet.getTimestamp(int).
getTimestamp in interface ResultSetSQLException
public Timestamp getTimestamp(int pColumnIndex)
throws SQLException
ResultSet.getTimestamp(int).
getTimestamp in interface ResultSetSQLException
public Timestamp getTimestamp(int pColumnIndex,
Calendar pCalendar)
throws SQLException
ResultSet.getTimestamp(int). Ignores Calendar.
getTimestamp in interface ResultSetSQLException
public long getLong(String pColumnName)
throws SQLException
ResultSet.getLong(int).
getLong in interface ResultSetSQLException
public long getLong(int pColumnIndex)
throws SQLException
ResultSet.getLong(int).
getLong in interface ResultSetSQLException
public short getShort(String pColumnName)
throws SQLException
ResultSet.getShort(int).
getShort in interface ResultSetSQLException
public short getShort(int pColumnIndex)
throws SQLException
ResultSet.getShort(int).
getShort in interface ResultSetSQLExceptionpublic void setDateFormat(DateFormat pDateFormat)
pDateFormat - custom data formatprotected boolean moveToLine()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||