Class StringColumnVTI
- java.lang.Object
-
- org.apache.derby.vti.VTITemplate
-
- org.apache.derby.vti.StringColumnVTI
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.sql.ResultSet
,java.sql.Wrapper
,AwareVTI
- Direct Known Subclasses:
XmlVTI
public abstract class StringColumnVTI extends VTITemplate
This is an abstract table function which assumes that all columns are strings and which coerces the strings to reasonable values for various getXXX() methods. Subclasses must implement the following ResultSet methods:
- next( )
- close()
and the following protected method introduced by this class:
- getRawColumn( int columnNumber )
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.vti.VTITemplate
VTITemplate.ColumnDescriptor
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]
_columnNames
private boolean
_lastColumnWasNull
-
Constructor Summary
Constructors Constructor Description StringColumnVTI(java.lang.String[] columnNames)
Build a StringColumnVTI with the given column names
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
checkNull(java.lang.String columnValue)
Set the wasNull flag based on whether this column value turned out to be null.int
findColumn(java.lang.String columnName)
java.io.InputStream
getAsciiStream(int columnIndex)
java.math.BigDecimal
getBigDecimal(int columnIndex)
java.io.InputStream
getBinaryStream(int columnIndex)
java.sql.Blob
getBlob(int columnIndex)
boolean
getBoolean(int columnIndex)
byte
getByte(int columnIndex)
byte[]
getBytes(int columnIndex)
java.sql.Clob
getClob(int columnIndex)
int
getColumnCount()
Get the number of columns.java.lang.String
getColumnName(int columnNumber)
Get name of a column (1-based indexing).java.sql.Date
getDate(int columnIndex)
double
getDouble(int columnIndex)
private java.io.InputStream
getEncodedStream(java.lang.String columnValue, java.lang.String encoding)
Turn a string into an appropriately encoded ByteArrayInputStream.float
getFloat(int columnIndex)
int
getInt(int columnIndex)
long
getLong(int columnIndex)
protected abstract java.lang.String
getRawColumn(int columnNumber)
Get the string value of the column in the current row identified by the 1-based columnNumber.short
getShort(int columnIndex)
java.lang.String
getString(int columnIndex)
java.sql.Time
getTime(int columnIndex)
java.sql.Timestamp
getTimestamp(int columnIndex)
private java.sql.SQLException
makeSQLException(java.lang.String sqlstate, java.lang.Object... args)
Construct a SQLException from a SQLState and args.private long
parseDateTime(java.lang.String columnValue)
Translate a date/time expression into the corresponding long number of milliseconds.void
setColumnNames(java.lang.String[] columnNames)
Set the column names for this table function.boolean
wasNull()
private java.sql.SQLException
wrap(java.lang.Throwable t)
Wrap an exception in a SQLException.-
Methods inherited from class org.apache.derby.vti.VTITemplate
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, first, getArray, getArray, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getCharacterStream, getCharacterStream, getClob, getConcurrency, getContext, getCursorName, getDate, getDate, getDate, getDouble, getFetchDirection, getFetchSize, getFloat, getHoldability, getInt, getLong, getMetaData, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getReturnTableSignature, getRow, getRowId, getRowId, getShort, getSQLXML, getSQLXML, getStatement, getString, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, notImplemented, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setContext, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp
-
-
-
-
Method Detail
-
getRawColumn
protected abstract java.lang.String getRawColumn(int columnNumber) throws java.sql.SQLException
Get the string value of the column in the current row identified by the 1-based columnNumber.
- Throws:
java.sql.SQLException
-
setColumnNames
public void setColumnNames(java.lang.String[] columnNames) throws java.sql.SQLException
Set the column names for this table function. This is useful for AwareVTIs, which need to figure out their column names after analyzing their execution context. Throws an exception if the column names have already been set.
- Throws:
java.sql.SQLException
-
getColumnCount
public int getColumnCount()
Get the number of columns.
-
getColumnName
public java.lang.String getColumnName(int columnNumber)
Get name of a column (1-based indexing).
-
wasNull
public boolean wasNull() throws java.sql.SQLException
- Specified by:
wasNull
in interfacejava.sql.ResultSet
- Overrides:
wasNull
in classVTITemplate
- Throws:
java.sql.SQLException
-
findColumn
public int findColumn(java.lang.String columnName) throws java.sql.SQLException
- Specified by:
findColumn
in interfacejava.sql.ResultSet
- Overrides:
findColumn
in classVTITemplate
- Throws:
java.sql.SQLException
-
getString
public java.lang.String getString(int columnIndex) throws java.sql.SQLException
- Specified by:
getString
in interfacejava.sql.ResultSet
- Overrides:
getString
in classVTITemplate
- Throws:
java.sql.SQLException
-
getBoolean
public boolean getBoolean(int columnIndex) throws java.sql.SQLException
- Specified by:
getBoolean
in interfacejava.sql.ResultSet
- Overrides:
getBoolean
in classVTITemplate
- Throws:
java.sql.SQLException
-
getByte
public byte getByte(int columnIndex) throws java.sql.SQLException
- Specified by:
getByte
in interfacejava.sql.ResultSet
- Overrides:
getByte
in classVTITemplate
- Throws:
java.sql.SQLException
-
getShort
public short getShort(int columnIndex) throws java.sql.SQLException
- Specified by:
getShort
in interfacejava.sql.ResultSet
- Overrides:
getShort
in classVTITemplate
- Throws:
java.sql.SQLException
-
getInt
public int getInt(int columnIndex) throws java.sql.SQLException
- Specified by:
getInt
in interfacejava.sql.ResultSet
- Overrides:
getInt
in classVTITemplate
- Throws:
java.sql.SQLException
-
getLong
public long getLong(int columnIndex) throws java.sql.SQLException
- Specified by:
getLong
in interfacejava.sql.ResultSet
- Overrides:
getLong
in classVTITemplate
- Throws:
java.sql.SQLException
-
getFloat
public float getFloat(int columnIndex) throws java.sql.SQLException
- Specified by:
getFloat
in interfacejava.sql.ResultSet
- Overrides:
getFloat
in classVTITemplate
- Throws:
java.sql.SQLException
-
getDouble
public double getDouble(int columnIndex) throws java.sql.SQLException
- Specified by:
getDouble
in interfacejava.sql.ResultSet
- Overrides:
getDouble
in classVTITemplate
- Throws:
java.sql.SQLException
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(int columnIndex) throws java.sql.SQLException
- Specified by:
getBigDecimal
in interfacejava.sql.ResultSet
- Overrides:
getBigDecimal
in classVTITemplate
- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes(int columnIndex) throws java.sql.SQLException
- Specified by:
getBytes
in interfacejava.sql.ResultSet
- Overrides:
getBytes
in classVTITemplate
- Throws:
java.sql.SQLException
-
getDate
public java.sql.Date getDate(int columnIndex) throws java.sql.SQLException
- Specified by:
getDate
in interfacejava.sql.ResultSet
- Overrides:
getDate
in classVTITemplate
- Throws:
java.sql.SQLException
-
getTime
public java.sql.Time getTime(int columnIndex) throws java.sql.SQLException
- Specified by:
getTime
in interfacejava.sql.ResultSet
- Overrides:
getTime
in classVTITemplate
- Throws:
java.sql.SQLException
-
getTimestamp
public java.sql.Timestamp getTimestamp(int columnIndex) throws java.sql.SQLException
- Specified by:
getTimestamp
in interfacejava.sql.ResultSet
- Overrides:
getTimestamp
in classVTITemplate
- Throws:
java.sql.SQLException
-
getAsciiStream
public java.io.InputStream getAsciiStream(int columnIndex) throws java.sql.SQLException
- Specified by:
getAsciiStream
in interfacejava.sql.ResultSet
- Overrides:
getAsciiStream
in classVTITemplate
- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream(int columnIndex) throws java.sql.SQLException
- Specified by:
getBinaryStream
in interfacejava.sql.ResultSet
- Overrides:
getBinaryStream
in classVTITemplate
- Throws:
java.sql.SQLException
-
getBlob
public java.sql.Blob getBlob(int columnIndex) throws java.sql.SQLException
- Specified by:
getBlob
in interfacejava.sql.ResultSet
- Overrides:
getBlob
in classVTITemplate
- Throws:
java.sql.SQLException
-
getClob
public java.sql.Clob getClob(int columnIndex) throws java.sql.SQLException
- Specified by:
getClob
in interfacejava.sql.ResultSet
- Overrides:
getClob
in classVTITemplate
- Throws:
java.sql.SQLException
-
checkNull
private void checkNull(java.lang.String columnValue)
Set the wasNull flag based on whether this column value turned out to be null.
-
wrap
private java.sql.SQLException wrap(java.lang.Throwable t)
Wrap an exception in a SQLException.
-
parseDateTime
private long parseDateTime(java.lang.String columnValue) throws java.sql.SQLException
Translate a date/time expression into the corresponding long number of milliseconds.
- Throws:
java.sql.SQLException
-
getEncodedStream
private java.io.InputStream getEncodedStream(java.lang.String columnValue, java.lang.String encoding) throws java.sql.SQLException
Turn a string into an appropriately encoded ByteArrayInputStream.
- Throws:
java.sql.SQLException
-
makeSQLException
private java.sql.SQLException makeSQLException(java.lang.String sqlstate, java.lang.Object... args)
Construct a SQLException from a SQLState and args.
-
-