public final class SqLitePgnFileIndexerSqlite4java
extends java.lang.Object
implements net.sourceforge.chessshell.plugin.api.IPgnFileIndexer
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
databaseVersion
See readDb() (and/or search for versionStr).
|
private java.util.List<java.lang.Long> |
gameBytePosition |
private long |
gameCount |
private java.lang.String |
indexFileName |
private com.almworks.sqlite4java.SQLiteConnection |
itsConnection |
private boolean |
newBase |
private java.lang.String |
pgnFileName |
private long |
pgnModifiedAt |
private net.sourceforge.chessshell.plugin.api.IProgressReporter |
progressReporter |
private net.sourceforge.chessshell.plugin.api.IPgnSymbolGetter |
psg |
private boolean |
wasCreatedAnew |
| Constructor and Description |
|---|
SqLitePgnFileIndexerSqlite4java(net.sourceforge.chessshell.plugin.api.IPgnSymbolGetter psg,
java.lang.String pgnFileName,
net.sourceforge.chessshell.plugin.api.IProgressReporter reporter)
Set up the pgn file indexer.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addBookmark(int currentGameIdx,
java.lang.String gameTrack,
java.lang.String description) |
void |
bookmark(int currentGameIdx,
java.lang.String gameTrack,
boolean bookmark) |
void |
bookmark(int currentGameIdx,
java.lang.String gameTrack,
boolean bookmark,
java.lang.String description) |
boolean |
canBookmarkPosition() |
boolean |
canClassifyPosition() |
void |
classifyPosition(int mainType,
int subType) |
void |
clearBookmarks() |
void |
close() |
private void |
createDb()
create the database tables and populate them.
|
private void |
createTables() |
private void |
dropTables(boolean acceptError) |
private long |
fetchGameCount() |
int |
getBookmarkedPositionCount() |
java.lang.String |
getBookmarkedPositionDescription(int i) |
net.sourceforge.chessshell.plugin.api.GameIndexAndTrack |
getBookmarkedPositionIndexes(int i)
Fetching the 'game track' of the i'th bookmark.
|
java.util.List<java.lang.String> |
getBookmarkGameTracks(int gameIndex)
Get the game-tracks for the game.
|
long |
getGameBytePosition(int i) |
long |
getGameCount() |
int |
getIndexInBookmarks(int gameIndex,
java.lang.String gameTrack) |
void |
indexate()
callback to allow complicated setup outside ctor
|
boolean |
isPositionBookmarked(int gameIndex,
java.lang.String gameTrack) |
private long |
openDbFile()
When opening an existing file, we have to validate several things.
|
private void |
populateTables() |
private void |
readDb() |
void |
removeBookmark(int i) |
private void |
removeBookmark(int currentGameIdx,
java.lang.String gameTrack) |
void |
setBookmarkedPositionDescription(int i,
java.lang.String description) |
private void |
updateDb(boolean acceptError) |
boolean |
wasCreatedAnew() |
private static final java.lang.String databaseVersion
private final boolean newBase
private final net.sourceforge.chessshell.plugin.api.IPgnSymbolGetter psg
private long pgnModifiedAt
private final java.lang.String pgnFileName
private final java.lang.String indexFileName
private com.almworks.sqlite4java.SQLiteConnection itsConnection
private long gameCount
private java.util.List<java.lang.Long> gameBytePosition
private boolean wasCreatedAnew
private final net.sourceforge.chessshell.plugin.api.IProgressReporter progressReporter
public SqLitePgnFileIndexerSqlite4java(net.sourceforge.chessshell.plugin.api.IPgnSymbolGetter psg,
java.lang.String pgnFileName,
net.sourceforge.chessshell.plugin.api.IProgressReporter reporter)
throws net.sourceforge.chessshell.common.DatabaseException
psg - pgnFileName - reporter - net.sourceforge.chessshell.common.DatabaseExceptionpublic void indexate()
throws net.sourceforge.chessshell.common.DatabaseFormatException
indexate in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexernet.sourceforge.chessshell.common.DatabaseFormatExceptionprivate void readDb()
public boolean wasCreatedAnew()
private void updateDb(boolean acceptError)
private void dropTables(boolean acceptError)
private void createDb()
private void createTables()
private void populateTables()
private long openDbFile()
throws net.sourceforge.chessshell.common.DatabaseFormatException
net.sourceforge.chessshell.common.DatabaseFormatException - - thrown if the file is not a valid database file,
ie. contains incorrect (not SQLite) content, wrong tables/schema, or is of a newer database
format, not known to us at the moment.public long getGameBytePosition(int i)
getGameBytePosition in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic long getGameCount()
getGameCount in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerprivate long fetchGameCount()
public void close()
close in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic boolean canBookmarkPosition()
canBookmarkPosition in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void bookmark(int currentGameIdx,
java.lang.String gameTrack,
boolean bookmark)
bookmark in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void bookmark(int currentGameIdx,
java.lang.String gameTrack,
boolean bookmark,
java.lang.String description)
bookmark in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerprivate void removeBookmark(int currentGameIdx,
java.lang.String gameTrack)
private void addBookmark(int currentGameIdx,
java.lang.String gameTrack,
java.lang.String description)
public boolean isPositionBookmarked(int gameIndex,
java.lang.String gameTrack)
isPositionBookmarked in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic int getIndexInBookmarks(int gameIndex,
java.lang.String gameTrack)
getIndexInBookmarks in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic int getBookmarkedPositionCount()
getBookmarkedPositionCount in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic net.sourceforge.chessshell.plugin.api.GameIndexAndTrack getBookmarkedPositionIndexes(int i)
getBookmarkedPositionIndexes in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void setBookmarkedPositionDescription(int i,
java.lang.String description)
setBookmarkedPositionDescription in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic java.lang.String getBookmarkedPositionDescription(int i)
getBookmarkedPositionDescription in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void clearBookmarks()
clearBookmarks in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void removeBookmark(int i)
removeBookmark in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic boolean canClassifyPosition()
canClassifyPosition in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic void classifyPosition(int mainType,
int subType)
classifyPosition in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexerpublic java.util.List<java.lang.String> getBookmarkGameTracks(int gameIndex)
getBookmarkGameTracks in interface net.sourceforge.chessshell.plugin.api.IPgnFileIndexer