org.planx.xmlstore.io
Class MemoryFileSystem

java.lang.Object
  extended by org.planx.xmlstore.io.MemoryFileSystem
All Implemented Interfaces:
FileSystem

public class MemoryFileSystem
extends Object
implements FileSystem

Author:
Thomas Ambus

Constructor Summary
MemoryFileSystem()
           
MemoryFileSystem(int capacity)
           
MemoryFileSystem(int capacity, FileSystemIdentifier fsi)
           
 
Method Summary
 LocalLocator all()
          Returns a LocalLocator to all content currently in this FileSystem.
 LocalLocator allocate()
          Always succeeds and allocates space at end of buffer, writes must be done before the next allocation.
 LocalLocator allocate(int size)
           
 LocalLocator allocate(int size, FileSystemIdentifier id)
           
 void clear()
          Frees all data and generates a new FileSystemIdentifier.
 void clear(FileSystemIdentifier fsi)
          Frees all data and sets the FileSystemIdentifier to the specified object.
 void close()
          No effect.
 void copy(FileSystem fs, LocalLocator fromLoc, LocalLocator locTo)
          Copies the data at fromLoc in the specified FileSystem to toLoc in this FileSystem.
 FileSystemIdentifier currentIdentifier()
           
 void free(LocalLocator loc)
          Does nothing.
 DataInput getInput(LocalLocator l)
          Positions the input at the specified location and returns a DataInput for reading.
 DataOutput getOutput(LocalLocator l)
          Only append allowed.
 boolean isContained(LocalLocator l)
          Returns true if the specified LocalLocator originates from this FileSystem.
 long size()
          Returns the size of the FileSystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryFileSystem

public MemoryFileSystem()

MemoryFileSystem

public MemoryFileSystem(int capacity)

MemoryFileSystem

public MemoryFileSystem(int capacity,
                        FileSystemIdentifier fsi)
Method Detail

currentIdentifier

public FileSystemIdentifier currentIdentifier()
Specified by:
currentIdentifier in interface FileSystem

allocate

public LocalLocator allocate()
                      throws IOException
Always succeeds and allocates space at end of buffer, writes must be done before the next allocation.

Specified by:
allocate in interface FileSystem
Throws:
IOException

allocate

public LocalLocator allocate(int size)
                      throws IOException
Specified by:
allocate in interface FileSystem
Throws:
IOException

allocate

public LocalLocator allocate(int size,
                             FileSystemIdentifier id)
                      throws IOException
Specified by:
allocate in interface FileSystem
Throws:
IOException

all

public LocalLocator all()
Description copied from interface: FileSystem
Returns a LocalLocator to all content currently in this FileSystem.

Specified by:
all in interface FileSystem

free

public void free(LocalLocator loc)
          throws IOException,
                 UnknownLocatorException
Does nothing.

Specified by:
free in interface FileSystem
Throws:
IOException
UnknownLocatorException

clear

public void clear()
Frees all data and generates a new FileSystemIdentifier.


clear

public void clear(FileSystemIdentifier fsi)
Frees all data and sets the FileSystemIdentifier to the specified object.


getInput

public DataInput getInput(LocalLocator l)
                   throws IOException,
                          UnknownLocatorException
Description copied from interface: FileSystem
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.

Specified by:
getInput in interface FileSystem
Throws:
IOException
UnknownLocatorException

getOutput

public DataOutput getOutput(LocalLocator l)
                     throws IOException,
                            UnknownLocatorException
Only append allowed.

Specified by:
getOutput in interface FileSystem
Throws:
IOException
UnknownLocatorException

copy

public void copy(FileSystem fs,
                 LocalLocator fromLoc,
                 LocalLocator locTo)
          throws IOException,
                 UnknownLocatorException
Description copied from interface: FileSystem
Copies the data at fromLoc in the specified FileSystem to toLoc in this FileSystem.

Specified by:
copy in interface FileSystem
Throws:
IOException
UnknownLocatorException

size

public long size()
          throws IOException
Description copied from interface: FileSystem
Returns the size of the FileSystem.

Specified by:
size in interface FileSystem
Throws:
IOException

close

public void close()
           throws IOException
No effect.

Specified by:
close in interface FileSystem
Throws:
IOException

isContained

public boolean isContained(LocalLocator l)
Description copied from interface: FileSystem
Returns true if the specified LocalLocator originates from this FileSystem.

Specified by:
isContained in interface FileSystem


Copyright © 2010. All Rights Reserved.