edu.sdsc.grid.io.srb
Class SRBShadowFile

java.lang.Object
  extended by edu.sdsc.grid.io.GeneralRandomAccessFile
      extended by edu.sdsc.grid.io.RemoteRandomAccessFile
          extended by edu.sdsc.grid.io.srb.SRBRandomAccessFile
              extended by edu.sdsc.grid.io.srb.SRBShadowFile
All Implemented Interfaces:
java.io.DataInput, java.io.DataOutput

public class SRBShadowFile
extends SRBRandomAccessFile

If the SRBShadowFile refers to a file, this class can obtain input bytes from a shadow file in a SRB file system. This SRBShadowFile can also represent a shadow directory.

Since:
JARGON1.4

Field Summary
 
Fields inherited from class edu.sdsc.grid.io.GeneralRandomAccessFile
fd, file, fileFormat, isClosed, mode, rw, SEEK_CURRENT, SEEK_END, SEEK_START, swapNeeded
 
Constructor Summary
SRBShadowFile(SRBFile file, java.lang.String shadowPath)
          Creates a random access file stream to read from, a shadow file object with the specified name.
SRBShadowFile(SRBShadowFile parent, java.lang.String child)
          Creates a random access file stream to read from, a shadow file object with the specified name.
 
Method Summary
 java.lang.String getShadowPath()
           
 SRBFile getSRBFile()
           
 long length()
          Returns the length of this file.
 java.lang.String[] list()
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
 SRBShadowFile[] listFiles()
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
protected  void open(GeneralFile file)
          Opens the given file for use by this stream.
 void setLength(long newLength)
          Sets the length of this file.
 java.lang.String toString()
           
 
Methods inherited from class edu.sdsc.grid.io.srb.SRBRandomAccessFile
close, finalize, getFilePointer, getFileSystem, read, readBytes, seek, setFileSystem, writeBytes
 
Methods inherited from class edu.sdsc.grid.io.GeneralRandomAccessFile
getBinaryDataFormat, getFD, getFile, isClosed, read, read, readBoolean, readBooleans, readByte, readChar, readDouble, readDoubles, readFloat, readFloats, readFully, readFully, readInt, readInts, readLine, readLong, readLongDouble, readLongDoubles, readLongLong, readLongLongs, readLongs, readShort, readShorts, readUnsignedByte, readUnsignedInt, readUnsignedInts, readUnsignedLong, readUnsignedLongLong, readUnsignedLongLongs, readUnsignedLongs, readUnsignedShort, readUnsignedShorts, readUTF, rwCheck, seek, setBinaryDataFormat, skipBytes, write, write, write, write, writeBoolean, writeBooleans, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeLong, writeLongDouble, writeLongDoubles, writeLongLong, writeLongLongs, writeLongs, writeShort, writeShorts, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SRBShadowFile

public SRBShadowFile(SRBFile file,
                     java.lang.String shadowPath)
              throws java.lang.IllegalArgumentException,
                     java.io.FileNotFoundException,
                     java.lang.SecurityException,
                     java.io.IOException
Creates a random access file stream to read from, a shadow file object with the specified name. A new file descriptor is obtained from the SRB which represents the connection to the file.

On construction a check is made to see if read access to the file is allowed.

Parameters:
file - the SRB abstract filepath
shadowPath - the shadow path
Throws:
java.io.IOException - If an I/O error occurs
java.io.FileNotFoundException - If the file exists but is a regular file rather than a shadow object, or cannot be opened for any other reason.
java.lang.SecurityException - If denied read access to the file.
java.lang.IllegalArgumentException

SRBShadowFile

public SRBShadowFile(SRBShadowFile parent,
                     java.lang.String child)
              throws java.lang.IllegalArgumentException,
                     java.io.FileNotFoundException,
                     java.lang.SecurityException,
                     java.io.IOException
Creates a random access file stream to read from, a shadow file object with the specified name. A new file descriptor is obtained from the SRB which represents the connection to the file.

On construction a check is made to see if read access to the file is allowed.

Parameters:
parent - a parent abstract shadow filepath
child - the child shadow path
Throws:
java.io.IOException - If an I/O error occurs
java.io.FileNotFoundException - If the file exists but is a regular file rather than a shadow object, or cannot be opened for any other reason.
java.lang.SecurityException - If denied read access to the file.
java.lang.IllegalArgumentException
Method Detail

open

protected void open(GeneralFile file)
             throws java.io.IOException
Opens the given file for use by this stream.

Overrides:
open in class SRBRandomAccessFile
Parameters:
file - the file to open
Throws:
java.io.IOException - if an I/O error occurs.

getSRBFile

public SRBFile getSRBFile()

getShadowPath

public java.lang.String getShadowPath()

length

public long length()
            throws java.io.IOException
Returns the length of this file.

Overrides:
length in class SRBRandomAccessFile
Returns:
the length of this file, measured in bytes.
Throws:
java.io.IOException - if an I/O error occurs.

setLength

public void setLength(long newLength)
               throws java.io.IOException
Sets the length of this file.

Truncating a file on the SRB Shadow Fileis not supported, so an UnsupportedOperationException will be thrown. (If the present length of the file as returned by the length method is greater than the newLength argument then the file will be truncated. In this case, if the file offset as returned by the getFilePointer method is greater then newLength then after this method returns the offset will be equal to newLength.)

If the present length of the file as returned by the length method is smaller than the newLength argument then the file will be extended. In this case, the contents of the extended portion of the file are not defined.

Overrides:
setLength in class SRBRandomAccessFile
Parameters:
newLength - The desired length of the file
Throws:
java.io.IOException - If an I/O error occurs
java.lang.UnsupportedOperationException - on truncate

toString

public java.lang.String toString()
Overrides:
toString in class GeneralRandomAccessFile

list

public java.lang.String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

This method will return all the files in the directory. Listing directories with a large number of files may take a very long time.

Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if an I/O error occurs.

listFiles

public SRBShadowFile[] listFiles()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

This method will return all the files in the directory. Listing directories with a large number of files may take a very long time.

Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if an I/O error occurs.