no.priv.garshol.duke
Class InMemoryLinkDatabase

java.lang.Object
  extended by no.priv.garshol.duke.InMemoryLinkDatabase
All Implemented Interfaces:
LinkDatabase

public class InMemoryLinkDatabase
extends Object
implements LinkDatabase

A link database implementation which keeps everything in memory.


Constructor Summary
InMemoryLinkDatabase()
           
 
Method Summary
 void assertLink(Link link)
          Assert a link.
 void checkConsistency()
           
 void clear()
          Removes all links from the database.
 void close()
          Shuts down the database, releasing resources.
 void commit()
          Commit asserted links to persistent store.
 List<Link> getAllLinks()
          Get all links.
 Collection<Link> getAllLinksFor(String id)
          Get all links for this identity.
 List<Link> getChangesSince(long since)
          Returns all links modified since the given time.
 Link inferLink(String id1, String id2)
          Can we work out, based on what we know, the relationship between these two? Returns null if we don't know the relationship.
 void setDoInference(boolean infer)
           
 String toString()
           
 Set<String> traverseAll(String id, Set<String> seen)
           
 void validateConnection()
          Verifies that we still have a connection to the database, and reestablishes it, if not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InMemoryLinkDatabase

public InMemoryLinkDatabase()
Method Detail

setDoInference

public void setDoInference(boolean infer)

getAllLinks

public List<Link> getAllLinks()
Description copied from interface: LinkDatabase
Get all links.

Specified by:
getAllLinks in interface LinkDatabase

getChangesSince

public List<Link> getChangesSince(long since)
Description copied from interface: LinkDatabase
Returns all links modified since the given time.

Specified by:
getChangesSince in interface LinkDatabase

getAllLinksFor

public Collection<Link> getAllLinksFor(String id)
Description copied from interface: LinkDatabase
Get all links for this identity. If there are no links it returns an empty collection, never null.

Specified by:
getAllLinksFor in interface LinkDatabase

assertLink

public void assertLink(Link link)
Description copied from interface: LinkDatabase
Assert a link.

Specified by:
assertLink in interface LinkDatabase

inferLink

public Link inferLink(String id1,
                      String id2)
Description copied from interface: LinkDatabase
Can we work out, based on what we know, the relationship between these two? Returns null if we don't know the relationship.

Specified by:
inferLink in interface LinkDatabase

checkConsistency

public void checkConsistency()

traverseAll

public Set<String> traverseAll(String id,
                               Set<String> seen)

validateConnection

public void validateConnection()
Description copied from interface: LinkDatabase
Verifies that we still have a connection to the database, and reestablishes it, if not. Useful when connections live a long time and are rarely used.

Specified by:
validateConnection in interface LinkDatabase

commit

public void commit()
Description copied from interface: LinkDatabase
Commit asserted links to persistent store.

Specified by:
commit in interface LinkDatabase

clear

public void clear()
Description copied from interface: LinkDatabase
Removes all links from the database.

Specified by:
clear in interface LinkDatabase

close

public void close()
Description copied from interface: LinkDatabase
Shuts down the database, releasing resources.

Specified by:
close in interface LinkDatabase

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.