public class ScribbleMgr
extends java.lang.Object
All the scribbles taken by an iRex DR1000 are stored in SQLite database
files. Of the four in the database, this program uses only the two tables
"file_metadata
" and "annotations
"; in the first there are the
data of the files in the folder, while in the latter are the scribbles.
The two tables are defined as:
+---------------------------+ | annotations | +------------------------+ +---------------------------+ | file_metadata | | annotation_id INTEGER | +------------------------+ | annotation_type TEXT | | file_id INTEGER | <------------ | file_id INTEGER | | filename VARCHAR(250) | | file_position INTEGER | +------------------------+ | data BLOB | | other non-used columns | +---------------------------+
In the case of PDF files there is a metadata.db
database in each
folder, and the table file_metadata
stores a record per file.
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.
A note taken with the device is memorized in a SQLite databse file with
the same structure above, except that the content of the file_metadata
table is a single record "file_id=1, filename=.
".
Modifier and Type | Field and Description |
---|---|
protected java.sql.Connection |
con
Connection to the scribble database file.
|
Constructor and Description |
---|
ScribbleMgr()
Creates a new ScribbleMgr.
|
Modifier and Type | Method and Description |
---|---|
private int |
chooseFileFromDB()
Let you choose the file in the database.
|
void |
closeConnection()
Close the connection to the DB.
|
int |
getFileId(java.lang.String fileName)
Returns the id corresponding to a file name.
|
java.lang.String[][] |
getScribbledFiles()
Returns a matrix with the scribbled files in the database.
|
java.util.List<java.lang.Integer> |
getScribbledPages(int idFile)
Returns a list of the pages' number with scribbles.
|
byte[] |
getScribbles(int pageNumber,
int idFile)
Returns a blob with the scribbles.
|
void |
init(java.io.File db)
Sets the database file and initialize the connection.
|
static void |
printFiles(java.lang.String[][] files)
Print a tables with the files in the database.
|
public void init(java.io.File db) throws java.lang.ClassNotFoundException, java.sql.SQLException
db
- path of the folder which contains the database filejava.lang.ClassNotFoundException
- if the class for the JDBC driver is not
foundjava.sql.SQLException
- if SQL errors occurpublic void closeConnection() throws java.sql.SQLException
java.sql.SQLException
- if SQL errors occurpublic int getFileId(java.lang.String fileName)
fileName
- the file nameprivate int chooseFileFromDB() throws java.io.IOException
java.io.IOException
public java.lang.String[][] getScribbledFiles()
public java.util.List<java.lang.Integer> getScribbledPages(int idFile) throws java.sql.SQLException
idFile
- file id (as in the database)java.sql.SQLException
public byte[] getScribbles(int pageNumber, int idFile) throws java.sql.SQLException
pageNumber
- the number of the pageidFile
- id of the file (as in the database)java.sql.SQLException
- if SQL errors occourpublic static void printFiles(java.lang.String[][] files)
files
- matrix with files, as returned by the method getScribbledFiles
© 2015 andynaz - http://andynaz.altervista.org