org.planx.xmlstore.io
Interface FileSystem

All Known Implementing Classes:
LocalFileSystem, MemoryFileSystem

public interface FileSystem

An abstraction of a FileSystem supporting operations needed by disk XMLStore implementations. Every FileSystem has a unique FileSystemIdentifier that can be used to identify it. All Locators returned by a FileSystem will contain this FileSystemIdentifier so that the origin of the Locator can be determined.

Author:
Thomas Ambus

Method Summary
 LocalLocator all()
          Returns a LocalLocator to all content currently in this FileSystem.
 LocalLocator allocate()
          Returns a LocalLocator to a free write position that can hold size number of bytes.
 LocalLocator allocate(int size)
           
 LocalLocator allocate(int size, FileSystemIdentifier fsi)
           
 void close()
          Closes the file system and releases all resources.
 void copy(FileSystem fs, LocalLocator fromLoc, LocalLocator toLoc)
          Copies the data at fromLoc in the specified FileSystem to toLoc in this FileSystem.
 FileSystemIdentifier currentIdentifier()
           
 void free(LocalLocator loc)
          Frees the space occupied by the specified LocalLocator.
 DataInput getInput(LocalLocator loc)
          Positions the input at the specified location and returns a DataInput for reading.
 DataOutput getOutput(LocalLocator loc)
          Positions the output at the specified location and returns a DataOutpu for writing.
 boolean isContained(LocalLocator loc)
          Returns true if the specified LocalLocator originates from this FileSystem.
 long size()
          Returns the size of the FileSystem.
 

Method Detail

copy

void copy(FileSystem fs,
          LocalLocator fromLoc,
          LocalLocator toLoc)
          throws IOException,
                 UnknownLocatorException
Copies the data at fromLoc in the specified FileSystem to toLoc in this FileSystem.

Throws:
IOException
UnknownLocatorException

getInput

DataInput getInput(LocalLocator loc)
                   throws IOException,
                          UnknownLocatorException
Positions the input at the specified location and returns a DataInput for reading. The DataInput is shared so if multiple threads operate on the same FileSystem concurrently, external synchronization should be used.

Throws:
IOException
UnknownLocatorException

getOutput

DataOutput getOutput(LocalLocator loc)
                     throws IOException,
                            UnknownLocatorException
Positions the output at the specified location and returns a DataOutpu for writing. Note, that this can overwrite existing data. The DataInput is shared so if multiple threads operate on the same FileSystem concurrently, external synchronization should be used. When writing new data allocate() should be called first.

Throws:
IOException
UnknownLocatorException

allocate

LocalLocator allocate()
                      throws IOException
Returns a LocalLocator to a free write position that can hold size number of bytes.

Throws:
IOException

allocate

LocalLocator allocate(int size)
                      throws IOException
Throws:
IOException

allocate

LocalLocator allocate(int size,
                      FileSystemIdentifier fsi)
                      throws IOException
Throws:
IOException

currentIdentifier

FileSystemIdentifier currentIdentifier()

isContained

boolean isContained(LocalLocator loc)
Returns true if the specified LocalLocator originates from this FileSystem.


all

LocalLocator all()
                 throws IOException
Returns a LocalLocator to all content currently in this FileSystem.

Throws:
IOException

free

void free(LocalLocator loc)
          throws IOException,
                 UnknownLocatorException
Frees the space occupied by the specified LocalLocator.

Throws:
IOException
UnknownLocatorException

size

long size()
          throws IOException
Returns the size of the FileSystem.

Throws:
IOException

close

void close()
           throws IOException
Closes the file system and releases all resources.

Throws:
IOException


Copyright © 2010. All Rights Reserved.