Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Freenet.node
Class StandardDataStore  view StandardDataStore download StandardDataStore.java

java.lang.Object
  extended byFreenet.node.StandardDataStore
All Implemented Interfaces:
Freenet.support.Callback, DataStore, java.io.Serializable

public class StandardDataStore
extends java.lang.Object
implements DataStore


Field Summary
protected  Freenet.support.CyclicArray ar
           
static java.lang.String filename
           
protected  java.util.Hashtable h
           
 long maxData
           
private static long write_interval
           
 
Constructor Summary
StandardDataStore(long maxData, int maxItems)
           
 
Method Summary
 void callback()
           
protected  void cleanUpData()
          Removes excess data (ie.
 Freenet.Key findClosestKey(Freenet.Key k)
          Returns the reference associated with the closest key to k.
 Freenet.Key findClosestKey(Freenet.Key k, Freenet.Key maskKey)
          Returns the reference associated with the closest key to k.
protected  int findNextClosestPos(Freenet.Key k, Freenet.Key nextk)
          Will return the position in ar of the closest key to k that is not as close as nextk
 java.util.Enumeration keys()
           
static DataStore makeDataStore(Node node, long maxData, int maxItems)
           
 void put(Freenet.Key k, Freenet.Address r, Data d)
          Adds an item to the DataStore
 void remove(Freenet.Key k)
          Removes an item from the DataStore given its key
 Data searchData(Freenet.Key k)
          Searches for a key in the DataStore and if found returns any data associated with that key.
 Freenet.Address searchRef(Freenet.Key k)
          Searches for a key in the DataStore and if found returns any reference associated with that key.
 void tofile(java.lang.String fname)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

write_interval

private static long write_interval

filename

public static java.lang.String filename

maxData

public long maxData

ar

protected Freenet.support.CyclicArray ar

h

protected java.util.Hashtable h
Constructor Detail

StandardDataStore

public StandardDataStore(long maxData,
                         int maxItems)
Method Detail

makeDataStore

public static DataStore makeDataStore(Node node,
                                      long maxData,
                                      int maxItems)

tofile

public void tofile(java.lang.String fname)
            throws java.io.IOException
Specified by:
tofile in interface DataStore

callback

public void callback()
Specified by:
callback in interface Freenet.support.Callback

keys

public java.util.Enumeration keys()

searchData

public Data searchData(Freenet.Key k)
Searches for a key in the DataStore and if found returns any data associated with that key. If none is found, null is returned.

Specified by:
searchData in interface DataStore

searchRef

public Freenet.Address searchRef(Freenet.Key k)
Searches for a key in the DataStore and if found returns any reference associated with that key. If none is found, null is returned.

Specified by:
searchRef in interface DataStore

remove

public void remove(Freenet.Key k)
Removes an item from the DataStore given its key

Specified by:
remove in interface DataStore

findClosestKey

public Freenet.Key findClosestKey(Freenet.Key k)
Returns the reference associated with the closest key to k.

Specified by:
findClosestKey in interface DataStore

findClosestKey

public Freenet.Key findClosestKey(Freenet.Key k,
                                  Freenet.Key maskKey)
Returns the reference associated with the closest key to k. The masking key allows the 'next best' key to be found. Imagine the entries in the datastore being sorted in terms of closeness to the key you specify. With no mask key the reference associated with the top-most item will be returned. However, with a mask key any references associated with keys above the mask key (including the mask key itself) will be ignored. This facility allows best-first backtracking.

Specified by:
findClosestKey in interface DataStore

put

public void put(Freenet.Key k,
                Freenet.Address r,
                Data d)
Adds an item to the DataStore

Specified by:
put in interface DataStore

findNextClosestPos

protected int findNextClosestPos(Freenet.Key k,
                                 Freenet.Key nextk)
Will return the position in ar of the closest key to k that is not as close as nextk


cleanUpData

protected void cleanUpData()
Removes excess data (ie. if there is more data than is permitted by the maxData field).


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).