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[]_columnNamesprivate 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 voidcheckNull(java.lang.String columnValue)Set the wasNull flag based on whether this column value turned out to be null.intfindColumn(java.lang.String columnName)java.io.InputStreamgetAsciiStream(int columnIndex)java.math.BigDecimalgetBigDecimal(int columnIndex)java.io.InputStreamgetBinaryStream(int columnIndex)java.sql.BlobgetBlob(int columnIndex)booleangetBoolean(int columnIndex)bytegetByte(int columnIndex)byte[]getBytes(int columnIndex)java.sql.ClobgetClob(int columnIndex)intgetColumnCount()Get the number of columns.java.lang.StringgetColumnName(int columnNumber)Get name of a column (1-based indexing).java.sql.DategetDate(int columnIndex)doublegetDouble(int columnIndex)private java.io.InputStreamgetEncodedStream(java.lang.String columnValue, java.lang.String encoding)Turn a string into an appropriately encoded ByteArrayInputStream.floatgetFloat(int columnIndex)intgetInt(int columnIndex)longgetLong(int columnIndex)protected abstract java.lang.StringgetRawColumn(int columnNumber)Get the string value of the column in the current row identified by the 1-based columnNumber.shortgetShort(int columnIndex)java.lang.StringgetString(int columnIndex)java.sql.TimegetTime(int columnIndex)java.sql.TimestampgetTimestamp(int columnIndex)private java.sql.SQLExceptionmakeSQLException(java.lang.String sqlstate, java.lang.Object... args)Construct a SQLException from a SQLState and args.private longparseDateTime(java.lang.String columnValue)Translate a date/time expression into the corresponding long number of milliseconds.voidsetColumnNames(java.lang.String[] columnNames)Set the column names for this table function.booleanwasNull()private java.sql.SQLExceptionwrap(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.SQLExceptionGet 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.SQLExceptionSet 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:
wasNullin interfacejava.sql.ResultSet- Overrides:
wasNullin classVTITemplate- Throws:
java.sql.SQLException
-
findColumn
public int findColumn(java.lang.String columnName) throws java.sql.SQLException- Specified by:
findColumnin interfacejava.sql.ResultSet- Overrides:
findColumnin classVTITemplate- Throws:
java.sql.SQLException
-
getString
public java.lang.String getString(int columnIndex) throws java.sql.SQLException- Specified by:
getStringin interfacejava.sql.ResultSet- Overrides:
getStringin classVTITemplate- Throws:
java.sql.SQLException
-
getBoolean
public boolean getBoolean(int columnIndex) throws java.sql.SQLException- Specified by:
getBooleanin interfacejava.sql.ResultSet- Overrides:
getBooleanin classVTITemplate- Throws:
java.sql.SQLException
-
getByte
public byte getByte(int columnIndex) throws java.sql.SQLException- Specified by:
getBytein interfacejava.sql.ResultSet- Overrides:
getBytein classVTITemplate- Throws:
java.sql.SQLException
-
getShort
public short getShort(int columnIndex) throws java.sql.SQLException- Specified by:
getShortin interfacejava.sql.ResultSet- Overrides:
getShortin classVTITemplate- Throws:
java.sql.SQLException
-
getInt
public int getInt(int columnIndex) throws java.sql.SQLException- Specified by:
getIntin interfacejava.sql.ResultSet- Overrides:
getIntin classVTITemplate- Throws:
java.sql.SQLException
-
getLong
public long getLong(int columnIndex) throws java.sql.SQLException- Specified by:
getLongin interfacejava.sql.ResultSet- Overrides:
getLongin classVTITemplate- Throws:
java.sql.SQLException
-
getFloat
public float getFloat(int columnIndex) throws java.sql.SQLException- Specified by:
getFloatin interfacejava.sql.ResultSet- Overrides:
getFloatin classVTITemplate- Throws:
java.sql.SQLException
-
getDouble
public double getDouble(int columnIndex) throws java.sql.SQLException- Specified by:
getDoublein interfacejava.sql.ResultSet- Overrides:
getDoublein classVTITemplate- Throws:
java.sql.SQLException
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(int columnIndex) throws java.sql.SQLException- Specified by:
getBigDecimalin interfacejava.sql.ResultSet- Overrides:
getBigDecimalin classVTITemplate- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes(int columnIndex) throws java.sql.SQLException- Specified by:
getBytesin interfacejava.sql.ResultSet- Overrides:
getBytesin classVTITemplate- Throws:
java.sql.SQLException
-
getDate
public java.sql.Date getDate(int columnIndex) throws java.sql.SQLException- Specified by:
getDatein interfacejava.sql.ResultSet- Overrides:
getDatein classVTITemplate- Throws:
java.sql.SQLException
-
getTime
public java.sql.Time getTime(int columnIndex) throws java.sql.SQLException- Specified by:
getTimein interfacejava.sql.ResultSet- Overrides:
getTimein classVTITemplate- Throws:
java.sql.SQLException
-
getTimestamp
public java.sql.Timestamp getTimestamp(int columnIndex) throws java.sql.SQLException- Specified by:
getTimestampin interfacejava.sql.ResultSet- Overrides:
getTimestampin classVTITemplate- Throws:
java.sql.SQLException
-
getAsciiStream
public java.io.InputStream getAsciiStream(int columnIndex) throws java.sql.SQLException- Specified by:
getAsciiStreamin interfacejava.sql.ResultSet- Overrides:
getAsciiStreamin classVTITemplate- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream(int columnIndex) throws java.sql.SQLException- Specified by:
getBinaryStreamin interfacejava.sql.ResultSet- Overrides:
getBinaryStreamin classVTITemplate- Throws:
java.sql.SQLException
-
getBlob
public java.sql.Blob getBlob(int columnIndex) throws java.sql.SQLException- Specified by:
getBlobin interfacejava.sql.ResultSet- Overrides:
getBlobin classVTITemplate- Throws:
java.sql.SQLException
-
getClob
public java.sql.Clob getClob(int columnIndex) throws java.sql.SQLException- Specified by:
getClobin interfacejava.sql.ResultSet- Overrides:
getClobin 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.SQLExceptionTranslate 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.SQLExceptionTurn 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.
-
-