iRex DR1000 Merger v0.4.1

it.andynaz.irex.dr1000.document
Class ScribbleMgr

java.lang.Object
  extended by it.andynaz.irex.dr1000.document.ScribbleMgr

 class ScribbleMgr
extends Object

Class to use the SQLite database file with the scribbles.

All the scribbles taken by an iRex DR1000 are stored in SQLite database files. Of the 4 tables in the database, this program uses only the 2 "file_metadata" and "annotations"; in the first there are the data of the files in the folder, while in the latter there are the scribbles.
The 2 tables are defined as:

                                          +------------------------+
 +------------------------+               |      annotations       |
 |     file_metadata      |               +------------------------+
 +------------------------+               | annotation_id  INTEGER |
 | file_id   INTEGER      | <------------ | file_id        INTEGER |
 | filename  VARCHAR(250) |               | file_position  INTEGER |
 +------------------------+               | data           BLOB    |
                                          | other non-used columns |
                                          +------------------------+
 

The file name is stored in the "file_metadata.filename" column, while the file id is stored in both the "file_metadata.file_id" and "annotations.file_id" columns (this is the join column between the 2 tables). The scribbles are stored per-page, where the page number is stored in the "annotations.file_position" column and the actual scribbles data are stored in the "annotations.data" column.

In case of note files, the content of the file_metadata table is a single record "file_id=1 filename=.", as the file contains only a note. In the case of PDF files the table stores a record per file, as there is a metadata.db file for each folder.

Version:
2013-08-01
Author:
andynaz

Field Summary
protected  Connection con
          Connection to the scribble database file.
 
Constructor Summary
protected ScribbleMgr()
          Creates a new ScribbleMgr.
 
Method Summary
private  int chooseFileFromDB()
          Let you choose the file in the database.
 void closeConnection()
          Close the connection to the DB.
 int getFileId(String fileName)
          Returns the id corresponding to a file name.
private  String[][] getScribbledFiles()
          Returns a table with the filenames in the database.
 List<Integer> getScribbledPages(int idFile)
          Get a list of the numbers of the pages with scribbles.
 byte[] getScribbles(int pageNumber, int idFile)
          Gets a blob with the scribbles as a list of Integer.
 void init(File db)
          Initialize the connection to an SQLite database with strokes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

con

protected Connection con
Connection to the scribble database file.

Constructor Detail

ScribbleMgr

protected ScribbleMgr()
Creates a new ScribbleMgr.

Method Detail

init

public void init(File db)
          throws ClassNotFoundException,
                 SQLException
Initialize the connection to an SQLite database with strokes. The SQLite database is stored in a SQLite file.

Parameters:
db - path of the folder which contains the database file
Throws:
ClassNotFoundException - if the class for the JDBC driver is not found
SQLException - if SQL errors occur

closeConnection

public void closeConnection()
                     throws SQLException
Close the connection to the DB.

Throws:
SQLException - if SQL errors occur

getFileId

public int getFileId(String fileName)
Returns the id corresponding to a file name. If the file is not found in the database, the program list all the files in the database having at least a scribble, so that user can choose which is the corresponding one. This can happen with a file having a name with all uppercases character, as the Linux operating system of the DR1000 may not recognize them properly.

Parameters:
fileName - the file name
Returns:
the id of the file, or 0 if the file is not found

chooseFileFromDB

private int chooseFileFromDB()
                      throws IOException
Let you choose the file in the database. Useful when the filename is not found in the database (usually if the filename is all uppercase).

Throws:
IOException

getScribbledFiles

private String[][] getScribbledFiles()
Returns a table with the filenames in the database. Only files with scribbles are returned.

Returns:
an array with the name of files in the database that have scribbles; each element in the array is an array with 3 elements, with file id, number of scribbles and filename
Throws:
SQLException - if SQL errors occour

getScribbledPages

public List<Integer> getScribbledPages(int idFile)
                                throws SQLException
Get a list of the numbers of the pages with scribbles.

Parameters:
idFile - file id (as in the database)
Returns:
a list with the number of the pages that have scribbles
Throws:
SQLException

getScribbles

public byte[] getScribbles(int pageNumber,
                           int idFile)
                    throws SQLException
Gets a blob with the scribbles as a list of Integer.

Parameters:
pageNumber - the number of the page
idFile - id of the file (as in the database)
Returns:
the blob as a byte array
Throws:
SQLException - if SQL errors occour

iRex DR1000 Merger v0.4.1

© 2013 andynaz - http://andynaz.altervista.org