|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.server.StyxFile
uk.ac.rdg.resc.jstyx.server.StyxDirectory
public class StyxDirectory
Class representing a directory on a Styx server. One would only rarely need to create subclasses of this; an example would be creating a StyxDirectory that represents a directory on the host filesystem (see DirectoryOnDisk).
| Field Summary |
|---|
| Fields inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile |
|---|
auth, directory, lastModifiedTime, name, parent |
| Constructor Summary | |
|---|---|
StyxDirectory(java.lang.String name)
Creates a directory with default permissions (0777, rwxrwxrwx) |
|
StyxDirectory(java.lang.String name,
int permissions)
Creates a directory with the given permissions |
|
StyxDirectory(java.lang.String name,
java.lang.String owner,
java.lang.String group,
int permissions)
Creates a new instance of StyxDirectory |
|
| Method Summary | |
|---|---|
StyxDirectory |
addChild(StyxFile sf)
Adds a file to this directory. |
void |
checkSetLength(ULong newLength)
This method is overridden to return a more meaningful error message. |
boolean |
childExists(java.lang.String name)
|
StyxFile |
createChild(java.lang.String name,
int perm,
boolean isDir,
boolean isAppOnly,
boolean isExclusive)
Creates a new file to be added to this directory. |
StyxFile |
getChild(java.lang.String name)
Gets the child with the given name or null if it does not exist |
StyxFile[] |
getChildren()
Gets all the direct descendants of this directory |
java.lang.String |
getFullPath()
Gets the full path relative to the root of this file system, or a single slash if this is the root directory. |
ULong |
getLength()
|
java.lang.String |
getName()
|
int |
getNumChildren()
Gets the number of direct descendants of this directory |
StyxDirectory |
getParent()
Returns the parent of this directory. |
boolean |
isRoot()
|
void |
read(StyxFileClient client,
long offset,
int count,
int tag)
Returns the directory contents. |
void |
refresh()
Refreshes this file (if it represents another entity, such as a file on disk, this method is used to make sure that the file metadata (length, access time etc) are up to date. |
protected void |
refresh(boolean updateChildren)
|
void |
remove()
Removes this directory from the server. |
void |
removeAllChildren()
Recursively removes all children from this directory. |
void |
removeChild(StyxFile child)
Removes the given file from this directory. |
void |
write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
This always throws a StyxException as it is illegal to write to a directory |
| Methods inherited from class uk.ac.rdg.resc.jstyx.server.StyxFile |
|---|
addChangeListener, addClient, checkSetLastModifiedTime, checkSetMode, checkSetName, clientConnected, clientDisconnected, contentsChanged, delete, fireContentsChanged, getClient, getDirEntry, getGroup, getNumClients, getOwner, getPermissions, getQid, getVersion, incrementVersion, isAppendOnly, isAuth, isDirectory, isExclusive, processAndReplyRead, processAndReplyRead, processAndReplyRead, 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 |
|---|
public StyxDirectory(java.lang.String name,
java.lang.String owner,
java.lang.String group,
int permissions)
throws StyxException
StyxException
public StyxDirectory(java.lang.String name)
throws StyxException
StyxException
public StyxDirectory(java.lang.String name,
int permissions)
throws StyxException
StyxException| Method Detail |
|---|
public void checkSetLength(ULong newLength)
throws StyxException
checkSetLength in class StyxFileStyxExceptionpublic boolean isRoot()
public java.lang.String getFullPath()
getFullPath in class StyxFilepublic java.lang.String getName()
getName in class StyxFile
public final void read(StyxFileClient client,
long offset,
int count,
int tag)
throws StyxException
read in class StyxFileclient - 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())
StyxException
public void write(StyxFileClient client,
long offset,
int count,
org.apache.mina.common.ByteBuffer data,
boolean truncate,
int tag)
throws StyxException
write in class StyxFileclient - 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())
StyxExceptionpublic final ULong getLength()
getLength in class StyxFilepublic void refresh()
refresh in class StyxFileprotected void refresh(boolean updateChildren)
updateChildren - If this is set true, this method will also refresh
all the immediate children of this directory. This default method does
nothing; subclasses must override this.public StyxFile[] getChildren()
public int getNumChildren()
public StyxDirectory addChild(StyxFile sf)
throws uk.ac.rdg.resc.jstyx.server.FileExistsException
StyxDirectory root = new StyxDirectory().addChild(file1).addChile(file2)
uk.ac.rdg.resc.jstyx.server.FileExistsExceptionpublic boolean childExists(java.lang.String name)
public StyxFile createChild(java.lang.String name,
int perm,
boolean isDir,
boolean isAppOnly,
boolean isExclusive)
throws StyxException
StyxExceptionpublic void removeChild(StyxFile child)
public void remove()
throws StyxException
remove in class StyxFileStyxException - if this is the root directory, or if it is not emptypublic void removeAllChildren()
public StyxFile getChild(java.lang.String name)
public final StyxDirectory getParent()
getParent in class StyxFile
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||