uk.ac.rdg.resc.jstyx.gridservice.server
Class SGSInputFile.File

java.lang.Object
  extended by uk.ac.rdg.resc.jstyx.server.StyxFile
      extended by uk.ac.rdg.resc.jstyx.gridservice.server.SGSInputFile
          extended by uk.ac.rdg.resc.jstyx.gridservice.server.SGSInputFile.File
Enclosing class:
SGSInputFile

public static class SGSInputFile.File
extends SGSInputFile


Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.rdg.resc.jstyx.gridservice.server.SGSInputFile
SGSInputFile.File, SGSInputFile.StdinFile
 
Field Summary
 
Fields inherited from class uk.ac.rdg.resc.jstyx.gridservice.server.SGSInputFile
candidateURL, candidateURLBuffer, candidateURLLength, dataWritten, instance, url
 
Fields inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile
auth, directory, lastModifiedTime, name, parent
 
Constructor Summary
SGSInputFile.File(java.io.File file, uk.ac.rdg.resc.jstyx.gridservice.server.StyxGridServiceInstance instance)
           
 
Method Summary
protected  void closeOutput()
          Closes the output file or stream.
 boolean dataUploadComplete()
           
 ULong getLength()
           
 void write(StyxFileClient client, long offset, int count, org.apache.mina.common.ByteBuffer data, boolean truncate, int tag)
          Writes data to this file.
protected  void writeData(StyxFileClient client, long offset, int count, org.apache.mina.common.ByteBuffer data, boolean truncate, int tag)
          This just writes the data to the underlying fileOnDisk
 
Methods inherited from class uk.ac.rdg.resc.jstyx.gridservice.server.SGSInputFile
getURL, setURL, write2
 
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, read, 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
 

Constructor Detail

SGSInputFile.File

public SGSInputFile.File(java.io.File file,
                         uk.ac.rdg.resc.jstyx.gridservice.server.StyxGridServiceInstance instance)
                  throws StyxException
Throws:
StyxException
Method Detail

closeOutput

protected void closeOutput()
                    throws java.io.IOException
Description copied from class: SGSInputFile
Closes the output file or stream. This default implementation does nothing

Specified by:
closeOutput in class SGSInputFile
Throws:
java.io.IOException

writeData

protected void writeData(StyxFileClient client,
                         long offset,
                         int count,
                         org.apache.mina.common.ByteBuffer data,
                         boolean truncate,
                         int tag)
                  throws StyxException,
                         java.io.IOException
This just writes the data to the underlying fileOnDisk

Specified by:
writeData in class SGSInputFile
Throws:
StyxException
java.io.IOException

write

public void write(StyxFileClient client,
                  long offset,
                  int count,
                  org.apache.mina.common.ByteBuffer data,
                  boolean truncate,
                  int tag)
           throws StyxException
Description copied from class: StyxFile
Writes data to this file. Must check that the file is open for writing before this. We have already dealt with the possibility that this is an append-only file before calling this method so subclasses do not need to check this. Subclasses must make sure they reply to the write request by calling writeReply() (although this can be done at any time; it does not have to be done within the write() method). After this method is called, ByteBuffer containing the data will be returned to the pool. If subclasses wish to keep the ByteBuffer after this method is complete, they should call data.acquire() to increase the reference count to the buffer. 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 written to.

Overrides:
write in class StyxFile
Parameters:
client - The client that is performing the write operation
offset - The place in the file where the new data will be added
count - The number of bytes to write
data - 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 data
tag - The tag of the incoming Twrite message (this is needed when calling writeReply())
Throws:
StyxException

dataUploadComplete

public boolean dataUploadComplete()
Returns:
true if we have received an EOF message (an empty write message)

getLength

public ULong getLength()
Overrides:
getLength in class StyxFile
Returns:
the length of the underlying file on disk


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.