|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.biffle.cliff.pearl.PearlTCPConnection
Provides a TCP implementation of the Pearl protocol.
| Field Summary | |
protected static int |
AUTHENTICATE
Message type for Authenticate message. |
protected boolean |
authenticated
|
protected static int |
BUSY
Message type for Busy message. |
protected static int |
DELETE_FILE
Message type for Delete File message. |
protected static int |
GET_ALL_FILE_INFO
Message type for Get All File Info message. |
protected static int |
GET_DATABASE_LOCK
Message type for Get Database Lock message. |
protected static int |
GET_DEVICE_INFO
Message type for Get Device Info message. |
protected static int |
GET_DEVICE_SETTINGS
Message type for Get Device Settings message. |
protected static int |
GET_FILE_INFO
Message type for Get File Info message. |
protected static int |
GET_SALT
Message type for Get Salt message. |
protected static int |
GET_STORAGE_INFO
Message type for Get Storage Info message. |
protected static int |
NAK
Message type for NAK message. |
protected static int |
PROTOCOL_VERSION
Message type for Protocol Version message. |
protected static int |
READ
Message type for Read message. |
protected boolean |
readLock
|
protected static int |
RELEASE_DATABASE_LOCK
Message type for Release Database Lock message. |
protected java.net.Socket |
saki
The socket used to communicate with the Pearl device. |
protected static int |
SET_FILE_INFO
Message type for Set File Info message. |
protected static byte[] |
signature
Protocol signature (Rio, accented, in UTF-8) |
protected static int |
WRITE
Message type for Write message. |
protected boolean |
writeLock
|
| Constructor Summary | |
PearlTCPConnection(java.net.InetAddress addr,
int port)
|
|
| Method Summary | |
void |
authenticate(java.lang.String password)
Attempts to authenticate using a given password. |
void |
close()
Closes a connection. |
void |
deleteFile(int fid)
Removes a file from the device. |
void |
getAllFileInfo(FileInfoListener target)
Retrieves all file information from the device using a callback mechanism. |
DeviceInfo |
getDeviceInfo()
Returns an object encapsulating basic device information -- number of storage devices, system software name, and firmware version. |
DeviceSettings |
getDeviceSettings()
Retrieves the Pearl device's settings as a DeviceSettings object. |
FileInfo |
getFileInfo(int fid)
Retrieves information on a single file, by FID. |
protected Message |
getMessage()
|
protected java.lang.String |
getNullTermString()
|
StorageInfo |
getStorageInfo(int idx)
Retrieves information about a storage device in the Pearl device. |
int[] |
getVersion()
Returns the version of the protocol being used as an array of two integers: the major and minor versions, respectively. |
boolean |
isAuthenticated()
Checks to see if the underlying session has been successfully authenticated. |
protected void |
lockDatabase(int lockType)
|
long |
readFileChunk(int fid,
long offset,
long size,
byte[] buffer)
Retrieves a chunk of a file into a supplied buffer. |
protected void |
sendMessage(Message m)
|
void |
setFileInfo(int fid,
FileInfo newInfo)
Updates information for a file identified by FID. |
protected void |
unlockDatabase()
|
void |
writeFileChunk(int fid,
int storageID,
long offset,
long size,
byte[] buffer)
Writes a chunk of a file from a supplied buffer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final byte[] signature
protected static final int PROTOCOL_VERSION
protected static final int NAK
protected static final int BUSY
protected static final int GET_SALT
protected static final int AUTHENTICATE
protected static final int GET_DEVICE_INFO
protected static final int GET_STORAGE_INFO
protected static final int GET_DEVICE_SETTINGS
protected static final int GET_DATABASE_LOCK
protected static final int RELEASE_DATABASE_LOCK
protected static final int WRITE
protected static final int GET_ALL_FILE_INFO
protected static final int GET_FILE_INFO
protected static final int SET_FILE_INFO
protected static final int READ
protected static final int DELETE_FILE
protected java.net.Socket saki
protected boolean authenticated
protected boolean readLock
protected boolean writeLock
| Constructor Detail |
public PearlTCPConnection(java.net.InetAddress addr,
int port)
throws java.io.IOException,
PearlException
| Method Detail |
public int[] getVersion()
throws PearlException
getVersion in interface PearlConnectionPearlExceptionpublic boolean isAuthenticated()
isAuthenticated in interface PearlConnection
public void authenticate(java.lang.String password)
throws PearlException
authenticate in interface PearlConnectionPearlException
public DeviceInfo getDeviceInfo()
throws PearlException
getDeviceInfo in interface PearlConnectionPearlException
public StorageInfo getStorageInfo(int idx)
throws PearlException
getStorageInfo in interface PearlConnectionPearlException
public DeviceSettings getDeviceSettings()
throws PearlException
getDeviceSettings in interface PearlConnectionPearlException
public void getAllFileInfo(FileInfoListener target)
throws PearlException
getAllFileInfo in interface PearlConnectionPearlException
public FileInfo getFileInfo(int fid)
throws PearlException
getFileInfo in interface PearlConnectionPearlException
public void setFileInfo(int fid,
FileInfo newInfo)
throws PearlException
setFileInfo in interface PearlConnectionPearlException
public void writeFileChunk(int fid,
int storageID,
long offset,
long size,
byte[] buffer)
throws PearlException
writeFileChunk in interface PearlConnectionfid - The FID of the file to write.storageID - The index of the storage device to write to.offset - The offset within the file to begin writing.size - The number of bytes to be written.buffer - The buffer from which bytes are sent.
PearlException
public long readFileChunk(int fid,
long offset,
long size,
byte[] buffer)
throws PearlException
readFileChunk in interface PearlConnectionfid - The FID of the file to read.offset - The offset within the file to begin reading.size - The number of bytes desired. If the end of the file is
encountered, this will be fewer than were requested.buffer - The buffer into which bytes are copied.
PearlException
public void deleteFile(int fid)
throws PearlException
deleteFile in interface PearlConnectionPearlExceptionpublic void close()
PearlConnection
close in interface PearlConnection
protected void lockDatabase(int lockType)
throws PearlException
PearlException
protected void unlockDatabase()
throws PearlException
PearlException
protected void sendMessage(Message m)
throws java.io.IOException
java.io.IOException
protected Message getMessage()
throws java.io.IOException
java.io.IOException
protected java.lang.String getNullTermString()
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||