org.pandora.knowledge
Class AbstractNetwork

java.lang.Object
  extended by org.pandora.knowledge.AbstractNetwork
All Implemented Interfaces:
java.lang.Cloneable, Network
Direct Known Subclasses:
BasicNetwork, DatabaseNetwork

public abstract class AbstractNetwork
extends java.lang.Object
implements Network, java.lang.Cloneable

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


Field Summary
static int MAX_SIZE
           
static int MAX_TEXT
          Define max text size for data value.
 
Constructor Summary
AbstractNetwork(boolean isShortTerm)
           
 
Method Summary
 void associateCaseInsensitivity(java.lang.String word, Vertex meaning)
          Associate alternative cases of the word with the meaning.
 AbstractNetwork clone()
          Return a copy of the network.
 Vertex createInstance(Primitive type)
          Create a new instance of the type.
 Vertex createInstance(Vertex type)
          Create a new instance of the type.
 Vertex createNewObject(java.lang.String name)
          Create the word, and a new meaning.
 Vertex createObject(java.lang.String name)
          Create the word, and its meaning.
 Vertex createSentence(java.lang.String text)
          Tokenize the sentence into its words and create a vertex representation.
 Vertex createSpeaker(java.lang.String name)
          Find or create the speaker with the name.
 Vertex createTimestamp()
          Create a timestamp based on the current nanos.
 Vertex createVertex()
          Create a new vertex in this network, assign the id and creation date.
 Vertex createVertex(java.lang.Object data)
          Create a new vertex in this network with the data, If a vertex with the data already exists, then it is returned as the data must be unique.
 Vertex createVertex(Vertex source)
          Create a new vertex from the source.
 Vertex createWord(java.lang.String text)
          Tokenize the text into its words and create a vertex representation of the word or compound word.
 Pandora getPandora()
          Return the associated Pandora instance.
 void importMerge(Vertex source, java.util.Map<Vertex,Vertex> identitySet)
          Merge the vertex into this network from an import.
 Vertex importVertex(Vertex source, java.util.Map<Vertex,Vertex> identitySet)
          Find the vertex matching the source, or create a new one.
 boolean isShortTerm()
           
 void merge(Network network)
          Merge the vertices and relations of the network into this network.
 void merge(Vertex sourceVertex)
          Merge the vertex into this network.
 void removeRelationship(Relationship relationship)
          Remove the relationship from the network.
 void setPandora(Pandora pandora)
          Set the associated Pandora instance.
 void setShortTerm(boolean isShortTerm)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pandora.api.knowledge.Network
clear, findAll, findAllLike, findAllQuery, findAllQuery, findAllRelationshipsTo, findByData, findById, findByName, getParent, removeVertex, removeVertexAndReferences, resume, save, setParent, size
 

Field Detail

MAX_TEXT

public static final int MAX_TEXT
Define max text size for data value.

See Also:
Constant Field Values

MAX_SIZE

public static int MAX_SIZE
Constructor Detail

AbstractNetwork

public AbstractNetwork(boolean isShortTerm)
Method Detail

clone

public AbstractNetwork clone()
Return a copy of the network.

Overrides:
clone in class java.lang.Object

toString

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

createVertex

public Vertex createVertex()
Create a new vertex in this network, assign the id and creation date.

Specified by:
createVertex in interface Network

createVertex

public Vertex createVertex(Vertex source)
Create a new vertex from the source. The source is from another network.

Specified by:
createVertex in interface Network

createVertex

public Vertex createVertex(java.lang.Object data)
Create a new vertex in this network with the data, If a vertex with the data already exists, then it is returned as the data must be unique.

Specified by:
createVertex in interface Network

merge

public void merge(Network network)
Merge the vertices and relations of the network into this network.

Specified by:
merge in interface Network

merge

public void merge(Vertex sourceVertex)
Merge the vertex into this network.

Specified by:
merge in interface Network

importVertex

public Vertex importVertex(Vertex source,
                           java.util.Map<Vertex,Vertex> identitySet)
Find the vertex matching the source, or create a new one. This is used from importing another memory.


importMerge

public void importMerge(Vertex source,
                        java.util.Map<Vertex,Vertex> identitySet)
Merge the vertex into this network from an import. This is used from importing another memory.

Specified by:
importMerge in interface Network

removeRelationship

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

Specified by:
removeRelationship in interface Network

createInstance

public Vertex createInstance(Primitive type)
Create a new instance of the type.

Specified by:
createInstance in interface Network

createInstance

public Vertex createInstance(Vertex type)
Create a new instance of the type.

Specified by:
createInstance in interface Network

createWord

public Vertex createWord(java.lang.String text)
Tokenize the text into its words and create a vertex representation of the word or compound word.

Specified by:
createWord in interface Network

associateCaseInsensitivity

public void associateCaseInsensitivity(java.lang.String word,
                                       Vertex meaning)
Associate alternative cases of the word with the meaning.

Specified by:
associateCaseInsensitivity in interface Network

createSentence

public Vertex createSentence(java.lang.String text)
Tokenize the sentence into its words and create a vertex representation.

Specified by:
createSentence in interface Network

createObject

public Vertex createObject(java.lang.String name)
Create the word, and its meaning. If the word or meaning exist, use the existing one.

Specified by:
createObject in interface Network

createNewObject

public Vertex createNewObject(java.lang.String name)
Create the word, and a new meaning.

Specified by:
createNewObject in interface Network

createSpeaker

public Vertex createSpeaker(java.lang.String name)
Find or create the speaker with the name.

Specified by:
createSpeaker in interface Network

createTimestamp

public Vertex createTimestamp()
Create a timestamp based on the current nanos.

Specified by:
createTimestamp in interface Network

getPandora

public Pandora getPandora()
Return the associated Pandora instance.

Specified by:
getPandora in interface Network

setPandora

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

Specified by:
setPandora in interface Network

isShortTerm

public boolean isShortTerm()

setShortTerm

public void setShortTerm(boolean isShortTerm)