Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.sleuthkit.autopsy.coreutils.SQLiteTableReader Class Reference

Inherits AutoCloseable.

Classes

class  Builder
 

Public Member Functions

void close () throws SQLiteTableReaderException
 
int getColumnCount (String tableName) throws SQLiteTableReaderException
 
int getRowCount (String tableName) throws SQLiteTableReaderException
 
List< String > getTableNames () throws SQLiteTableReaderException
 
boolean isFinished ()
 
void read (String tableName) throws SQLiteTableReaderException
 
void read (String tableName, int limit, int offset) throws SQLiteTableReaderException
 
void read (String tableName, BooleanSupplier condition) throws SQLiteTableReaderException
 

Protected Member Functions

void finalize () throws Throwable
 

Private Member Functions

 SQLiteTableReader (Builder builder)
 
void closeTableResources ()
 
String copyFileToTempDirectory (AbstractFile file, long fileId) throws IOException, NoCurrentCaseException
 
void ensureOpen () throws SQLiteTableReaderException
 
void findAndCopySQLiteMetaFile (AbstractFile sqliteFile, String metaFileName) throws NoCurrentCaseException, TskCoreException, IOException
 
void openTableResources (String query) throws SQLiteTableReaderException
 
void readHelper (String query, BooleanSupplier condition) throws SQLiteTableReaderException
 

Private Attributes

final Builder builder
 
int columnNameIndex
 
Connection conn
 
ResultSetMetaData currentMetadata
 
int currRowColumnIndex
 
final AbstractFile file
 
boolean liveResultSet
 
String prevTableName
 
ResultSet queryResults
 
PreparedStatement statement
 
int totalColumnCount
 
boolean unfinishedRow
 

Static Private Attributes

static final Logger logger = Logger.getLogger(SQLiteTableReader.class.getName())
 
static final String SELECT_ALL_QUERY = "SELECT * FROM \"%s\""
 

Detailed Description

Reads through SQLite tables row by row. Functions performed on the data must be declared up front to the Builder. For example:

tableReader = new SQLiteTableReader.Builder(file).forAllColumnNames(System.out::println); tableReader.read("Sample Table X");

By declaring the functions up front, the SQLiteTableReader instance can stream the table contents in the most memory efficient manner.

Definition at line 54 of file SQLiteTableReader.java.

Constructor & Destructor Documentation

org.sleuthkit.autopsy.coreutils.SQLiteTableReader.SQLiteTableReader ( Builder  builder)
private

Holds reference to the builder instance so that we can use its actions during iteration.

Definition at line 218 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.builder, and org.sleuthkit.autopsy.coreutils.SQLiteTableReader.Builder.file.

Referenced by org.sleuthkit.autopsy.coreutils.SQLiteTableReader.Builder.build().

Member Function Documentation

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.close ( ) throws SQLiteTableReaderException
void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.closeTableResources ( )
private

Ensures both the statement and the result set for a table are closed.

Definition at line 495 of file SQLiteTableReader.java.

Referenced by org.sleuthkit.autopsy.coreutils.SQLiteTableReader.read(), and org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper().

String org.sleuthkit.autopsy.coreutils.SQLiteTableReader.copyFileToTempDirectory ( AbstractFile  file,
long  fileId 
) throws IOException, NoCurrentCaseException
private

Copies the file contents into a unique path in the current case temp directory.

Parameters
fileAbstractFile from the data source
fileIdThe input files id value
Returns
The path of the file on disk
Exceptions
IOExceptionException writing file contents
NoCurrentCaseExceptionCurrent case closed during file copying

Definition at line 460 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.casemodule.Case.getCurrentCaseThrows(), org.sleuthkit.autopsy.casemodule.Case.getTempDirectory(), and org.sleuthkit.autopsy.datamodel.ContentUtils.writeToFile().

Referenced by org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen(), and org.sleuthkit.autopsy.coreutils.SQLiteTableReader.findAndCopySQLiteMetaFile().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen ( ) throws SQLiteTableReaderException
private
void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.finalize ( ) throws Throwable
protected

Last ditch effort to close the connections during garbage collection.

Exceptions
Throwable

Definition at line 540 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.close().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.findAndCopySQLiteMetaFile ( AbstractFile  sqliteFile,
String  metaFileName 
) throws NoCurrentCaseException, TskCoreException, IOException
private

Searches for a meta file associated with the give SQLite database. If found, it copies this file into the temp directory of the current case.

Parameters
sqliteFilefile being processed
metaFileNamename of meta file to look for
Exceptions
NoCurrentCaseExceptionCase has been closed.
TskCoreExceptionfileManager cannot find AbstractFile files.
IOExceptionIssue during writing to file.

Definition at line 426 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.copyFileToTempDirectory(), org.sleuthkit.autopsy.casemodule.services.FileManager.findFilesExactName(), org.sleuthkit.autopsy.casemodule.Case.getCurrentCaseThrows(), org.sleuthkit.autopsy.casemodule.services.Services.getFileManager(), and org.sleuthkit.autopsy.casemodule.Case.getSleuthkitCase().

Referenced by org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen().

int org.sleuthkit.autopsy.coreutils.SQLiteTableReader.getColumnCount ( String  tableName) throws SQLiteTableReaderException

Fetches the column count of the table.

Parameters
tableNameSource table to count
Returns
Count as an integer
Exceptions
SQLiteTableReaderException

Definition at line 275 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen().

Referenced by org.sleuthkit.autopsy.textextractors.SqliteTextExtractor.SQLiteStreamReader.read().

int org.sleuthkit.autopsy.coreutils.SQLiteTableReader.getRowCount ( String  tableName) throws SQLiteTableReaderException

Fetches the row count.

Parameters
tableNameSource table to count
Returns
Count as an integer
Exceptions
SQLiteTableReaderException

Definition at line 255 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen().

List<String> org.sleuthkit.autopsy.coreutils.SQLiteTableReader.getTableNames ( ) throws SQLiteTableReaderException

Fetches all table names from the database.

Returns
List of all table names found while querying the sqlite_master table
Exceptions
SQLiteTableReaderException

Definition at line 231 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen().

Referenced by org.sleuthkit.autopsy.textextractors.SqliteTextExtractor.SQLiteStreamReader.read().

boolean org.sleuthkit.autopsy.coreutils.SQLiteTableReader.isFinished ( )

Provides status of the current read operation.

Returns

Definition at line 530 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.liveResultSet.

Referenced by org.sleuthkit.autopsy.textextractors.SqliteTextExtractor.SQLiteStreamReader.read().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.openTableResources ( String  query) throws SQLiteTableReaderException
private

Executes the query and assigns resource references to instance variables.

Parameters
queryInput query to execute
Exceptions
SQLiteTableReaderException

Definition at line 479 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.ensureOpen().

Referenced by org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.read ( String  tableName) throws SQLiteTableReaderException

Reads column names and values from the table. Only actions that were configured in the Builder will be invoked during iteration. Iteration will stop when the table read has completed or an exception was encountered.

Parameters
tableNameSource table to read
Exceptions
SQLiteTableReaderException

Definition at line 295 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper().

Referenced by org.sleuthkit.autopsy.textextractors.SqliteTextExtractor.SQLiteStreamReader.read().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.read ( String  tableName,
int  limit,
int  offset 
) throws SQLiteTableReaderException

Reads column names and values from the table. Only actions that were configured in the Builder will be invoked during iteration. Iteration will stop when the table read has completed or an exception was encountered.

Parameters
tableNameSource table to perform a read
limitNumber of rows to read from the table
offsetStarting row to read from in the table
Exceptions
SQLiteTableReaderException

Definition at line 312 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.read ( String  tableName,
BooleanSupplier  condition 
) throws SQLiteTableReaderException

Reads column names and values from the table. Iteration will stop when the condition is true.

Parameters
tableNameSource table to perform a read
conditionCondition to stop iteration when true
Exceptions
SQLiteTableReaderException

Definition at line 327 of file SQLiteTableReader.java.

References org.sleuthkit.autopsy.coreutils.SQLiteTableReader.closeTableResources(), and org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper().

void org.sleuthkit.autopsy.coreutils.SQLiteTableReader.readHelper ( String  query,
BooleanSupplier  condition 
) throws SQLiteTableReaderException
private

Member Data Documentation

final Builder org.sleuthkit.autopsy.coreutils.SQLiteTableReader.builder
private
int org.sleuthkit.autopsy.coreutils.SQLiteTableReader.columnNameIndex
private

Definition at line 208 of file SQLiteTableReader.java.

Connection org.sleuthkit.autopsy.coreutils.SQLiteTableReader.conn
private

Definition at line 201 of file SQLiteTableReader.java.

ResultSetMetaData org.sleuthkit.autopsy.coreutils.SQLiteTableReader.currentMetadata
private

Definition at line 204 of file SQLiteTableReader.java.

int org.sleuthkit.autopsy.coreutils.SQLiteTableReader.currRowColumnIndex
private

Definition at line 207 of file SQLiteTableReader.java.

final AbstractFile org.sleuthkit.autopsy.coreutils.SQLiteTableReader.file
private

Definition at line 195 of file SQLiteTableReader.java.

boolean org.sleuthkit.autopsy.coreutils.SQLiteTableReader.liveResultSet
private
final Logger org.sleuthkit.autopsy.coreutils.SQLiteTableReader.logger = Logger.getLogger(SQLiteTableReader.class.getName())
staticprivate

Definition at line 199 of file SQLiteTableReader.java.

String org.sleuthkit.autopsy.coreutils.SQLiteTableReader.prevTableName
private

Definition at line 212 of file SQLiteTableReader.java.

ResultSet org.sleuthkit.autopsy.coreutils.SQLiteTableReader.queryResults
private

Definition at line 203 of file SQLiteTableReader.java.

final String org.sleuthkit.autopsy.coreutils.SQLiteTableReader.SELECT_ALL_QUERY = "SELECT * FROM \"%s\""
staticprivate

Definition at line 198 of file SQLiteTableReader.java.

PreparedStatement org.sleuthkit.autopsy.coreutils.SQLiteTableReader.statement
private

Definition at line 202 of file SQLiteTableReader.java.

int org.sleuthkit.autopsy.coreutils.SQLiteTableReader.totalColumnCount
private
boolean org.sleuthkit.autopsy.coreutils.SQLiteTableReader.unfinishedRow
private

Definition at line 210 of file SQLiteTableReader.java.


The documentation for this class was generated from the following file:

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.