Salt  3.4.2
A powerful, tagset-independent and theory-neutral meta model and API for storing, manipulating, and representing nearly all types of linguistic data .
org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R > Class Template Reference

Inherits org.corpus_tools.salt.graph.impl.IdentifiableElementImpl, and org.corpus_tools.salt.graph.Graph< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.

Inherited by org.corpus_tools.salt.core.impl.SGraphImpl, and org.corpus_tools.salt.extensions.notification.graph.impl.GraphNotifierImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.

Classes

enum  UPDATE_TYPE
 

Public Member Functions

 GraphImpl (Graph< N, R, L > delegate)
 Initializes an object of type Graph. More...
 
IndexMgr getIndexMgr ()
 Returns the index manager. More...
 
 GraphImpl (int expectedNodes, int expectedRelations)
 Instantiates a new graph object and sets the initial capacity for all indexes to the passed ones. More...
 
List< N > getNodes ()
 {@inheritDoc Graph::getNodes()}
 
getNode (String nodeId)
 {@inheritDoc Graph::getNode(String)}
 
void addNode (N node)
 {@inheritDoc Graph::addNode(Node)}
 
void removeNode (N node)
 {@inheritDoc Graph::removeNode(Node)}
 
boolean containsNode (String nodeId)
 {@inheritDoc Graph::containsNode(String)}
 
List< R > getRelations ()
 {@inheritDoc Graph::getRelations()}
 
getRelation (String relationId)
 {@inheritDoc Graph::getRelation(String)}
 
List< R > getRelations (String sourceNodeId, String targetNodeId)
 Returns all relations,which connects the two passed nodes.
Parameters
sourceNodeIdthe id of the source node
targetNodeIdthe id of the target node
Returns
returns all nodes between source node and target node

 
List< R > getInRelations (String nodeId)
 Returns all relations, which have the node corresponding to the passed id as their target node.
Parameters
nodeIdid corresponding to the node, for which all incoming relations should be searched
Returns
a list of all incoming relations

 
List< R > getOutRelations (String nodeId)
 Returns all relations, which have the node corresponding to the passed id as their source node.
Parameters
nodeIdid corresponding to the node, for which all outgoing relations should be searched
Returns
a list of all outgoing relations

 
void addRelation (Relation<? extends N, ? extends N > relation)
 {@inheritDoc Graph::addRelation(Relation)}
 
void removeRelation (Relation<? extends N, ? extends N > rel)
 Removes the passed relation from this graph.If a relation is removed, it will be deleted from all indexes. If the passed relation is null, nothing is removed.
Parameters
relationrelation to be removed

 
void removeRelations ()
 Removes all relations from this graph and cleans all indexes.
 
boolean containsRelation (String relationId)
 {@inheritDoc Graph::containsRelation(String)}
 
Set< L > getLayers ()
 Returns a set of layers contained by this graph.
Returns
all contained layers

 
getLayer (String layerId)
 Returns a layer corresponding to the passed id, if such a layer is contained in the graph.
Parameters
layerIdid of the layer to be searched for

 
boolean containsLayer (String layerId)
 {@inheritDoc Graph::containsLayer(String)}
 
void addLayer (L layer)
 Adds the passed layer to this graph.If layer is null or layer is already contained nothing is inserted. The passed layer and this graph will be double chained, which means the method Layer#getGraph() will return this graph. If the passed layer contains nodes or relations, which are not already contained by the graph, they will be added.
Parameters
layerlayer to be inserted

 
void removeLayer (L layer)
 Removes the passed layer from this graph and cleans all indexes.It also ensures, that the graph is removed from the layer, thus invoking Layer#getGraph() will return null. The double chaining between this graph and the passed layer will be cut off. If the passed layer is null nothing happens.
Parameters
layerthe layer to be removed

 
- Public Member Functions inherited from org.corpus_tools.salt.graph.impl.IdentifiableElementImpl
 IdentifiableElementImpl (IdentifiableElement delegate)
 
Identifier getIdentifier ()
 {@inheritDoc IdentifiableElement::getIdentifier()}
 
void setIdentifier (Identifier identifier)
 {@inheritDoc IdentifiableElement::setIdentifier(Identifier)}
 
void removeLabel (String qName)
 {@inheritDoc LabelableElement::removeLabel(String)} In case the passed qualified name is equal to SaltUtil#LABEL_ID_QNAME the internal reference to identifier is set to null.
 
String getId ()
 {@inheritDoc IdentifiableElement::getId()}
 
void setId (String id)
 {@inheritDoc IdentifiableElement::setId(String)}
 
String toString ()
 
- Public Member Functions inherited from org.corpus_tools.salt.graph.impl.LabelableElementImpl
 LabelableElementImpl (LabelableElement delegatee)
 Initializes a new object and sets an internal delegate. More...
 
Collection< LabelgetLabels ()
 {@inheritDoc LabelableElement::getLabels()}
 
Label getLabel (String qName)
 {@inheritDoc LabelableElement::getLabel(String)}
 
Label getLabel (String namespace, String name)
 {@inheritedDoc LabelableElement::getLabel(String, String)}
 
Set< LabelgetLabelsByNamespace (String namespace)
 {@inheritDoc LabelableElement::getLabelsByNamespace(String)}
 
void addLabel (Label label)
 Adds the given Label object to the list of labels.
Parameters
labelthe Label object to be added

 
void basicAddLabel (Label label)
 This is an internally used method. More...
 
void basicRemoveLabel (String qName)
 This is an internally used method. More...
 
void removeLabel (String namespace, String name)
 {@inheritDoc LabelableElement::removeLabel(String, String))}
 
void removeAll ()
 {@inheritDoc LabelableElement::removeAll()}
 
boolean containsLabel (String qName)
 {@inheritDoc LabelableElement::containsLabel(String)}
 
Integer sizeLabels ()
 {@inheritDoc LabelableElement::sizeLabels()}
 

Protected Member Functions

Graph< N, R, L > getDelegate ()
 Returns the delegate object.If delegate is not null, all functions of this method are delegated to the delegate object. Setting delegate makes this object to a container.
Returns
the delegate object

 
void init ()
 Initializes an object of type GraphImpl. More...
 
void basicAddNode (N node)
 This is an internally used method. More...
 
void basicRemoveNode (N node)
 This is an internally used method. More...
 
void basicAddRelation (Relation<? extends Node, ? extends Node > relation)
 This is an internally used method. More...
 
void update (Object oldValue, Object container, UPDATE_TYPE updateType) throws SaltException
 Updates all graph internal indexes, concerning the kind of the update which has been made. More...
 
void basicRemoveRelation (Relation<? extends N, ? extends N > rel)
 This is an internally used method. More...
 
void basicAddLayer (L layer)
 This is an internally used method. More...
 
void basicRemoveLayer (L layer)
 This is an internally used method. More...
 

Protected Attributes

IndexMgr indexMgr = null
 Index manager.
 
int expectedNodes = 16
 Number of expected nodes to initialize indexes.
 
int expectedRelations = 16
 Number of expected relations to initialize indexes.
 
int approximatedNodeDegree = expectedRelations / expectedNodes
 Approximated node degree, which is expectedRelations / expectedNodes.
 
- Protected Attributes inherited from org.corpus_tools.salt.graph.impl.LabelableElementImpl
LabelableElement delegate = null
 A delegate object of the same type. More...
 

Additional Inherited Members

- Static Public Attributes inherited from org.corpus_tools.salt.graph.impl.LabelableElementImpl
static final int EXPECTED_NUMBER_OF_LABELS = 5
 Determines the expected number of labels.
 

Constructor & Destructor Documentation

◆ GraphImpl() [1/2]

org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.GraphImpl ( Graph< N, R, L >  delegate)

Initializes an object of type Graph.

If delegate is not null, all functions of this method are delegated to the delegate object. Setting delegate makes this object to a container.

Parameters
adelegate object of the same type.

◆ GraphImpl() [2/2]

org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.GraphImpl ( int  expectedNodes,
int  expectedRelations 
)

Instantiates a new graph object and sets the initial capacity for all indexes to the passed ones.

Parameters
expectedNodesexpected upper bound of nodes in the graph, used for optimization
expectedRelationsexpected upper bound of relations in the graph, used for optimization

Member Function Documentation

◆ basicAddLayer()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicAddLayer ( layer)
protected

This is an internally used method.

To implement a double chaining of Graph and Node object when an node is inserted into this graph and to avoid an endless invocation the insertion of an relation is split into the two methods addLayer(Layer) and basicAddLayer(Layer). The invocation of methods is implement as follows:

addLayer(layer)                      Layer#setGraph(Graph)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicAddLayer(Layer)            Layer#basicSetGraph(Graph)

That means method addLayer(Layer) calls basicAddLayer(Layer) and Node#basicSetGraph(Graph). And method Layer#setGraph(Graph) calls basicAddLayer(Layer) and Layer#basicSetGraph(Graph).

Parameters
nodenode to be inserted

◆ basicAddNode()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicAddNode ( node)
protected

This is an internally used method.

To implement a double chaining of Graph and Node object when an node is inserted into this graph and to avoid an endless invocation the insertion of an relation is split into the two methods addNode(node) and basicAddNode(Node). The invocation of methods is implement as follows:

addNode(node)                      Node#setGraph(Graph)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicAddNode(Node)            Node#basicSetGraph(Graph)

That means method addNode(Node) calls basicAddNode(Node) and Node#basicSetGraph(Graph). And method Node#setGraph(Graph) calls basicAddNode(Node) and Node#basicSetGraph(Graph).

Parameters
nodenode to be inserted

◆ basicAddRelation()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicAddRelation ( Relation<? extends Node, ? extends Node relation)
protected

This is an internally used method.

To implement a double chaining of Graph and Relation object when an relation is inserted into this graph and to avoid an endless invocation the insertion of an relation is split into the two methods addRelation(Relation) and basicAddRelation(Relation). The invocation of methods is implement as follows:

addRelation(Relation)                      Relation#setGraph(Graph)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicAddRelation(Relation)            Relation#basicSetGraph(Graph)

That means method addRelation(Relation) calls basicAddRelation(Relation) and Relation#basicSetGraph(Graph). And method Relation#setGraph(Graph) calls basicAddRelation(Relation) and Relation#basicSetGraph(Graph).

Parameters
relationrelation to be inserted

Reimplemented in org.corpus_tools.salt.common.impl.SCorpusGraphImpl.

◆ basicRemoveLayer()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicRemoveLayer ( layer)
protected

This is an internally used method.

To realize the cut of the double chaining, the removal is split in two methods removeLayer(Layer) and basicRemoveLayer(Layer). which are connected as follows:

removeLayer(layer)                      Layer#setGraph(null)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicRemoveLayer(Layer)            Layer#basicSetGraph(null)
Parameters
nodethe node to be removed

◆ basicRemoveNode()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicRemoveNode ( node)
protected

This is an internally used method.

To realize the cut of the double chaining, the removal is split in two methods removeNode(Node) and basicRemoveNode(Node). which are connected as follows:

removeNode(node)                      Node#setGraph(null)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicRemoveNode(Node)            Node#basicSetGraph(null)
Parameters
nodethe node to be removed

◆ basicRemoveRelation()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.basicRemoveRelation ( Relation<? extends N, ? extends N >  rel)
protected

This is an internally used method.

To realize the cut of the double chaining, the removal is split in two methods removeRelation(Relation) and basicRemoveRelation(Relation). which are connected as follows:

removeRelation(relation)                      Relation#setGraph(null)
        ||             \ /                   ||
        ||              X                    ||
        \/             / \                   \/
basicRemoveRelation(Relation)            Relation#basicSetGraph(null)
Parameters
relationthe relation to be removed

◆ getIndexMgr()

IndexMgr org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.getIndexMgr ( )

Returns the index manager.

The index manager is used to register indexes for sets of nodes, relations, layers etc. or single values. The manager contains all indexes used by the Graph class. These indexes are:

Even further indexes can be added to the index manager.

Returns
the index manager

Implements org.corpus_tools.salt.graph.Graph< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.

◆ init()

◆ update()

void org.corpus_tools.salt.graph.impl.GraphImpl< N extends Node, R extends Relation< N, N, L extends Layer< N, R >.update ( Object  oldValue,
Object  container,
UPDATE_TYPE  updateType 
) throws SaltException
protected

Updates all graph internal indexes, concerning the kind of the update which has been made.

If the update could not be performed, false is returned. True otherwise.

Parameters
oldValueold value
containerthe object which has been updated
updateTypetype of update to be performed
Exceptions
SaltExceptionin case the update could not be performed