uk.ac.rdg.resc.jstyx.server
Class URLFile
java.lang.Object
uk.ac.rdg.resc.jstyx.server.StyxFile
uk.ac.rdg.resc.jstyx.server.URLFile
public class URLFile
- extends StyxFile
StyxFile that contains a URL.
- Author:
- Jon Blower
$Revision: 609 $
$Date: 2006-03-31 18:09:42 +0100 (Fri, 31 Mar 2006) $
$Log$
Revision 1.3 2005/11/07 21:14:44 jonblower
Fixed null pointer bug in getLength()
Revision 1.2 2005/11/07 12:22:25 jonblower
Added getLength() method
Revision 1.1 2005/11/04 17:32:11 jonblower
Initial import
|
Constructor Summary |
URLFile(java.lang.String name)
Creates a new instance of URLFile with read-write permissions for everyone
(0666). |
|
Method Summary |
ULong |
getLength()
|
java.net.URL |
getURL()
|
void |
read(StyxFileClient client,
long offset,
int count,
int tag)
Reads data from this file. |
void |
write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
The new value for the URL must come in a single message (i.e. |
| Methods inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile |
addChangeListener, addClient, checkSetLastModifiedTime, checkSetLength, checkSetMode, checkSetName, clientConnected, clientDisconnected, contentsChanged, delete, fireContentsChanged, getClient, getDirEntry, getFullPath, getGroup, getName, getNumClients, getOwner, getParent, getPermissions, getQid, getVersion, incrementVersion, isAppendOnly, isAuth, isDirectory, isExclusive, processAndReplyRead, processAndReplyRead, processAndReplyRead, refresh, remove, removeChangeListener, removeClient, rename, replyRead, replyRead, replyRead, replyRead, replyRead, replyWrite, setLastAccessTime, setLastModified, setLength, setMode, setName, setPermissions, setReadOnly |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
URLFile
public URLFile(java.lang.String name)
throws StyxException
- Creates a new instance of URLFile with read-write permissions for everyone
(0666).
- Throws:
StyxException
read
public void read(StyxFileClient client,
long offset,
int count,
int tag)
throws StyxException
- Description copied from class:
StyxFile
- Reads data from this file. This method could be synchronized in subclasses,
but watch out for blocks if the read is expected to take some time to
complete. Subclasses must make sure they reply to the read request by
creating a java.nio.ByteBuffer or byte array of data, then calling the
appropriate readReply() (this can be done at any time; it does not have
to be done within the read() method).
This default implementation simply throws a StyxException, which will
result in an Rerror message being sent back to the client. Subclasses
should override this to provide the desired behaviour when the file is
read.
- Overrides:
read in class StyxFile
- Parameters:
client - The client that is performing the readoffset - The point in the file at which to start readingcount - The maximum number of bytes to readtag - The tag of the incoming Tread message (this is needed when
calling readReply())
- Throws:
StyxException
write
public void write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
throws StyxException
- The new value for the URL must come in a single message (i.e.
the offset must be zero and the incoming ByteBuffer must contain the
entire URL). Must also write with truncation.
- Overrides:
write in class StyxFile
- Parameters:
client - The client that is performing the write operationoffset - The place in the file where the new data will be addedcount - The number of bytes to writedata - The data to write. The position and limit of this ByteBuffer
will be set correctly, but subclasses should note that the position might
not be zero.truncate - If this is true the file will be truncated at the end of
the new datatag - The tag of the incoming Twrite message (this is needed when
calling writeReply())
- Throws:
StyxException
getLength
public ULong getLength()
- Overrides:
getLength in class StyxFile
- Returns:
- the size of this file in bytes
getURL
public java.net.URL getURL()
- Returns:
- the URL contained in this file or null if it hasn't been set
Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.