org.planx.io
Interface FileSystem

All Known Subinterfaces:
NodeFileSystem<R>
All Known Implementing Classes:
CacheNodeFileSystem, LocalFileSystem, MemoryFileSystem, MemoryNodeFileSystem, MultiFileSystem, NodeFileSystemImpl

public interface FileSystem

A file system with allocation and free capabilities. Reading and writing is done through PositionalData.

Author:
Thomas Ambus

Method Summary
 Bound all()
          Returns a locator encapsulating all data currently in this file system.
 Bound allocate()
          (Optional) Returns a locator to a free write position that can hold an unspecified amount of bytes.
 Bound allocate(long size)
          Returns a locator to a free write position that can hold size number of bytes.
 void clear()
          Frees all data in this FileSystem.
 void clearModified()
          Marks this file system as unmodified.
 void close()
          Closes this file system and releases all resources.
 void free(Bound loc)
          Frees the space occupied by the specified Bound.
 PositionalData getData(Locator loc)
          Returns a PositionalData for reading and writing to the FileSystem at the specified location.
 Bound getMeta()
          Returns a locator to a special block of meta data.
 SourceId id()
          Returns a SourceId identifying this FileSystem in its present state.
 boolean isContained(Locator loc)
          Returns true if the specified Locator originates from this FileSystem and is valid.
 boolean isModified()
          Returns true if this file system has been modified since it was created or since the last call to clearModified().
 boolean isReadOnly()
          Returns true if this file system is read-only.
 void setMeta(Bound b)
          Sets the meta data pointer of this file system.
 void setReadOnly(boolean isReadOnly)
          Sets the read-only status of this file system.
 long size()
          Returns the size of this file system.
 

Method Detail

id

SourceId id()
            throws IOException
Returns a SourceId identifying this FileSystem in its present state. The SourceId can change at any point and is not necessarily equal to the SourceIds returned by allocation method even though these may still be valid. Thus, this SourceId should be regarded as a unique canonical id that identifies only the present state of this FileSystem.

Throws:
IOException

getData

PositionalData getData(Locator loc)
                       throws IOException,
                              InvalidSourceIdException,
                              OutOfBoundsException
Returns a PositionalData for reading and writing to the FileSystem at the specified location.

Throws:
IOException - if an I/O error occurred.
InvalidSourceIdException - if the file system identifier of the locator is invalid.
OutOfBoundsException - if the locator is out of bounds.

allocate

Bound allocate()
               throws IOException,
                      UnsupportedOperationException
(Optional) Returns a locator to a free write position that can hold an unspecified amount of bytes. Implementations are allowed to throw an UnsupportedOperationException if this is not supported.

Throws:
IOException - if an I/O error occurred.
UnsupportedOperationException - if not supported.

allocate

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

Throws:
IOException - if an I/O error occurred or the specified amount of bytes could not be allocated.

isContained

boolean isContained(Locator loc)
                    throws IOException
Returns true if the specified Locator originates from this FileSystem and is valid.

Throws:
IOException

all

Bound all()
          throws IOException
Returns a locator encapsulating all data currently in this file system.

Throws:
IOException - if an I/O error occurred.

free

void free(Bound loc)
          throws IOException,
                 InvalidSourceIdException,
                 OutOfBoundsException
Frees the space occupied by the specified Bound.

Throws:
IOException - if an I/O error occurred.
InvalidSourceIdException - if the file system identifier of the locator is invalid.
OutOfBoundsException - if the locator is out of bounds.

clear

void clear()
           throws IOException
Frees all data in this FileSystem.

Throws:
IOException

getMeta

Bound getMeta()
              throws IOException
Returns a locator to a special block of meta data. Only one meta data block is allowed per file system. If no meta data block has been set, or meta data is not supported, null is returned.

Throws:
IOException

setMeta

void setMeta(Bound b)
             throws IOException
Sets the meta data pointer of this file system. If meta data is not supported the operation is ignored.

Throws:
IOException

size

long size()
          throws IOException
Returns the size of this file system.

Throws:
IOException - if an I/O error occurred.

close

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

Throws:
IOException - if an I/O error occurred.

isModified

boolean isModified()
                   throws IOException
Returns true if this file system has been modified since it was created or since the last call to clearModified().

Throws:
IOException

clearModified

void clearModified()
                   throws IOException
Marks this file system as unmodified.

Throws:
IOException

isReadOnly

boolean isReadOnly()
                   throws IOException
Returns true if this file system is read-only.

Throws:
IOException

setReadOnly

void setReadOnly(boolean isReadOnly)
                 throws IOException
Sets the read-only status of this file system.

Throws:
IOException


Copyright © 2004-2005 Plan-X. All Rights Reserved.