org.axiondb.engine.tables
Class BaseFlatfileTable

java.lang.Object
  extended by org.axiondb.event.BaseTableModificationPublisher
      extended by org.axiondb.engine.tables.AbstractBaseTable
          extended by org.axiondb.engine.tables.BaseTable
              extended by org.axiondb.engine.tables.BaseDiskTable
                  extended by org.axiondb.engine.tables.BaseFlatfileTable
All Implemented Interfaces:
ExternalTable, RowSource, Table
Direct Known Subclasses:
DelimitedFlatfileTable, FixedWidthFlatfileTable, TaggedEBCDICTable

public abstract class BaseFlatfileTable
extends BaseDiskTable
implements ExternalTable

Base Flatfile Table
TODO: Support for decimal and thousand separator, trailing/leading minus sign TODO: Support for multiple record delimiter


Nested Class Summary
protected  class BaseFlatfileTable.BaseFlatfileTableOrganizationContext
           
 
Field Summary
protected  String _fileName
           
protected  boolean _isFirstLineHeader
           
protected  String _lineSep
           
protected  long _maxFaults
           
protected  int _rowsToSkip
           
protected  TableOrganizationContext context
           
protected static int EOF
           
protected static char FILLER
           
static String PROP_FILENAME
           
protected static String PROP_ISFIRSTLINEHEADER
           
protected static String PROP_MAXFAULTS
           
protected static String PROP_RECORDDELIMITER
           
protected static String PROP_ROWSTOSKIP
           
 
Fields inherited from class org.axiondb.engine.tables.BaseDiskTable
_dataFile, _dbdir, _freeIds, _readOnly, _rowCount, CURRENT_META_VERSION, FRID_FILE_EXT, FS, INDICES_DIR_NAME, INVALID_OFFSET, META_FILE_EXT, PIDX_FILE_EXT, SEQ_FILE_EXT, TYPE_FILE_EXT
 
Fields inherited from interface org.axiondb.ExternalTable
COLUMNS_ARE_CASE_SENSITIVE, DELIMITED_TABLE_TYPE, EXTERNAL_DB_TABLE_TYPE, FW_TABLE_TYPE, PROP_CATALOG, PROP_CREATE_IF_NOT_EXIST, PROP_DB, PROP_LOADTYPE, PROP_ORDERBY, PROP_REMOTETABLE, PROP_SCHEMA, PROP_VENDOR, PROP_WHERE, TAGGED_EBCDIC_TABLE_TYPE
 
Fields inherited from interface org.axiondb.Table
REGULAR_TABLE_TYPE, SYSTEM_TABLE_TYPE
 
Constructor Summary
BaseFlatfileTable(String name, Database db, TableFactory factory)
           
 
Method Summary
 void addColumn(Column col, boolean metaUpdateNeeded)
           
static String addEscapeSequence(String srcString)
           
protected  void createOrLoadDataFile()
           
protected  void createOrLoadDataFile(boolean createNewDataFile)
           
protected  String evaluateForNull(String colValue, DataType datatype)
           
static String fixEscapeSequence(String srcString)
           
protected  File getDataFile()
           
protected  String getDefaultDataFileExtension()
           
protected  File getLobDir()
           
protected  long ignoreRowsToSkip()
           
protected  void initializeTable()
           
protected abstract  boolean isEndOfRecord(int recLength, int nextChar, BufferedDataInputStream data)
           
protected  boolean isEOF(int nextChar)
           
protected  boolean isNullString(String str)
           
 boolean loadExternalTable(Properties props)
          Loads external data using the given properties table - should be called only once by the table factory.
protected  int nextLineLength(long fileOffset)
           
protected  void reloadFilesAfterTruncate()
           
 void remount()
           
protected  void renameTableFiles(String oldName, String name)
           
protected  Row trySettingColumn(int idToAssign, Row row, int i, String colValue)
           
protected abstract  void writeHeader(BufferedDataOutputStream data2)
           
 
Methods inherited from class org.axiondb.engine.tables.BaseDiskTable
addColumn, addConstraint, applyDeletes, applyInserts, applyUpdates, checkpoint, clearDataFileReference, closeFiles, createOrLoadFreeIdsFile, drop, freeRowId, getInputStream, getNextRowId, getOutputStream, getPidxList, getRootDir, getRow, getRowByOffset, getRowCount, getRowIterator, getTableFile, initFiles, initializeRowCount, isReadOnly, loadOrMigrateMetaFile, migrate, parsePidxFile, parseTableProperties, populateIndex, remount, removeIndex, rename, resetLobColumns, saveIndicesAfterTruncate, setSequence, shutdown, truncate, tryToRemove, writeFridFile, writeMetaFile, writeNameToFile, writeRow, writeTableProperties
 
Methods inherited from class org.axiondb.engine.tables.BaseTable
addIndex, addRow, applyDeletesToIndices, applyInsertsToIndices, applyUpdatesToIndices, clearCache, deleteRow, getColumn, getColumn, getColumnCount, getColumnIdentifiers, getColumnIndex, getConstraint, getConstraints, getIndexedRows, getIndexedRows, getIndexForColumn, getIndices, getName, getRowIterator, getSequence, getType, hasColumn, hasIndex, isColumnIndexed, isPrimaryKeyConstraintExists, isUniqueConstraintExists, makeRowDecorator, makeTransactableTable, notifyColumnsOfNewLobDir, readColumns, readConstraints, recreateIndices, removeConstraint, setName, setType, toString, truncateIndices, updateRow, writeColumns, writeConstraints
 
Methods inherited from class org.axiondb.engine.tables.AbstractBaseTable
checkConstraints, checkConstraints, checkConstraints, getMatchingRows, hasDeferredConstraint, isDeferAll, migrate
 
Methods inherited from class org.axiondb.event.BaseTableModificationPublisher
addTableModificationListener, getTableModificationListeners, publishEvent, removeTableModificationListener, setDeferAllConstraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axiondb.ExternalTable
getTableProperties
 
Methods inherited from interface org.axiondb.Table
addColumn, addConstraint, addIndex, addRow, addTableModificationListener, applyDeletes, applyInserts, applyUpdates, checkpoint, deleteRow, drop, freeRowId, getColumn, getColumn, getColumnCount, getColumnIdentifiers, getColumnIndex, getConstraint, getConstraints, getIndexedRows, getIndexedRows, getIndexForColumn, getIndices, getMatchingRows, getName, getNextRowId, getRowCount, getRowIterator, getSequence, getTableModificationListeners, getType, hasColumn, hasIndex, isColumnIndexed, isPrimaryKeyConstraintExists, isUniqueConstraintExists, makeRowDecorator, makeTransactableTable, migrate, populateIndex, remount, removeConstraint, removeIndex, removeTableModificationListener, rename, setDeferAllConstraints, setSequence, shutdown, truncate, updateRow
 
Methods inherited from interface org.axiondb.RowSource
getRow
 

Field Detail

EOF

protected static final int EOF
See Also:
Constant Field Values

FILLER

protected static final char FILLER
See Also:
Constant Field Values

PROP_FILENAME

public static final String PROP_FILENAME
See Also:
Constant Field Values

PROP_ISFIRSTLINEHEADER

protected static final String PROP_ISFIRSTLINEHEADER
See Also:
Constant Field Values

PROP_RECORDDELIMITER

protected static final String PROP_RECORDDELIMITER
See Also:
Constant Field Values

PROP_ROWSTOSKIP

protected static final String PROP_ROWSTOSKIP
See Also:
Constant Field Values

PROP_MAXFAULTS

protected static final String PROP_MAXFAULTS
See Also:
Constant Field Values

context

protected TableOrganizationContext context

_fileName

protected String _fileName

_isFirstLineHeader

protected boolean _isFirstLineHeader

_rowsToSkip

protected int _rowsToSkip

_maxFaults

protected long _maxFaults

_lineSep

protected String _lineSep
Constructor Detail

BaseFlatfileTable

public BaseFlatfileTable(String name,
                         Database db,
                         TableFactory factory)
                  throws AxionException
Throws:
AxionException
Method Detail

addColumn

public void addColumn(Column col,
                      boolean metaUpdateNeeded)
               throws AxionException
Overrides:
addColumn in class BaseDiskTable
Throws:
AxionException

loadExternalTable

public boolean loadExternalTable(Properties props)
                          throws AxionException
Loads external data using the given properties table - should be called only once by the table factory.

Specified by:
loadExternalTable in interface ExternalTable
Parameters:
table - Table to be set
props - Properties for Table
Throws:
AxionException - thrown while setting Properties

remount

public void remount()
             throws AxionException
Specified by:
remount in interface ExternalTable
Throws:
AxionException

addEscapeSequence

public static String addEscapeSequence(String srcString)

createOrLoadDataFile

protected void createOrLoadDataFile()
                             throws AxionException
Overrides:
createOrLoadDataFile in class BaseDiskTable
Throws:
AxionException

createOrLoadDataFile

protected void createOrLoadDataFile(boolean createNewDataFile)
                             throws AxionException
Throws:
AxionException

fixEscapeSequence

public static String fixEscapeSequence(String srcString)

getDataFile

protected File getDataFile()
Specified by:
getDataFile in class BaseDiskTable

renameTableFiles

protected void renameTableFiles(String oldName,
                                String name)
Overrides:
renameTableFiles in class BaseDiskTable

getLobDir

protected File getLobDir()
Specified by:
getLobDir in class BaseDiskTable

ignoreRowsToSkip

protected long ignoreRowsToSkip()
                         throws AxionException
Throws:
AxionException

initializeTable

protected void initializeTable()
                        throws AxionException
Throws:
AxionException

isEndOfRecord

protected abstract boolean isEndOfRecord(int recLength,
                                         int nextChar,
                                         BufferedDataInputStream data)
                                  throws IOException
Throws:
IOException

isEOF

protected boolean isEOF(int nextChar)

isNullString

protected boolean isNullString(String str)

getDefaultDataFileExtension

protected String getDefaultDataFileExtension()
Overrides:
getDefaultDataFileExtension in class BaseDiskTable

reloadFilesAfterTruncate

protected void reloadFilesAfterTruncate()
                                 throws AxionException
Specified by:
reloadFilesAfterTruncate in class BaseDiskTable
Throws:
AxionException

trySettingColumn

protected Row trySettingColumn(int idToAssign,
                               Row row,
                               int i,
                               String colValue)
                        throws AxionException
Throws:
AxionException

evaluateForNull

protected String evaluateForNull(String colValue,
                                 DataType datatype)

writeHeader

protected abstract void writeHeader(BufferedDataOutputStream data2)
                             throws AxionException
Throws:
AxionException

nextLineLength

protected int nextLineLength(long fileOffset)
                      throws AxionException
Throws:
AxionException