Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jempeg.empeg.emptool
Class PlayerDatabase  view PlayerDatabase download PlayerDatabase.java

java.lang.Object
  extended byorg.jempeg.empeg.emptool.PlayerDatabase
All Implemented Interfaces:
java.util.EventListener, org.jempeg.empeg.protocol.event.ProtocolListenerIfc, org.jempeg.empeg.protocol.event.TuneDatabaseListenerIfc

public class PlayerDatabase
extends java.lang.Object
implements org.jempeg.empeg.protocol.event.ProtocolListenerIfc, org.jempeg.empeg.protocol.event.TuneDatabaseListenerIfc

PlayerDatabase is the primary interface to manipulating and querying the database of songs and playlists on the Empeg. It also provides the low-level implementation of downloading and synchronization to the Empeg.

Version:
$Revision: 1.23 $

Field Summary
private static int CONNECT_TIMEOUT
           
private  org.jempeg.empeg.protocol.ProtocolClient myClient
           
private  org.jempeg.empeg.core.DynamicConfigFile myConfig
           
private  boolean myConfigChanged
           
private  FIDNodeMap myFIDs
           
private  org.jempeg.empeg.protocol.PlayerIdentity myIdentity
           
private  DatabaseProgressListenerIfc myListener
           
private  java.util.Vector myRepairTagsList
           
private  java.io.File myRestoreFile
           
private  DatabaseTags myTagNames
           
private  long myTotalFree
           
private  long myTotalSize
           
private static int RESTART_TIMEOUT
           
 
Constructor Summary
PlayerDatabase(java.io.File _restoreFile)
           
PlayerDatabase(java.io.File _restoreFile, DatabaseProgressListenerIfc _listener)
           
PlayerDatabase(org.jempeg.empeg.protocol.ProtocolClient _client)
           
PlayerDatabase(org.jempeg.empeg.protocol.ProtocolClient _client, DatabaseProgressListenerIfc _listener)
           
 
Method Summary
 boolean addFID(int _fid, AbstractFIDNode _node)
           
 int addTag(java.lang.String _name)
           
 void adjustFreeSpace(long _size)
           
 void backup(java.io.File _backupFile)
           
 int checkRootLists()
           
protected  void clearTags()
           
protected  FIDPlaylist createRootPlaylist()
           
 boolean databaseEntryFound(org.jempeg.empeg.protocol.event.TuneDatabaseEntryEvent _event)
           
 int download(boolean _rebuildOnFail)
           
 void ensureBasicTags()
           
 int findFreeFID()
           
 org.jempeg.empeg.protocol.ProtocolClient getClient()
           
 java.lang.String getConfig()
           
 org.jempeg.empeg.core.DynamicConfigFile getConfigFile()
           
 DatabaseProgressListenerIfc getListener()
           
 AbstractFIDNode getNode(int _fid)
           
 AbstractFIDNode getNode(java.lang.String _gfid)
           
 FIDNodeMap getNodeMap()
           
 FIDPlaylist getPlaylist(int _fid)
           
 FIDPlaylist getRootPlaylist()
           
 java.lang.String getTagName(int _tag)
           
 DatabaseTags getTagNames()
           
 int getTagNumber(java.lang.String _name)
           
 int getTitleTag()
           
 long getTotalFree()
           
 long getTotalSize()
           
 long getTotalUsed()
           
 int getTypeTag()
           
 java.lang.String getUniqueID(long _fid)
          Returns the globally unique id for the given FID.
 boolean isDirty()
          Returns whether or not any nodes in this database are dirty.
protected  boolean isRepairRequired(AbstractFIDNode _node)
           
 boolean isTagRepairRequired()
          Returns whether or not there are nodes that require tags to be repaired.
 void logFreeSpace()
           
protected  int needRebuild(boolean _rebuildOnFail, boolean _doRebuild)
           
 void progressReported(org.jempeg.empeg.protocol.event.ProtocolActivityEvent _event)
           
 AbstractFIDNode readFID(int _fid, NodeTags _tags)
           
protected  void readOnly()
           
 void rebuildDatabase()
           
 boolean removeFID(int _fid)
           
protected  void removeFIDs()
           
 int repair(boolean _doRepair)
           
 void repairTags()
          Repairs the nodes that have missing frame tags.
 void restore(java.io.File _restoreFile)
           
 void setConfigFile(org.jempeg.empeg.core.DynamicConfigFile _configFile)
           
 void setConfigValue(java.lang.String _section, java.lang.String _key, java.lang.String _value)
           
 void setListener(DatabaseProgressListenerIfc _listener)
           
 void synchronize()
           
protected  void synchronizeReadOnly()
           
 void tagIndexFound(org.jempeg.empeg.protocol.event.TuneDatabaseIndexEvent _event)
           
 void warningReported(org.jempeg.empeg.protocol.event.ProtocolWarningEvent _event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECT_TIMEOUT

private static final int CONNECT_TIMEOUT
See Also:
Constant Field Values

RESTART_TIMEOUT

private static final int RESTART_TIMEOUT
See Also:
Constant Field Values

myClient

private org.jempeg.empeg.protocol.ProtocolClient myClient

myListener

private DatabaseProgressListenerIfc myListener

myConfig

private org.jempeg.empeg.core.DynamicConfigFile myConfig

myConfigChanged

private boolean myConfigChanged

myTagNames

private DatabaseTags myTagNames

myFIDs

private FIDNodeMap myFIDs

myRestoreFile

private java.io.File myRestoreFile

myTotalSize

private long myTotalSize

myTotalFree

private long myTotalFree

myRepairTagsList

private java.util.Vector myRepairTagsList

myIdentity

private org.jempeg.empeg.protocol.PlayerIdentity myIdentity
Constructor Detail

PlayerDatabase

public PlayerDatabase(org.jempeg.empeg.protocol.ProtocolClient _client)

PlayerDatabase

public PlayerDatabase(org.jempeg.empeg.protocol.ProtocolClient _client,
                      DatabaseProgressListenerIfc _listener)

PlayerDatabase

public PlayerDatabase(java.io.File _restoreFile)

PlayerDatabase

public PlayerDatabase(java.io.File _restoreFile,
                      DatabaseProgressListenerIfc _listener)
Method Detail

getUniqueID

public java.lang.String getUniqueID(long _fid)
                             throws java.io.IOException
Returns the globally unique id for the given FID.


isDirty

public boolean isDirty()
Returns whether or not any nodes in this database are dirty.


isTagRepairRequired

public boolean isTagRepairRequired()
Returns whether or not there are nodes that require tags to be repaired. This would be the case if the user is upgrading from an older version of Emplode. To repair the nodes, call repairTags.


repairTags

public void repairTags()
Repairs the nodes that have missing frame tags.


clearTags

protected void clearTags()

removeFIDs

protected void removeFIDs()
                   throws java.io.IOException

getClient

public org.jempeg.empeg.protocol.ProtocolClient getClient()

setListener

public void setListener(DatabaseProgressListenerIfc _listener)

getListener

public DatabaseProgressListenerIfc getListener()

backup

public void backup(java.io.File _backupFile)
            throws java.io.IOException

restore

public void restore(java.io.File _restoreFile)
             throws java.lang.ClassNotFoundException,
                    java.io.IOException

getNode

public AbstractFIDNode getNode(int _fid)

getNode

public AbstractFIDNode getNode(java.lang.String _gfid)

findFreeFID

public int findFreeFID()

getTagNumber

public int getTagNumber(java.lang.String _name)

getTagName

public java.lang.String getTagName(int _tag)

addTag

public int addTag(java.lang.String _name)

getTagNames

public DatabaseTags getTagNames()

getTypeTag

public int getTypeTag()

getTitleTag

public int getTitleTag()

addFID

public boolean addFID(int _fid,
                      AbstractFIDNode _node)
               throws java.io.IOException

removeFID

public boolean removeFID(int _fid)
                  throws java.io.IOException

tagIndexFound

public void tagIndexFound(org.jempeg.empeg.protocol.event.TuneDatabaseIndexEvent _event)
Specified by:
tagIndexFound in interface org.jempeg.empeg.protocol.event.TuneDatabaseListenerIfc

getNodeMap

public FIDNodeMap getNodeMap()

getRootPlaylist

public FIDPlaylist getRootPlaylist()

getPlaylist

public FIDPlaylist getPlaylist(int _fid)

databaseEntryFound

public boolean databaseEntryFound(org.jempeg.empeg.protocol.event.TuneDatabaseEntryEvent _event)
Specified by:
databaseEntryFound in interface org.jempeg.empeg.protocol.event.TuneDatabaseListenerIfc

isRepairRequired

protected boolean isRepairRequired(AbstractFIDNode _node)

progressReported

public void progressReported(org.jempeg.empeg.protocol.event.ProtocolActivityEvent _event)
Specified by:
progressReported in interface org.jempeg.empeg.protocol.event.ProtocolListenerIfc

warningReported

public void warningReported(org.jempeg.empeg.protocol.event.ProtocolWarningEvent _event)
Specified by:
warningReported in interface org.jempeg.empeg.protocol.event.ProtocolListenerIfc

ensureBasicTags

public void ensureBasicTags()

getConfig

public java.lang.String getConfig()
                           throws java.io.IOException

getConfigFile

public org.jempeg.empeg.core.DynamicConfigFile getConfigFile()
                                                      throws java.io.IOException

setConfigFile

public void setConfigFile(org.jempeg.empeg.core.DynamicConfigFile _configFile)

setConfigValue

public void setConfigValue(java.lang.String _section,
                           java.lang.String _key,
                           java.lang.String _value)
                    throws java.io.IOException

createRootPlaylist

protected FIDPlaylist createRootPlaylist()
                                  throws java.io.IOException

checkRootLists

public int checkRootLists()
                   throws java.io.IOException

readFID

public AbstractFIDNode readFID(int _fid,
                               NodeTags _tags)
                        throws java.lang.IllegalArgumentException,
                               java.io.IOException

repair

public int repair(boolean _doRepair)
           throws java.io.IOException

logFreeSpace

public void logFreeSpace()
                  throws java.io.IOException

getTotalSize

public long getTotalSize()

getTotalFree

public long getTotalFree()

getTotalUsed

public long getTotalUsed()

adjustFreeSpace

public void adjustFreeSpace(long _size)

download

public int download(boolean _rebuildOnFail)
             throws java.io.IOException

needRebuild

protected int needRebuild(boolean _rebuildOnFail,
                          boolean _doRebuild)
                   throws java.io.IOException

synchronize

public void synchronize()
                 throws java.io.IOException

synchronizeReadOnly

protected void synchronizeReadOnly()
                            throws java.io.IOException

rebuildDatabase

public void rebuildDatabase()
                     throws java.io.IOException

readOnly

protected void readOnly()
                 throws java.io.IOException