net.jxta.search.resolver.io
Class Directory

java.lang.Object
  |
  +--net.jxta.search.resolver.io.Directory
Direct Known Subclasses:
FSDirectory, RAMDirectory

public abstract class Directory
extends java.lang.Object

A Directory is a flat list of files. Files may be written once, when they are created. Once a file is created it may only be opened for read, or deleted. Random access is permitted when reading and writing.


Constructor Summary
Directory()
           
 
Method Summary
abstract  void close()
          Closes the store.
abstract  Output createFile(java.lang.String name)
          Creates a new, empty file in the directory with the given name.
abstract  void deleteFile(java.lang.String name)
          Removes an existing file in the directory.
abstract  boolean fileExists(java.lang.String name)
          Returns true iff a file with the given name exists.
abstract  long fileLength(java.lang.String name)
          Returns the length of a file in the directory.
abstract  long fileModified(java.lang.String name)
          Returns the time the named file was last modified.
abstract  java.lang.String[] list()
          Returns an array of strings, one for each file in the directory.
abstract  Input openFile(java.lang.String name)
          Returns a stream reading an existing file.
 int[] readVIntFile(java.lang.String fileName, boolean deltaDecode)
          Utility to read an int array from a file.
 long[] readVLongFile(java.lang.String fileName, boolean deltaDecode)
          Utility to read a long array from a file.
abstract  void renameFile(java.lang.String from, java.lang.String to)
          Renames an existing file in the directory.
 void writeVIntFile(int[] ints, int length, java.lang.String fileName, boolean deltaEncode)
          Utility to write an int array to a file.
 void writeVLongFile(long[] longs, int length, java.lang.String fileName, boolean deltaEncode)
          Utility to write a long array to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Directory

public Directory()
Method Detail

list

public abstract java.lang.String[] list()
                                 throws java.io.IOException,
                                        java.lang.SecurityException
Returns an array of strings, one for each file in the directory.

fileExists

public abstract boolean fileExists(java.lang.String name)
                            throws java.io.IOException,
                                   java.lang.SecurityException
Returns true iff a file with the given name exists.

fileModified

public abstract long fileModified(java.lang.String name)
                           throws java.io.IOException,
                                  java.lang.SecurityException
Returns the time the named file was last modified.

deleteFile

public abstract void deleteFile(java.lang.String name)
                         throws java.io.IOException,
                                java.lang.SecurityException
Removes an existing file in the directory.

renameFile

public abstract void renameFile(java.lang.String from,
                                java.lang.String to)
                         throws java.io.IOException,
                                java.lang.SecurityException
Renames an existing file in the directory. If a file already exists with the new name, then it is replaced. This replacement should be atomic.

fileLength

public abstract long fileLength(java.lang.String name)
                         throws java.io.IOException,
                                java.lang.SecurityException
Returns the length of a file in the directory.

createFile

public abstract Output createFile(java.lang.String name)
                           throws java.io.IOException,
                                  java.lang.SecurityException
Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

openFile

public abstract Input openFile(java.lang.String name)
                        throws java.io.IOException,
                               java.lang.SecurityException
Returns a stream reading an existing file.

close

public abstract void close()
                    throws java.io.IOException,
                           java.lang.SecurityException
Closes the store.

writeVIntFile

public void writeVIntFile(int[] ints,
                          int length,
                          java.lang.String fileName,
                          boolean deltaEncode)
                   throws java.io.IOException
Utility to write an int array to a file.

writeVLongFile

public void writeVLongFile(long[] longs,
                           int length,
                           java.lang.String fileName,
                           boolean deltaEncode)
                    throws java.io.IOException
Utility to write a long array to a file.

readVIntFile

public int[] readVIntFile(java.lang.String fileName,
                          boolean deltaDecode)
                   throws java.io.IOException
Utility to read an int array from a file.

readVLongFile

public long[] readVLongFile(java.lang.String fileName,
                            boolean deltaDecode)
                     throws java.io.IOException
Utility to read a long array from a file.