net.sourceforge.neurosdbm.db
Class Database

java.lang.Object
  extended bynet.sourceforge.neurosdbm.db.Database
Direct Known Subclasses:
AdvDatabase

public class Database
extends java.lang.Object


Nested Class Summary
 class Database.SyncStats
           
 
Field Summary
private  AudioDB audioDB
           
static int DB_AA_ALL
           
static int DB_AA_ARTISTS
           
static int DB_ALBUMS
           
static int DB_ARTISTS
           
static int DB_AUDIO
           
static int DB_FAILEDHISI
           
static int DB_GENRES
           
static int DB_HISI
           
static int DB_IDEDHISI
           
static int DB_PCAUDIO
           
static int DB_PLAYLISTS
           
static int DB_RECORDINGS
           
static int DB_TRACKS
           
static int DB_UNIDEDHISI
           
protected  java.util.ArrayList deleteQueue
           
protected  NeurosDevice device
           
private  FailedHiSiDB failedhisiDB
           
private  IdedHiSiDB idedhisiDB
           
private  boolean modifiedPlaylists
           
protected  java.util.ArrayList modifyQueue
           
(package private)  java.io.File music
           
protected  boolean needForPlaylist
           
protected  java.lang.String path
           
private  PCAudioDB pcaudioDB
           
protected  java.util.ArrayList playlistQueue
           
private static java.lang.String RECORDING_REGEX
          The regular expression to determine the recording directory.
private  java.lang.String SearchPath
           
protected  java.util.ArrayList syncQueue
           
private  UnidedHiSiDB unidedhisiDB
           
 
Constructor Summary
protected Database()
          This constuctor should only be called by the AdvDatabase subclass.
  Database(java.lang.String _path, boolean createNew, int _device)
           
  Database(java.lang.String _path, int _device)
           
 
Method Summary
 int addFilesToPlaylist(java.io.File[] files, int playListKey)
          Add files directly to playlist.
 void addToPlaylist(java.util.ArrayList tracks, int playlistKey)
           
 void addToPlaylist(int audioKey, int playlistKey)
           
 void addToPlaylist(int audioKey, int playlistKey, boolean disableSave)
           
 void autoBackup()
           
 void backup(java.io.File targetDirectory)
          This function makes a backup of the database to the specified target directory.
static void backupError(java.lang.String databaseDirectory)
          This function is called if an error has occured during database parsing.
private  void checkForRecording(NewTrack newTrack)
          Check to see if this track is in the recording directory.
private  void checkParents(java.io.File file)
           
 void computeMDBPointers()
           
 void createEmptyDatabase()
           
 int createPlaylist(java.lang.String name)
           
 int createPlaylist(java.lang.String name, boolean disableSave)
          Creates a new playlist.
 void deleteDatabase()
          This function deletes all the database files from the Neuros device.
 void deleteFromPlaylist(java.util.ArrayList tracks, int playlistKey)
           
 boolean deleteQueueContains(AudioRecord record)
           
static void fixDBDir(java.lang.String path)
           
 NeurosDevice getDevice()
           
 NewTrack getNewTrackFromSyncQueue(AudioRecord record)
           
 int getNumberDeleted()
           
 int getNumberModified()
           
 int getNumberQueued()
           
 java.lang.String getPath()
           
 boolean hasModifiedPlaylists()
           
private  void loadExistingDatabase()
           
 void markTracksForDeletion(java.util.ArrayList tracks)
           
 boolean modifyQueueContains(AudioRecord record)
           
 void modifyTrack(int audioKey, NewTrack newTrack)
          The purpose of this function is to modify the Neuros tags of given track.
 DisplayRecord query(DisplayIndex index)
           
 java.util.ArrayList query(int database, int type)
           
 java.util.ArrayList query(int database, int type, int key)
           
 java.util.ArrayList queryTracksForAlbum(int albumKey)
           
 java.util.ArrayList queryTracksForArtist(int artistKey)
           
 java.util.ArrayList queryTracksForGenre(int genreKey)
           
 java.util.ArrayList queryTracksForPlaylist(int playlistKey)
           
 java.util.ArrayList queryTracksForRecordings(int recordingKey)
           
 boolean queueMP3TrackAdd(java.io.File trackToAdd)
           
 boolean queueMP3TrackAdd(java.io.File trackToAdd, boolean rebuild)
           
private  boolean queueOGGTrackAdd(java.io.File trackToAdd)
           
private  boolean queueOGGTrackAdd(java.io.File trackToAdd, boolean rebuild)
           
 boolean queueTrackAdd(NewTrack newTrack)
          Queues the new track for copying over to the Neuros.
 int queueTracksRecurseDirectories(java.io.File[] files)
           
 boolean queueWAVTrackAdd(java.io.File trackToAdd)
           
 boolean queueWAVTrackAdd(java.io.File trackToAdd, boolean rebuild)
           
 boolean queueWMATrackAdd(java.io.File trackToAdd)
           
 boolean queueWMATrackAdd(java.io.File trackToAdd, boolean rebuild)
           
 void rearrangePlaylist(java.util.ArrayList tracks, int playlistKey)
           
 int rebuild()
           
 int rebuild(RebuildDatabase.RebuildDialog dialog)
           
private  int rebuildTracks(int numberRebuilt, java.io.File[] files, RebuildDatabase.RebuildDialog dialog)
           
 void refreshDatabase()
           
 void refreshDatabase(java.lang.String _path, int _device)
           
 void removePlaylist(int playlistKey)
           
 void renamePlaylist(java.lang.String newName, int playlistKey)
           
 void restore(java.io.File restorePathFile)
          This function restores the database from a previously peformed backup.
private  void setIsModifiedBit(java.io.File mdbFileName)
          This function sets the "isModifiedBit" in the passed in MDB file.
 void sort()
           
 void sort(java.util.ArrayList list)
           
 Database.SyncStats synchronize(Listener progress)
           
 boolean syncQueueContains(AudioRecord record)
           
 void testTrackAdd1()
           
 void testTrackAdd2()
           
 void testTrackAddRandom()
           
 java.lang.String toString()
           
 void write()
          This function writes the current in memory database to the Neuros device.
 void write(boolean disableAutoBackup)
          This function writes the current in memory database to the Neuros device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

device

protected NeurosDevice device

audioDB

private AudioDB audioDB

unidedhisiDB

private UnidedHiSiDB unidedhisiDB

idedhisiDB

private IdedHiSiDB idedhisiDB

failedhisiDB

private FailedHiSiDB failedhisiDB

pcaudioDB

private PCAudioDB pcaudioDB

path

protected java.lang.String path

SearchPath

private java.lang.String SearchPath

modifiedPlaylists

private boolean modifiedPlaylists

syncQueue

protected java.util.ArrayList syncQueue

deleteQueue

protected java.util.ArrayList deleteQueue

modifyQueue

protected java.util.ArrayList modifyQueue

needForPlaylist

protected boolean needForPlaylist

playlistQueue

protected java.util.ArrayList playlistQueue

DB_AUDIO

public static final int DB_AUDIO
See Also:
Constant Field Values

DB_FAILEDHISI

public static final int DB_FAILEDHISI
See Also:
Constant Field Values

DB_IDEDHISI

public static final int DB_IDEDHISI
See Also:
Constant Field Values

DB_PCAUDIO

public static final int DB_PCAUDIO
See Also:
Constant Field Values

DB_UNIDEDHISI

public static final int DB_UNIDEDHISI
See Also:
Constant Field Values

DB_AA_ALL

public static final int DB_AA_ALL
See Also:
Constant Field Values

DB_AA_ARTISTS

public static final int DB_AA_ARTISTS
See Also:
Constant Field Values

DB_TRACKS

public static final int DB_TRACKS
See Also:
Constant Field Values

DB_PLAYLISTS

public static final int DB_PLAYLISTS
See Also:
Constant Field Values

DB_ARTISTS

public static final int DB_ARTISTS
See Also:
Constant Field Values

DB_ALBUMS

public static final int DB_ALBUMS
See Also:
Constant Field Values

DB_GENRES

public static final int DB_GENRES
See Also:
Constant Field Values

DB_RECORDINGS

public static final int DB_RECORDINGS
See Also:
Constant Field Values

DB_HISI

public static final int DB_HISI
See Also:
Constant Field Values

RECORDING_REGEX

private static java.lang.String RECORDING_REGEX
The regular expression to determine the recording directory.


music

java.io.File music
Constructor Detail

Database

public Database(java.lang.String _path,
                boolean createNew,
                int _device)
         throws java.io.FileNotFoundException,
                java.io.IOException,
                DatabaseCorruptException,
                DatabaseDoesNotExistException

Database

public Database(java.lang.String _path,
                int _device)
         throws java.io.FileNotFoundException,
                java.io.IOException,
                DatabaseCorruptException,
                DatabaseDoesNotExistException

Database

protected Database()
This constuctor should only be called by the AdvDatabase subclass.

Method Detail

loadExistingDatabase

private void loadExistingDatabase()
                           throws java.io.FileNotFoundException,
                                  java.io.IOException,
                                  DatabaseCorruptException,
                                  DatabaseDoesNotExistException
Throws:
java.io.FileNotFoundException
java.io.IOException
DatabaseCorruptException
DatabaseDoesNotExistException

createEmptyDatabase

public void createEmptyDatabase()
                         throws java.io.FileNotFoundException,
                                java.io.IOException,
                                DatabaseCorruptException
Throws:
java.io.FileNotFoundException
java.io.IOException
DatabaseCorruptException

refreshDatabase

public void refreshDatabase()
                     throws java.io.FileNotFoundException,
                            java.io.IOException,
                            DatabaseCorruptException,
                            DatabaseDoesNotExistException
Throws:
java.io.FileNotFoundException
java.io.IOException
DatabaseCorruptException
DatabaseDoesNotExistException

refreshDatabase

public void refreshDatabase(java.lang.String _path,
                            int _device)
                     throws java.io.FileNotFoundException,
                            java.io.IOException,
                            DatabaseCorruptException,
                            DatabaseDoesNotExistException
Throws:
java.io.FileNotFoundException
java.io.IOException
DatabaseCorruptException
DatabaseDoesNotExistException

deleteDatabase

public void deleteDatabase()
This function deletes all the database files from the Neuros device. Essentially the entire woid_db directory and everything underneath is removed.


write

public void write()
           throws java.io.IOException,
                  DatabaseInternalCorruptionException
This function writes the current in memory database to the Neuros device. An autobackup will occur if this option is set.

Throws:
java.io.IOException
DatabaseInternalCorruptionException

write

public void write(boolean disableAutoBackup)
           throws java.io.IOException,
                  DatabaseInternalCorruptionException
This function writes the current in memory database to the Neuros device. An autobackup will occur depending on the argument and if the option is set.

Parameters:
disableAutoBackup - true if you don't want to write a autobackup
Throws:
java.io.IOException
DatabaseInternalCorruptionException

query

public java.util.ArrayList query(int database,
                                 int type)

query

public java.util.ArrayList query(int database,
                                 int type,
                                 int key)

query

public DisplayRecord query(DisplayIndex index)

sort

public void sort(java.util.ArrayList list)

getPath

public java.lang.String getPath()

backupError

public static void backupError(java.lang.String databaseDirectory)
This function is called if an error has occured during database parsing. The database should be saved for later analysis.


backup

public void backup(java.io.File targetDirectory)
            throws java.io.FileNotFoundException,
                   java.io.IOException
This function makes a backup of the database to the specified target directory. Essentially it recursively copies the entire directory tree into the target.

Parameters:
targetDirectory - The target directory for the backup.
Throws:
java.io.FileNotFoundException
java.io.IOException

restore

public void restore(java.io.File restorePathFile)
             throws java.io.FileNotFoundException,
                    java.io.IOException
This function restores the database from a previously peformed backup.

Parameters:
restorePathFile - The directory of the backup to restore
Throws:
java.io.FileNotFoundException
java.io.IOException

setIsModifiedBit

private void setIsModifiedBit(java.io.File mdbFileName)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
This function sets the "isModifiedBit" in the passed in MDB file. This bit needs to be set in order for the Neuros device to read the file (otherwise it just uses the cache value.)

Throws:
java.io.FileNotFoundException
java.io.IOException

rebuild

public int rebuild()
            throws DatabaseInternalCorruptionException,
                   DatabaseCorruptException,
                   java.io.FileNotFoundException,
                   java.io.IOException
Throws:
DatabaseInternalCorruptionException
DatabaseCorruptException
java.io.FileNotFoundException
java.io.IOException

rebuild

public int rebuild(RebuildDatabase.RebuildDialog dialog)
            throws DatabaseInternalCorruptionException,
                   DatabaseCorruptException,
                   java.io.FileNotFoundException,
                   java.io.IOException
Throws:
DatabaseInternalCorruptionException
DatabaseCorruptException
java.io.FileNotFoundException
java.io.IOException

rebuildTracks

private int rebuildTracks(int numberRebuilt,
                          java.io.File[] files,
                          RebuildDatabase.RebuildDialog dialog)

checkForRecording

private void checkForRecording(NewTrack newTrack)
Check to see if this track is in the recording directory. If it is, set the recording flag.


queueMP3TrackAdd

public boolean queueMP3TrackAdd(java.io.File trackToAdd)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueMP3TrackAdd

public boolean queueMP3TrackAdd(java.io.File trackToAdd,
                                boolean rebuild)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueOGGTrackAdd

private boolean queueOGGTrackAdd(java.io.File trackToAdd)
                          throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueOGGTrackAdd

private boolean queueOGGTrackAdd(java.io.File trackToAdd,
                                 boolean rebuild)
                          throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueWMATrackAdd

public boolean queueWMATrackAdd(java.io.File trackToAdd)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueWMATrackAdd

public boolean queueWMATrackAdd(java.io.File trackToAdd,
                                boolean rebuild)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueWAVTrackAdd

public boolean queueWAVTrackAdd(java.io.File trackToAdd)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueWAVTrackAdd

public boolean queueWAVTrackAdd(java.io.File trackToAdd,
                                boolean rebuild)
                         throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueTracksRecurseDirectories

public int queueTracksRecurseDirectories(java.io.File[] files)
                                  throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

queueTrackAdd

public boolean queueTrackAdd(NewTrack newTrack)
                      throws DatabaseInternalCorruptionException
Queues the new track for copying over to the Neuros. The track can be of any type.

Parameters:
newTrack - The track to add.
Returns:
true if successfully added
Throws:
DatabaseInternalCorruptionException - Database is corrupted.

sort

public void sort()

checkParents

private void checkParents(java.io.File file)

synchronize

public Database.SyncStats synchronize(Listener progress)

autoBackup

public void autoBackup()
                throws java.io.FileNotFoundException,
                       java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

testTrackAdd1

public void testTrackAdd1()
                   throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

testTrackAdd2

public void testTrackAdd2()
                   throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

testTrackAddRandom

public void testTrackAddRandom()
                        throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

getNumberQueued

public int getNumberQueued()

getNumberDeleted

public int getNumberDeleted()

getNumberModified

public int getNumberModified()

markTracksForDeletion

public void markTracksForDeletion(java.util.ArrayList tracks)

createPlaylist

public int createPlaylist(java.lang.String name)

createPlaylist

public int createPlaylist(java.lang.String name,
                          boolean disableSave)
Creates a new playlist. The key of the new playlist is returned.

Parameters:
name - The name of this playlist.
Returns:
The key of the newly created playlist.

removePlaylist

public void removePlaylist(int playlistKey)

addToPlaylist

public void addToPlaylist(int audioKey,
                          int playlistKey)
                   throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

addToPlaylist

public void addToPlaylist(int audioKey,
                          int playlistKey,
                          boolean disableSave)
                   throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

addToPlaylist

public void addToPlaylist(java.util.ArrayList tracks,
                          int playlistKey)
                   throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

deleteFromPlaylist

public void deleteFromPlaylist(java.util.ArrayList tracks,
                               int playlistKey)
                        throws DatabaseInternalCorruptionException
Throws:
DatabaseInternalCorruptionException

rearrangePlaylist

public void rearrangePlaylist(java.util.ArrayList tracks,
                              int playlistKey)

renamePlaylist

public void renamePlaylist(java.lang.String newName,
                           int playlistKey)

addFilesToPlaylist

public int addFilesToPlaylist(java.io.File[] files,
                              int playListKey)
                       throws DatabaseInternalCorruptionException
Add files directly to playlist. Description: A set of files are added to the databases and also to the given playlist. Directories are traversed. Arguments: files: an array of files/directories to add playListKey: the playlist id Return: Number of files added

Throws:
DatabaseInternalCorruptionException

getDevice

public NeurosDevice getDevice()

toString

public java.lang.String toString()

deleteQueueContains

public boolean deleteQueueContains(AudioRecord record)

syncQueueContains

public boolean syncQueueContains(AudioRecord record)

modifyQueueContains

public boolean modifyQueueContains(AudioRecord record)

queryTracksForArtist

public java.util.ArrayList queryTracksForArtist(int artistKey)

queryTracksForAlbum

public java.util.ArrayList queryTracksForAlbum(int albumKey)

queryTracksForGenre

public java.util.ArrayList queryTracksForGenre(int genreKey)

queryTracksForRecordings

public java.util.ArrayList queryTracksForRecordings(int recordingKey)

queryTracksForPlaylist

public java.util.ArrayList queryTracksForPlaylist(int playlistKey)

hasModifiedPlaylists

public boolean hasModifiedPlaylists()

fixDBDir

public static void fixDBDir(java.lang.String path)

modifyTrack

public void modifyTrack(int audioKey,
                        NewTrack newTrack)
The purpose of this function is to modify the Neuros tags of given track.

Parameters:
audioKey - The key of the track to be changed in the audio database.
newTrack - The new information.

computeMDBPointers

public void computeMDBPointers()

getNewTrackFromSyncQueue

public NewTrack getNewTrackFromSyncQueue(AudioRecord record)


Copyright © 2004 NeurosDBM Dev Team All Rights Reserved.