org.biffle.cliff.pearl2
Class Pearl2TCPConnection

java.lang.Object
  |
  +--org.biffle.cliff.pearl.PearlTCPConnection
        |
        +--org.biffle.cliff.pearl2.Pearl2TCPConnection
All Implemented Interfaces:
Pearl2Connection, PearlConnection

public class Pearl2TCPConnection
extends PearlTCPConnection
implements Pearl2Connection

A wrapper for PearlTCPConnection that provides the Pearl2Connection level of functionality, including data caching/validation, progress and authentication handlers, and simplified file transfer.


Field Summary
 
Fields inherited from class org.biffle.cliff.pearl.PearlTCPConnection
AUTHENTICATE, authenticated, BUSY, DELETE_FILE, GET_ALL_FILE_INFO, GET_DATABASE_LOCK, GET_DEVICE_INFO, GET_DEVICE_SETTINGS, GET_FILE_INFO, GET_SALT, GET_STORAGE_INFO, NAK, PROTOCOL_VERSION, READ, readLock, RELEASE_DATABASE_LOCK, saki, SET_FILE_INFO, signature, WRITE, writeLock
 
Constructor Summary
Pearl2TCPConnection(java.net.InetAddress device, int port)
          Creates a new Pearl2TCPConnection to the given device and port.
 
Method Summary
 void deleteFile(int fid)
          Removes a file from the device.
 FileInfo getFileByFID(int fid)
          Returns a file by FID, or null if no such FID exists.
 long getFileCount()
          Returns the number of files available on the device.
 java.util.Iterator getFileIterator()
          Returns an iterator for the known files.
 int getMaxFID()
          Returns the highest allocated FID.
 void readFile(int fid, java.io.File dest)
          Downloads a file from the device by FID.
protected  void requireAuth()
           
 void setAuthHandler(AuthHandler handler)
          Sets the AuthHandler to be used if authentication is required.
 void setProgressHandler(ProgressHandler handler)
          Sets a library-global ProgressHandler.
protected  void validateFileInfoCache()
           
 int writeFile(java.io.File src)
          Writes a local file to the device.
 int writeTaxiFile(java.io.File src)
          Writes a local file to the device without attempting to interpret the file as a song.
 
Methods inherited from class org.biffle.cliff.pearl.PearlTCPConnection
authenticate, close, getAllFileInfo, getDeviceInfo, getDeviceSettings, getFileInfo, getMessage, getNullTermString, getStorageInfo, getVersion, isAuthenticated, lockDatabase, readFileChunk, sendMessage, setFileInfo, unlockDatabase, writeFileChunk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biffle.cliff.pearl2.Pearl2Connection
close, getDeviceInfo, getDeviceSettings, getStorageInfo, getVersion, isAuthenticated, setFileInfo
 

Constructor Detail

Pearl2TCPConnection

public Pearl2TCPConnection(java.net.InetAddress device,
                           int port)
                    throws java.io.IOException,
                           PearlException
Creates a new Pearl2TCPConnection to the given device and port.

Method Detail

setAuthHandler

public void setAuthHandler(AuthHandler handler)
Description copied from interface: Pearl2Connection
Sets the AuthHandler to be used if authentication is required.

Specified by:
setAuthHandler in interface Pearl2Connection

setProgressHandler

public void setProgressHandler(ProgressHandler handler)
Description copied from interface: Pearl2Connection
Sets a library-global ProgressHandler.

Specified by:
setProgressHandler in interface Pearl2Connection

getFileCount

public long getFileCount()
                  throws PearlException
Description copied from interface: Pearl2Connection
Returns the number of files available on the device.

Specified by:
getFileCount in interface Pearl2Connection
PearlException

getFileIterator

public java.util.Iterator getFileIterator()
                                   throws PearlException
Description copied from interface: Pearl2Connection
Returns an iterator for the known files.

Specified by:
getFileIterator in interface Pearl2Connection
PearlException

getFileByFID

public FileInfo getFileByFID(int fid)
                      throws PearlException
Description copied from interface: Pearl2Connection
Returns a file by FID, or null if no such FID exists.

Specified by:
getFileByFID in interface Pearl2Connection
PearlException

getMaxFID

public int getMaxFID()
              throws PearlException
Description copied from interface: Pearl2Connection
Returns the highest allocated FID.

Specified by:
getMaxFID in interface Pearl2Connection
PearlException

writeFile

public int writeFile(java.io.File src)
              throws PearlException,
                     java.io.FileNotFoundException,
                     java.io.IOException
Description copied from interface: Pearl2Connection
Writes a local file to the device. Returns the file's FID.

Specified by:
writeFile in interface Pearl2Connection
PearlException
java.io.FileNotFoundException
java.io.IOException

writeTaxiFile

public int writeTaxiFile(java.io.File src)
                  throws PearlException,
                         java.io.FileNotFoundException,
                         java.io.IOException
Description copied from interface: Pearl2Connection
Writes a local file to the device without attempting to interpret the file as a song. Returns the file's FID.

Specified by:
writeTaxiFile in interface Pearl2Connection
PearlException
java.io.FileNotFoundException
java.io.IOException

readFile

public void readFile(int fid,
                     java.io.File dest)
              throws PearlException,
                     java.io.IOException
Description copied from interface: Pearl2Connection
Downloads a file from the device by FID.

Specified by:
readFile in interface Pearl2Connection
PearlException
java.io.IOException

deleteFile

public void deleteFile(int fid)
                throws PearlException
Description copied from interface: Pearl2Connection
Removes a file from the device.

Specified by:
deleteFile in interface Pearl2Connection
Overrides:
deleteFile in class PearlTCPConnection
PearlException

validateFileInfoCache

protected void validateFileInfoCache()
                              throws PearlException
PearlException

requireAuth

protected void requireAuth()
                    throws PearlException
PearlException