org.pandora.knowledge
Class BasicNetwork

java.lang.Object
  extended by org.pandora.knowledge.AbstractNetwork
      extended by org.pandora.knowledge.BasicNetwork
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Network

public class BasicNetwork
extends AbstractNetwork
implements java.io.Serializable

An interconnected set of vertices, representing and knowledge-space. Basic implementation to allow subclasses to avoid defining some of the basic stuff.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.pandora.knowledge.AbstractNetwork
MAX_SIZE, MAX_TEXT
 
Constructor Summary
BasicNetwork()
           
BasicNetwork(boolean isShortTerm)
           
BasicNetwork(Network parent)
           
 
Method Summary
 void addVertex(Vertex vertex)
          Add the existing vertex to the network.
 void clear()
          Clear all vertices from the network.
 BasicNetwork clone()
          Return a thread safe copy of the network.
 java.util.List<Vertex> findAll()
          Return all vertices.
 java.util.List<Vertex> findAllLike(java.lang.String filter)
          Return all vertices matching the filter.
 java.util.List<Vertex> findAllQuery(java.lang.String query)
          Return all vertices matching the query.
 java.util.List<Vertex> findAllQuery(java.lang.String query, int max)
          Return all vertices matching the query.
 java.util.List<Relationship> findAllRelationshipsTo(Vertex vertex)
          Find all relationships related to the vertex or of the vertex type.
 Vertex findByData(java.lang.Object data)
          Return the vertex with the given data.
 Vertex findById(java.lang.Number id)
          Return the vertex with the given name.
 Vertex findByName(java.lang.String name)
          Return the vertex with the given name.
 Pandora getPandora()
          Return the associated Pandora instance.
 Network getParent()
          Return the parent network.
 java.util.Map<java.lang.Number,Vertex> getVerticiesById()
           
 void removeVertex(Vertex vertex)
          Remove the vertex from the network.
 void removeVertexAndReferences(Vertex vertex)
          Remove the vertex and all references to it from the network.
 void resume()
          Resume after a merge/save.
 void save()
          Merge the memory into the long term.
 void setPandora(Pandora pandora)
          Set the associated Pandora instance.
 void setParent(Network parent)
          Set the parent network.
 void setVerticiesById(java.util.Map<java.lang.Number,Vertex> verticiesById)
           
 int size()
          Return the total number of vertices stored.
 java.lang.String toString()
           
 
Methods inherited from class org.pandora.knowledge.AbstractNetwork
associateCaseInsensitivity, createInstance, createInstance, createNewObject, createObject, createSentence, createSpeaker, createTimestamp, createVertex, createVertex, createVertex, createWord, importMerge, importVertex, isShortTerm, merge, merge, removeRelationship, setShortTerm
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicNetwork

public BasicNetwork()

BasicNetwork

public BasicNetwork(boolean isShortTerm)

BasicNetwork

public BasicNetwork(Network parent)
Method Detail

resume

public void resume()
Description copied from interface: Network
Resume after a merge/save.

Specified by:
resume in interface Network

save

public void save()
Merge the memory into the long term. This is similar to a transactional commit. The changes should also be persisted, as the long term should always just be a cache of the storage. This implementation does not support persistence.

Specified by:
save in interface Network

clone

public BasicNetwork clone()
Return a thread safe copy of the network.

Overrides:
clone in class AbstractNetwork

clear

public void clear()
Clear all vertices from the network.

Specified by:
clear in interface Network

addVertex

public void addVertex(Vertex vertex)
Add the existing vertex to the network. Used to load an existing vertex, createVertex must be used to create a new one.


getParent

public Network getParent()
Description copied from interface: Network
Return the parent network. A network is essentially a nested-transactional sub-graph of the parent.

Specified by:
getParent in interface Network

setParent

public void setParent(Network parent)
Description copied from interface: Network
Set the parent network. A network is essentially a nested-transactional sub-graph of the parent.

Specified by:
setParent in interface Network

size

public int size()
Description copied from interface: Network
Return the total number of vertices stored.

Specified by:
size in interface Network

removeVertexAndReferences

public void removeVertexAndReferences(Vertex vertex)
Remove the vertex and all references to it from the network.

Specified by:
removeVertexAndReferences in interface Network

removeVertex

public void removeVertex(Vertex vertex)
Remove the vertex from the network. Note that the vertex must be no longer referenced by any other vertex in the network.

Specified by:
removeVertex in interface Network

findAll

public java.util.List<Vertex> findAll()
Return all vertices.

Specified by:
findAll in interface Network

findAllQuery

public java.util.List<Vertex> findAllQuery(java.lang.String query)
Return all vertices matching the query. Currently unable to process in memory.

Specified by:
findAllQuery in interface Network

findAllQuery

public java.util.List<Vertex> findAllQuery(java.lang.String query,
                                           int max)
Return all vertices matching the query. Currently unable to process in memory.

Specified by:
findAllQuery in interface Network

findAllLike

public java.util.List<Vertex> findAllLike(java.lang.String filter)
Return all vertices matching the filter.

Specified by:
findAllLike in interface Network

findByData

public Vertex findByData(java.lang.Object data)
Return the vertex with the given data.

Specified by:
findByData in interface Network

findByName

public Vertex findByName(java.lang.String name)
Return the vertex with the given name.

Specified by:
findByName in interface Network

findById

public Vertex findById(java.lang.Number id)
Return the vertex with the given name.

Specified by:
findById in interface Network

findAllRelationshipsTo

public java.util.List<Relationship> findAllRelationshipsTo(Vertex vertex)
Find all relationships related to the vertex or of the vertex type.

Specified by:
findAllRelationshipsTo in interface Network

getVerticiesById

public java.util.Map<java.lang.Number,Vertex> getVerticiesById()

setVerticiesById

public void setVerticiesById(java.util.Map<java.lang.Number,Vertex> verticiesById)

toString

public java.lang.String toString()
Overrides:
toString in class AbstractNetwork

getPandora

public Pandora getPandora()
Return the associated Pandora instance.

Specified by:
getPandora in interface Network
Overrides:
getPandora in class AbstractNetwork

setPandora

public void setPandora(Pandora pandora)
Set the associated Pandora instance.

Specified by:
setPandora in interface Network
Overrides:
setPandora in class AbstractNetwork