|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.client.CStyxFile
public class CStyxFile
A Styx file (or directory) from the point of view of the client. (It is called a CStyxFile in order to avoid confusion with the server-side StyxFile class.) To create a CStyxFile, open a StyxConnection and use the getFile() method. CStyxFiles cannot be created directly.
| Method Summary | |
|---|---|
void |
addChangeListener(CStyxFileChangeListener listener)
Adds a CStyxFileChangeListener to this file. |
void |
close()
Closes the file (i.e. |
void |
createAsync(boolean isDirectory,
int permissions,
int mode,
MessageCallback callback)
Creates this file on the remote server, provided that its parent directory exists. |
void |
download(java.io.File file)
Downloads the data from this file and writes to a local java.io.File. |
void |
download(java.io.File file,
int numRequests)
Downloads the data from this file and writes to a local java.io.File. |
void |
downloadAsync(java.io.File file)
Downloads the data from this file and writes to a local java.io.File. |
void |
downloadAsync(java.io.File file,
int numRequests)
Downloads the data from this file and writes to a local java.io.File. |
void |
downloadAsync(java.io.File file,
int numRequests,
MessageCallback callback)
Downloads the data from this file and writes to a local java.io.File. |
void |
downloadAsync(java.io.File file,
MessageCallback callback)
Downloads the data from this file and writes to a local java.io.File. |
boolean |
exists()
Tests to see if this file exists on the server, returning true if so and false if not. |
void |
fireChildrenFound()
Fires the childrenFound() method on all registered listeners |
void |
fireCreated()
Fires the fileCreated() method on all registered listeners |
void |
fireDataArrived(TreadMessage tReadMsg,
RreadMessage rReadMsg)
Fires the dataArrived() method on all registered listeners |
void |
fireDataWritten(TwriteMessage tWriteMsg)
Fires the dataWritten() method on all registered listeners |
void |
fireDownloadComplete()
Fires the downloadComplete() method on all registered listeners |
void |
fireError(java.lang.String message)
Fires the error() method on all registered listeners |
void |
fireOpen()
Fires the fileOpen() method on all registered listeners |
void |
fireStatChanged(RstatMessage rStatMsg)
Fires the statChanged() method on all registered listeners |
void |
fireUploadComplete()
Fires the uploadComplete() method on all registered listeners |
CStyxFile[] |
getChildren()
Gets all the children of this directory. |
void |
getChildrenAsync()
Reads this directory to get all its children. |
StyxConnection |
getConnection()
|
java.lang.String |
getContents()
Reads the entire contents of the file and returns them as a String. |
DirEntry |
getDirEntry()
|
long |
getFid()
|
CStyxFile |
getFile(java.lang.String path)
Gets a reference to a file on the same connection as this CStyxFile. |
java.lang.String |
getGroup()
|
int |
getIoUnit()
|
java.util.Date |
getLastModified()
|
long |
getLength()
|
static org.apache.log4j.Logger |
getLogger()
|
int |
getMode()
|
java.lang.String |
getName()
Gets the name of the file, i.e. |
java.lang.String |
getOwner()
|
java.lang.String |
getParentPath()
Gets the full path of the parent of this file |
java.lang.String |
getPath()
Gets the full path of the file |
Qid |
getQid()
|
java.lang.String |
getURL()
|
boolean |
hasFid()
|
boolean |
isAuth()
|
boolean |
isDirectory()
|
boolean |
isOpen()
|
boolean |
isSameFile(CStyxFile otherFile)
Returns true if this CStyxFile represents the same file on the server as the CStyxFile passed in the argument. |
static void |
main(java.lang.String[] args)
|
void |
open(int mode)
Opens the file on the server, i.e. |
void |
openAsync(int mode)
Opens the file on the server. |
void |
openAsync(int mode,
MessageCallback callback)
Opens the file on the server. |
CStyxFile |
openFile(java.lang.String path,
int mode)
Gets a file on the same connection as this CStyxFile, then opens it. |
void |
openOrCreate(boolean isDirectory,
int mode)
Opens or creates this file: if the file exists it will be opened with the given mode. |
void |
openOrCreateAsync(boolean isDirectory,
int mode,
MessageCallback callback)
Opens or creates this file: if the file exists it will be opened with the given mode. |
org.apache.mina.common.ByteBuffer |
read(long offset)
Reads a chunk of data from the file. |
void |
readAsync(long offset)
Reads a chunk of data from the file. |
void |
readAsync(long offset,
boolean openForWriting)
Reads a chunk of data from the file. |
void |
readAsync(long offset,
int bytesRequired,
boolean openForWriting,
MessageCallback callback)
Reads a chunk of data from the file. |
void |
readAsync(long offset,
int bytesRequired,
MessageCallback callback)
Reads a chunk of data from the file. |
void |
readAsync(long offset,
MessageCallback callback)
Reads a chunk of data from the file. |
void |
refresh()
Refreshes the stat (DirEntry) of the file. |
void |
refreshAsync()
Refreshes the status of the file by sending a TStatMessage. |
void |
refreshAsync(MessageCallback callback)
Refreshes the status of the file by sending a TstatMessage. |
void |
removeChangeListener(CStyxFileChangeListener listener)
Removes the given change listener |
void |
setChildren(CStyxFile[] children)
Sets the children of this file. |
void |
setContents(java.lang.String str)
Sets the contents of the file to the given string. |
void |
setDirEntry(DirEntry dirEntry)
Sets the dirEntry of this file. |
void |
setFid(long newFid)
Sets the fid of the file. |
void |
setIoUnit(int newIoUnit)
Sets the maximum number of bytes that can be read from or written to this file in a single operation. |
void |
setMode(int newMode)
Set the mode of this file: this should not normally be called, except by the OpenCallback, when the file has been open |
void |
setQid(Qid newQid)
Sets the qid of the file. |
java.lang.String |
toString()
|
void |
upload(java.io.File fromFile)
Uploads data from an local file to this file. |
void |
upload(java.io.InputStream in)
Uploads data from an InputStream to this file. |
void |
uploadAsync(java.io.File file)
Uploads data from a local java.io.File to this file. |
void |
uploadAsync(java.io.File file,
MessageCallback callback)
Uploads data from a local java.io.File to this file. |
void |
uploadAsync(java.io.InputStream in)
Uploads data from an InputStream to this file. |
void |
uploadAsync(java.io.InputStream in,
MessageCallback callback)
Uploads data from an InputStream to this file. |
void |
walkFid()
Gets a new fid from the pool and walks it to the location of this file. |
void |
walkFidAsync(MessageCallback callback)
Gets a new fid from the pool and walks it to the location of this file. |
long |
write(byte[] bytes,
int pos,
int count,
long offset,
boolean truncate)
Writes a block of data to the file at the given offset. |
long |
write(byte[] bytes,
long offset,
boolean truncate)
Writes a block of data to the file at the given offset. |
void |
writeAll(byte[] bytes,
long offset)
Writes a block of data to the file at the given offset. |
void |
writeAsync(byte[] bytes,
int pos,
int count,
long offset,
boolean truncate,
MessageCallback callback)
Writes a chunk of data to the file at the given file offset. |
void |
writeAsync(byte[] bytes,
long offset,
boolean truncate)
Writes a chunk of data to the file at the given file offset. |
void |
writeAsync(byte[] bytes,
long offset,
boolean truncate,
MessageCallback callback)
Writes a chunk of data to the file at the given file offset. |
void |
writeAsync(java.lang.String str,
long offset)
Writes a string to the file at the given offset, with truncation. |
void |
writeAsync(java.lang.String str,
long offset,
MessageCallback callback)
Writes a string to the file at the given offset, with truncation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public StyxConnection getConnection()
public java.lang.String getName()
public java.lang.String getPath()
public java.lang.String getParentPath()
public java.lang.String getURL()
public boolean isDirectory()
throws StyxException
StyxExceptionpublic boolean isAuth()
public java.lang.String getOwner()
throws StyxException
StyxException
public java.lang.String getGroup()
throws StyxException
StyxException
public long getLength()
throws StyxException
StyxException
public java.util.Date getLastModified()
throws StyxException
StyxExceptionpublic DirEntry getDirEntry()
public void setDirEntry(DirEntry dirEntry)
public boolean hasFid()
public long getFid()
public void setMode(int newMode)
public int getMode()
public void setFid(long newFid)
public void setQid(Qid newQid)
public Qid getQid()
public boolean isOpen()
public boolean isSameFile(CStyxFile otherFile)
throws StyxException
StyxException - if the dirEntry of one of the files was not set and
there was an error getting the file's stat. If you know that the dirEntry
of both files is already set, you can safely ignore this exception.public void setIoUnit(int newIoUnit)
public int getIoUnit()
public void setChildren(CStyxFile[] children)
public static org.apache.log4j.Logger getLogger()
public void walkFidAsync(MessageCallback callback)
public void walkFid()
throws StyxException
StyxException - if there was an error walking the fid (i.e. the
file does not exist)public boolean exists()
public void open(int mode)
throws StyxException
mode - Integer representing the mode - see the constants in StyxUtils.
For example, to open a file for reading, use StyxUtils.OREAD. To open a
file for writing with truncation use StyxUtils.OWRITE | StyxUtils.OTRUNC.
StyxExceptionpublic void openAsync(int mode)
mode - Integer representing the mode - see the constants in StyxUtils.
For example, to open a file for reading, use StyxUtils.OREAD. To open a
file for writing with truncation use StyxUtils.OWRITE | StyxUtils.OTRUNC.
java.lang.IllegalStateException - if the file is already open
public void openAsync(int mode,
MessageCallback callback)
mode - Integer representing the mode - see the constants in StyxUtils.
For example, to open a file for reading, use StyxUtils.OREAD. To open a
file for writing with truncation use StyxUtils.OWRITE | StyxUtils.OTRUNC.callback - The MessageCallback object that will handle the Ropen message
public void createAsync(boolean isDirectory,
int permissions,
int mode,
MessageCallback callback)
public void openOrCreateAsync(boolean isDirectory,
int mode,
MessageCallback callback)
public void openOrCreate(boolean isDirectory,
int mode)
throws StyxException
StyxExceptionpublic void close()
public org.apache.mina.common.ByteBuffer read(long offset)
throws StyxException
StyxExceptionpublic void readAsync(long offset)
public void readAsync(long offset,
boolean openForWriting)
offset - The index of the first byte of data in the file to readopenForWriting - If this is true, the file will be opened for reading
and writing with truncation, provided that the file is not open already.
If this is false, the file will be opened for reading only
public void readAsync(long offset,
MessageCallback callback)
public void readAsync(long offset,
int bytesRequired,
MessageCallback callback)
offset - The index of the first byte of data in the file to readbytesRequired - The maximum number of bytes requiredcallback - The class that will be notified if the read was successful,
or if there was an error
public void readAsync(long offset,
int bytesRequired,
boolean openForWriting,
MessageCallback callback)
offset - The index of the first byte of data in the file to readbytesRequired - The maximum number of bytes requiredopenForWriting - If this is true, the file will be opened for reading
and writing with truncation, provided that the file is not open already.
If this is false, the file will be opened for reading onlycallback - The class that will be notified if the read was successful,
or if there was an error
public java.lang.String getContents()
throws StyxException
StyxException
public void setContents(java.lang.String str)
throws StyxException
str - The new file contents
StyxException - if there was an error opening or writing to the file
public void writeAll(byte[] bytes,
long offset)
throws StyxException
StyxException - if there is an error writing to the file
public long write(byte[] bytes,
long offset,
boolean truncate)
throws StyxException
bytes - The data to write. Will attempt to write all the data in this array.offset - The position in the file at which to write the datatruncate - True if the file is to be truncated at the end of the
new data
StyxException - if there is an error writing to the file
public long write(byte[] bytes,
int pos,
int count,
long offset,
boolean truncate)
throws StyxException
bytes - The data to write.pos - The index of the first data point in the byte array to writecount - The number of bytes from the input array to writeoffset - The position in the file at which to write the datatruncate - True if the file is to be truncated at the end of the
new data
StyxException - if there is an error writing to the file
public void writeAsync(java.lang.String str,
long offset)
public void writeAsync(java.lang.String str,
long offset,
MessageCallback callback)
public void writeAsync(byte[] bytes,
long offset,
boolean truncate)
bytes - The byte array containing the data to write. This will attempt to
write all the data in the arrayoffset - The position in the file at which the data will be writtentruncate - True if the file should be truncated at the end of the new data
public void writeAsync(byte[] bytes,
long offset,
boolean truncate,
MessageCallback callback)
bytes - The array of bytes to writeoffset - The position in the file at which the data will be writtentruncate - If this is true, the file will be truncated at the end
of the new datacallback - The replyArrived() method of this callback object will be
called when the write confirmation arrives
public void writeAsync(byte[] bytes,
int pos,
int count,
long offset,
boolean truncate,
MessageCallback callback)
bytes - The array of bytes to writepos - The position in the array of the first byte to writecount - The number of bytes from the byte array to writeoffset - The position in the file at which the data will be writtentruncate - If this is true, the file will be truncated at the end
of the new datacallback - The replyArrived() method of this callback object will be
called when the write confirmation arrives
public void refresh()
throws StyxException
StyxExceptionpublic void refreshAsync()
public void refreshAsync(MessageCallback callback)
public CStyxFile getFile(java.lang.String path)
path - The path of the file to be opened, relative to this file.
InvalidPathException - if the path is not valid
public CStyxFile openFile(java.lang.String path,
int mode)
throws StyxException
path - The path of the file to be opened, relative to this file.mode - The mode with which to open the file
StyxException - if the file could not be opened with the given mode
public CStyxFile[] getChildren()
throws StyxException
StyxExceptionpublic void getChildrenAsync()
public void download(java.io.File file)
throws StyxException
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten. If this is null, the data
will be downloaded but not written to a file
StyxException
public void download(java.io.File file,
int numRequests)
throws StyxException
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten. If this is null, the data
will be downloaded but not written to a filenumRequests - The number of simultaneous read requests that will be
sent. The download may proceed faster with a larger number of simultaneous
read requests. If numRequests > 1, the file on the remote server must
be seekable otherwise unpredictable behaviour may result.
StyxException
public void downloadAsync(java.io.File file,
int numRequests)
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten.numRequests - The number of simultaneous read requests that will be
sent. The download may proceed faster with a larger number of simultaneous
read requests. If numRequests > 1, the file on the remote server must
be seekable otherwise unpredictable behaviour may result.public void downloadAsync(java.io.File file)
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten.
public void downloadAsync(java.io.File file,
MessageCallback callback)
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten.
public void downloadAsync(java.io.File file,
int numRequests,
MessageCallback callback)
file - The java.io.File to which the data will be written. If this
file already exists it will be overwritten.numRequests - The number of simultaneous read requests that will be
sent. The download may proceed faster with a larger number of simultaneous
read requests. If numRequests > 1, the file on the remote server must
be seekable otherwise unpredictable behaviour may result.
java.lang.IllegalArgumentException - if numRequests is less than 1 or greater
than 100.
public void upload(java.io.InputStream in)
throws StyxException
in - The InputStream from which to read data to be written to this file
StyxException
public void upload(java.io.File fromFile)
throws StyxException
fromFile - The File from which to read data to be written to this file
StyxExceptionpublic void uploadAsync(java.io.InputStream in)
in - The InputStream from which to read data to be written to this file
public void uploadAsync(java.io.InputStream in,
MessageCallback callback)
in - The InputStream from which to read data to be written to this filecallback - The MessageCallback that will be notified when the
upload process is complete.public void uploadAsync(java.io.File file)
file - The File to copy/upload
public void uploadAsync(java.io.File file,
MessageCallback callback)
file - The File to copy/uploadcallback - The MessageCallback that will be notified when the
upload process is complete.public void addChangeListener(CStyxFileChangeListener listener)
public void removeChangeListener(CStyxFileChangeListener listener)
public void fireError(java.lang.String message)
public void fireOpen()
public void fireCreated()
public void fireDataArrived(TreadMessage tReadMsg,
RreadMessage rReadMsg)
public void fireStatChanged(RstatMessage rStatMsg)
public void fireDataWritten(TwriteMessage tWriteMsg)
public void fireChildrenFound()
public void fireUploadComplete()
public void fireDownloadComplete()
public java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||