Class FlatFileVTI

java.lang.Object
org.apache.derby.vti.VTITemplate
org.apache.derby.vti.StringColumnVTI
org.apache.derbyDemo.vtis.core.FlatFileVTI
All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper, org.apache.derby.vti.AwareVTI
Direct Known Subclasses:
LineListVTI, PropertyFileVTI, SubversionLogVTI

public abstract class FlatFileVTI extends org.apache.derby.vti.StringColumnVTI

This VTI makes a table out of the records in a flat file. This is an abstract class. Child classes are responsible for implementing the following methods which parse and advance the file:

  • parseRow() - Parses the next record of the file into an array of Strings, one for each column.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.derby.vti.VTITemplate

    org.apache.derby.vti.VTITemplate.ColumnDescriptor
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    private File
     
    private FileReader
     
    private int
     
     
    private String[]
     
    private String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FlatFileVTI(String[] columnNames, String textFileName)
    Build a StringColumnVTI with the given column names
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected int
    Get the current line number.
     
    protected String
    getRawColumn(int columnNumber)
    Get the string value of the column in the current row identified by the 1-based columnNumber.
    protected String
    Get the name of the file being read.
    boolean
     
    protected abstract String[]
    Parse the next chunk of text, using readLine(), and return the next row.
    protected String
    Read the next line from the file and return it.
    protected SQLException
    wrap(String message, Throwable t)
    Wrap an exception in a SQLException.
    protected SQLException
    Wrap an exception in a SQLException.

    Methods inherited from class org.apache.derby.vti.StringColumnVTI

    findColumn, getAsciiStream, getBigDecimal, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getClob, getColumnCount, getColumnName, getDate, getDouble, getFloat, getInt, getLong, getShort, getString, getTime, getTimestamp, setColumnNames, wasNull

    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, 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.sql.ResultSet

    updateObject, updateObject, updateObject, updateObject
  • Field Details

    • _textFileName

      private String _textFileName
    • _file

      private File _file
    • _fileReader

      private FileReader _fileReader
    • _lineReader

      private LineNumberReader _lineReader
    • _closed

      private boolean _closed
    • _row

      private String[] _row
    • _lineNumber

      private int _lineNumber
  • Constructor Details

    • FlatFileVTI

      public FlatFileVTI(String[] columnNames, String textFileName)

      Build a StringColumnVTI with the given column names

  • Method Details

    • parseRow

      protected abstract String[] parseRow() throws SQLException

      Parse the next chunk of text, using readLine(), and return the next row. Returns null if the file is exhausted.

      Throws:
      SQLException
    • getRawColumn

      protected String getRawColumn(int columnNumber) throws SQLException

      Get the string value of the column in the current row identified by the 1-based columnNumber.

      Specified by:
      getRawColumn in class org.apache.derby.vti.StringColumnVTI
      Throws:
      SQLException
    • next

      public boolean next() throws SQLException
      Throws:
      SQLException
    • close

      public void close() throws SQLException
      Throws:
      SQLException
    • getMetaData

      public ResultSetMetaData getMetaData() throws SQLException
      Specified by:
      getMetaData in interface ResultSet
      Overrides:
      getMetaData in class org.apache.derby.vti.VTITemplate
      Throws:
      SQLException
    • getLineNumber

      protected int getLineNumber()

      Get the current line number.

    • getTextFileName

      protected String getTextFileName()

      Get the name of the file being read.

    • readLine

      protected String readLine() throws SQLException

      Read the next line from the file and return it. Return null if the file is exhausted.

      Throws:
      SQLException
    • wrap

      protected SQLException wrap(Throwable t)

      Wrap an exception in a SQLException.

    • wrap

      protected SQLException wrap(String message, Throwable t)

      Wrap an exception in a SQLException.