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.core.SGraph Interface Reference

Inherits org.corpus_tools.salt.graph.Graph< N extends Node, R extends Relation< N, N, L extends Layer< N, R >, org.corpus_tools.salt.core.SAnnotationContainer, org.corpus_tools.salt.core.SNamedElement, and org.corpus_tools.salt.core.SPathElement.

Inherited by org.corpus_tools.salt.common.SCorpusGraph, org.corpus_tools.salt.common.SDocumentGraph, and org.corpus_tools.salt.core.impl.SGraphImpl.

Classes

enum  GRAPH_TRAVERSE_TYPE
 The GRAPH_TRAVERSE_TYPE determines the the traversal order. More...
 

Public Member Functions

List< SNodegetRoots ()
 Returns all root nodes, if exist. More...
 
List< SNodegetLeafs ()
 Returns all leaf nodes, if exist. More...
 
List< SNodegetChildren (SNode parent, SALT_TYPE relationType)
 Returns a list of nodes in base document. More...
 
List< SNodegetSharedParent (List< SNode > children, SALT_TYPE nodeType)
 Returns a list of nodes that are the parents of every node in the given base list. More...
 
void traverse (List< SNode > startNodes, GRAPH_TRAVERSE_TYPE traverseType, String traverseId, GraphTraverseHandler traverseHandler)
 Traverses a graph in the given order traverseType and starts traversing with the given startNodes. More...
 
void traverse (List<? extends SNode > startNodes, GRAPH_TRAVERSE_TYPE traverseType, String traverseId, GraphTraverseHandler traverseHandler, boolean isCycleSafe)
 Traverses a graph in the given order traverseType and starts traversing with the given startNodes. More...
 
List< SNodegetNodesByName (String nodeName)
 Searches for a node or a set of nodes having the given node name. More...
 
List< SRelationgetRelationsByName (String relationName)
 Searches for a relation or a set of relations having the given relation name. More...
 
List< SLayergetLayerByName (String layerName)
 Searches for a layer or a set of layers having the given layer name. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.graph.Graph< N extends Node, R extends Relation< N, N, L extends Layer< N, R >
IndexMgr getIndexMgr ()
 Returns the index manager. More...
 
List< R > getRelations ()
 Returns a list of all relations contained in this graph. More...
 
getRelation (String relationId)
 Returns an relation corresponding to the passed id, if such an relation is contained in the graph. More...
 
List< R > getRelations (String sourceNodeId, String targetNodeId)
 Returns all relations,which connects the two passed nodes. More...
 
List< R > getInRelations (String nodeId)
 Returns all relations, which have the node corresponding to the passed id as their target node. More...
 
List< R > getOutRelations (String nodeId)
 Returns all relations, which have the node corresponding to the passed id as their source node. More...
 
void addRelation (Relation<? extends N, ? extends N > relation)
 Adds the passed relation to this graph and updates indexes. More...
 
void removeRelation (Relation<? extends N, ? extends N > relation)
 Removes the passed relation from this graph. More...
 
void removeRelations ()
 Removes all relations from this graph and cleans all indexes.
 
boolean containsRelation (String relationId)
 Returns whether this graph contains an Relation corresponding to the passed id. More...
 
List< N > getNodes ()
 Returns a list of all relations contained in this graph. More...
 
getNode (String nodeId)
 Returns a node corresponding to the passed id, if such a node is contained in the graph. More...
 
void addNode (N node)
 Adds the passed node to this graph and updates indexes. More...
 
void removeNode (N node)
 Removes the passed node from this graph and cleans all indexes. More...
 
boolean containsNode (String nodeId)
 Returns whether this graph contains a Node corresponding to the passed id. More...
 
getLayer (String layerId)
 Returns a layer corresponding to the passed id, if such a layer is contained in the graph. More...
 
Set< L > getLayers ()
 Returns a set of layers contained by this graph. More...
 
void addLayer (L layer)
 Adds the passed layer to this graph. More...
 
boolean containsLayer (String layerId)
 Returns whether this graph contains a Layer corresponding to the passed id. More...
 
void removeLayer (L layer)
 Removes the passed layer from this graph and cleans all indexes. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.graph.IdentifiableElement
String getId ()
 Returns the id of this object, which is the value of the contained Identifier object. More...
 
void setId (String id)
 Creates a new Identifier object and sets its value to the passed id. More...
 
Identifier getIdentifier ()
 Returns the Identifier label for this object. More...
 
void setIdentifier (Identifier identifier)
 Sets the Identifier label for this object. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.graph.LabelableElement
Collection< LabelgetLabels ()
 Returns all labels being contained by this object. More...
 
void addLabel (Label label)
 Adds the given Label object to the list of labels. More...
 
Label getLabel (String namespace, String name)
 Returns a label having the passed namespace and name, if such a label is contained by this object. More...
 
Label getLabel (String qName)
 Returns a label having the passed qualified name. More...
 
void removeLabel (String qName)
 Removes the label having the passed qName. More...
 
void removeLabel (String namespace, String name)
 Removes a Label object from the list of labels of this object. More...
 
void removeAll ()
 Removes all Label objects.
 
Set< LabelgetLabelsByNamespace (String namespace)
 Returns a set containing all Label objects having the given namespace. More...
 
boolean containsLabel (String qName)
 Checks if this object has a Label object in its list having the given qualified name. More...
 
Integer sizeLabels ()
 returns the number of Label objects contained by this object. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.core.SAnnotationContainer
SAnnotation createAnnotation (String namespace, String name, Object value)
 Creates and returns an annotation having the passed namespace, name and value. More...
 
public< A extends SAnnotation > Set< A > createAnnotations (String annotationString)
 This method parses the given annotation String and adds an SAnnotation object for each annotation being contained in that string to the given SAnnotationContainer object. More...
 
public< A extends SAnnotation > Set< A > getAnnotations ()
 Returns all annotations contained by this object. More...
 
void addAnnotation (SAnnotation annotation)
 Adds the passed annotation to this container. More...
 
SAnnotation getAnnotation (String qName)
 Returns an annotation having the passed qualified name, if this container contains such an annotation. More...
 
SAnnotation getAnnotation (String namespace, String name)
 Returns an annotation having the passed qualified name, if this container contains such an annotation. More...
 
Iterator< SAnnotationiterator_SAnnotation ()
 Returns an iterator to iterate over the SAnnotation objects contained by this container. More...
 
SMetaAnnotation createMetaAnnotation (String namespace, String name, Object value)
 Creates and returns a meta annotation having the passed namespace, name and value. More...
 
public< A extends SMetaAnnotation > Set< A > createMetaAnnotations (String metaAnnotationString)
 This method parses the given meta annotation String and adds an SMetaAnnotation object for each meta annotation being contained in that string to the given SAnnotationContainer object. More...
 
public< A extends SMetaAnnotation > Set< A > getMetaAnnotations ()
 Returns all meta annotations contained by this object. More...
 
void addMetaAnnotation (SMetaAnnotation metaAnnotation)
 Adds the passed meta annotation to this container. More...
 
SMetaAnnotation getMetaAnnotation (String qName)
 Returns a meta annotation having the passed qualified name, if this container contains such a meta annotation. More...
 
Iterator< SMetaAnnotationiterator_SMetaAnnotation ()
 Returns an iterator to iterate over the SMetaAnnotation objects contained by this container. More...
 
SProcessingAnnotation createProcessingAnnotation (String namespace, String name, Object value)
 Creates and returns a processing-annotation having the passed namespace, name and value. More...
 
public< A extends SProcessingAnnotation > Set< A > createProcessingAnnotations (String annotationString)
 This method parses the given processing-annotation String and adds an SProcessingAnnotation object for each processing-annotation being contained in that string to the given SAnnotationContainer object. More...
 
public< A extends SProcessingAnnotation > Set< A > getProcessingAnnotations ()
 Returns all processing-annotations contained by this object. More...
 
void addProcessingAnnotation (SProcessingAnnotation processingAnnotation)
 Adds the passed processing-annotation to this container. More...
 
SProcessingAnnotation getProcessingAnnotation (String qName)
 Returns a processing-annotation having the passed qualified name, if this container contains such a processing-annotation. More...
 
Iterator< SProcessingAnnotationiterator_SProcessingAnnotation ()
 Returns an iterator to iterate over the SProcessingAnnotation objects contained by this container. More...
 
SFeature createFeature (String namespace, String name, Object value)
 Creates and returns an feature having the passed namespace, name and value. More...
 
public< A extends SFeature > Set< A > createFeatures (String featureString)
 This method parses the given feature String and adds an SFeature object for each feature being contained in that string to the given SAnnotationContainer object. More...
 
public< A extends SFeature > Set< A > getFeatures ()
 Returns all features contained by this object. More...
 
void addFeature (SFeature feature)
 Adds the passed feature to this container. More...
 
SFeature getFeature (String qName)
 Returns an feature having the passed qualified name, if this container contains such an feature. More...
 
SFeature getFeature (String namespace, String name)
 Returns an feature having the passed qualified name, if this container contains such an feature. More...
 
Iterator< SFeatureiterator_SFeature ()
 Returns an iterator to iterate over the SFeature objects contained by this container. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.core.SNamedElement
String getName ()
 Returns the name of this element. More...
 
void setName (String name)
 Sets the name of the element. More...
 
- Public Member Functions inherited from org.corpus_tools.salt.core.SPathElement
URI getPath ()
 Returns the id of this object as a URI path If no Id exists, null is returned. More...
 

Class Documentation

◆ org::corpus_tools::salt::core::SGraph::GRAPH_TRAVERSE_TYPE

enum org::corpus_tools::salt::core::SGraph::GRAPH_TRAVERSE_TYPE

The GRAPH_TRAVERSE_TYPE determines the the traversal order.

In general top-down means a traversal along the direction of the relations, whereas bottom-up means a traversal against the direction of the relations.

Author
florian
Enumerator
BOTTOM_UP_BREADTH_FIRST
BOTTOM_UP_DEPTH_FIRST
TOP_DOWN_BREADTH_FIRST
TOP_DOWN_DEPTH_FIRST

Member Function Documentation

◆ getChildren()

List<SNode> org.corpus_tools.salt.core.SGraph.getChildren ( SNode  parent,
SALT_TYPE  relationType 
)

Returns a list of nodes in base document.

The returned nodes are equivalents to the direct children of the passed parent node. The children are retrieved via traversing of relations of the passed SALT_TYPE.

Parameters
parentnode to who the children are retrieved
relationTypetype of relations to be traversed, if relationType is null, all relations are used
Returns
a list of children nodes, or an empty list

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getLayerByName()

List<SLayer> org.corpus_tools.salt.core.SGraph.getLayerByName ( String  layerName)

Searches for a layer or a set of layers having the given layer name.

Parameters
layerNameName of the layer to search for
Returns
A complete list of all matching layers. Is never null.

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getLeafs()

List<SNode> org.corpus_tools.salt.core.SGraph.getLeafs ( )

Returns all leaf nodes, if exist.

A leaf node is a node, which has no outgoing relations.

Returns
list of nodes being leafs in the given graph.

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getNodesByName()

List<SNode> org.corpus_tools.salt.core.SGraph.getNodesByName ( String  nodeName)

Searches for a node or a set of nodes having the given node name.

Parameters
nodeNameName of the node to search for
Returns
A complete list of all matching nodes. Is never null.

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getRelationsByName()

List<SRelation> org.corpus_tools.salt.core.SGraph.getRelationsByName ( String  relationName)

Searches for a relation or a set of relations having the given relation name.

Parameters
relationNameName of the relation to search for
Returns
A complete list of all matching relations. Is never null.

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getRoots()

List<SNode> org.corpus_tools.salt.core.SGraph.getRoots ( )

Returns all root nodes, if exist.

A root node is a node, which has no incoming relations.

Returns
list of nodes being roots in the given graph.

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ getSharedParent()

List<SNode> org.corpus_tools.salt.core.SGraph.getSharedParent ( List< SNode children,
SALT_TYPE  nodeType 
)

Returns a list of nodes that are the parents of every node in the given base list.

Only nodes with the given SALT_TYPE will be considered.

Parameters
childrenlist of nodes whose parents are looked for
nodeTyperegarded types of relations
Returns
a list of parents

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ traverse() [1/2]

void org.corpus_tools.salt.core.SGraph.traverse ( List< SNode startNodes,
GRAPH_TRAVERSE_TYPE  traverseType,
String  traverseId,
GraphTraverseHandler  traverseHandler 
)

Traverses a graph in the given order traverseType and starts traversing with the given startNodes.

When a node is reached, first this method will invoke the method GraphTraverseHandler#checkConstraint(GRAPH_TRAVERSE_MODE, String, Edge, Node, long) of the given callback handler traverseHandler, second the method GraphTraverseHandler#nodeReached(GRAPH_TRAVERSE_MODE, String, Node, Edge, Node, long) is invoked. When a node was left, the method GraphTraverseHandler#nodeLeft(GRAPH_TRAVERSE_MODE, String, Node, Edge, Node, long) is invoked. When calling these methods, the traverseId will be passed, so that the callback handler knows which traversal is meant. This is helpful, in case of a single callback handler is used for more than one traversal at the same time. This method throws a GraphTraverserException in case of the graph contains a cycle. A cycle means a path containing the same node twice.

Parameters
startNodeslist of nodes at which the traversal shall start
traverseTypetype of traversing
traverseIdidentification for callback handler, in case of more than one traversal is running at the same time with the same callback handler
traverseHandlercallback handler, on which the three methods will be invoked

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.

◆ traverse() [2/2]

void org.corpus_tools.salt.core.SGraph.traverse ( List<? extends SNode startNodes,
GRAPH_TRAVERSE_TYPE  traverseType,
String  traverseId,
GraphTraverseHandler  traverseHandler,
boolean  isCycleSafe 
)

Traverses a graph in the given order traverseType and starts traversing with the given startNodes.

When a node is reached, first this method will invoke the method GraphTraverseHandler#checkConstraint(GRAPH_TRAVERSE_MODE, String, Edge, Node, long) of the given callback handler traverseHandler, second the method GraphTraverseHandler#nodeReached(GRAPH_TRAVERSE_MODE, String, Node, Edge, Node, long) is invoked. When a node was left, the method GraphTraverseHandler#nodeLeft(GRAPH_TRAVERSE_MODE, String, Node, Edge, Node, long) is invoked. When calling these methods, the traverseId will be passed, so that the callback handler knows which traversal is meant. This is helpful, in case of a single callback handler is used for more than one traversal at the same time. This method throws a GraphTraverserException in case of the graph contains a cycle. A cycle means a path containing the same node twice.

Parameters
startNodeslist of nodes at which the traversal shall start
traverseTypetype of traversing
traverseIdidentification for callback handler, in case of more than one traversal is running at the same time with the same callback handler
traverseHandlercallback handler, on which the three methods will be invoked
isCycleSafedetermines whether cycle safeness chould be checked

Implemented in org.corpus_tools.salt.core.impl.SGraphImpl.