org.egothor.repository
Class WebStore

java.lang.Object
  extended by org.egothor.repository.WebStore
All Implemented Interfaces:
DataRepository, URIRepositoryAppender

public class WebStore
extends java.lang.Object
implements URIRepositoryAppender, DataRepository

Author:
galambos

Nested Class Summary
static class WebStore.Page
           
 
Nested classes/interfaces inherited from interface org.egothor.repository.DataRepository
DataRepository.TupleSequence
 
Constructor Summary
WebStore(URIRepository map, DataRepository data)
          Creates a new instance of WebStore
 
Method Summary
 int addItem(long page_id, byte[] document, int length)
          Adds another document into the repository.
 long append(java.net.URI uri)
          Returns the new identifier related to the URI, -id iff the URI already exists under the id in the base.
 void close()
          Closes the repository.
 void destroy()
          Destroy the repository.
 DataInputStream elementAt(long key, int revision)
          Retrieves a data block.
 DataRepository.TupleSequence elements()
          The tuples are [long:uid;int:rev;Object:DataInputStream;Object:URI].
 void flush()
           
 WebStore.Page pageAt(long key, int revision)
          Retrieves a data block.
 long size()
          Returns number of URIs in the base, or -1 iff the value is unknown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebStore

public WebStore(URIRepository map,
                DataRepository data)
Creates a new instance of WebStore

Method Detail

close

public void close()
Description copied from interface: DataRepository
Closes the repository.

Specified by:
close in interface DataRepository
Specified by:
close in interface URIRepositoryAppender

destroy

public void destroy()
Description copied from interface: DataRepository
Destroy the repository.

Specified by:
destroy in interface DataRepository

addItem

public int addItem(long page_id,
                   byte[] document,
                   int length)
Adds another document into the repository. If the implementation is able to recognize whether the incoming data block is still the same (as the existing in the repository), it would discard the insertion request and return 0 as the signal of no-op.

Specified by:
addItem in interface DataRepository
Returns:
revision number (0 iff unchanged) or -1 when fails

append

public long append(java.net.URI uri)
            throws DatabaseStorageException
Returns the new identifier related to the URI, -id iff the URI already exists under the id in the base.

Specified by:
append in interface URIRepositoryAppender
Throws:
DatabaseStorageException

pageAt

public WebStore.Page pageAt(long key,
                            int revision)
                     throws DatabaseStorageException
Retrieves a data block.

Parameters:
key - the key of the block
revision - revision number of the block, 0 is used for the latest (current) revision
Returns:
null if the revision is not available (or the key is unknown)
Throws:
DatabaseStorageException

size

public long size()
Description copied from interface: URIRepositoryAppender
Returns number of URIs in the base, or -1 iff the value is unknown.

Specified by:
size in interface URIRepositoryAppender

elementAt

public DataInputStream elementAt(long key,
                                 int revision)
Description copied from interface: DataRepository
Retrieves a data block.

Specified by:
elementAt in interface DataRepository
Parameters:
key - the key of the block
revision - revision number of the block, 0 is used for the latest (current) revision
Returns:
null if the revision is not available (or the key is unknown)

elements

public DataRepository.TupleSequence elements()
The tuples are [long:uid;int:rev;Object:DataInputStream;Object:URI].

Specified by:
elements in interface DataRepository

flush

public void flush()
Specified by:
flush in interface DataRepository