de.fuberlin.wiwiss.wiqa.gp
Class GraphPatternTreeNode

java.lang.Object
  extended byde.fuberlin.wiwiss.wiqa.gp.GraphPatternTreeNode

public class GraphPatternTreeNode
extends Object

A node in the tree of graph patterns. Represents one of the policy's graph patterns, manages its children, and may contain an explanation template associated with the pattern.

Version:
$Id$
Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
GraphPatternTreeNode(ExplanationTemplate explanation)
          Creates a root graph pattern.
GraphPatternTreeNode(String sharedVariable, ElementNamedGraph element, ExplanationTemplate explanation)
          Creates a new GraphPattern which corresponds to one of the PATTERN blocks in a WIQA policy.
 
Method Summary
 void addChild(GraphPatternTreeNode childPattern)
           
 List children()
           
 ElementNamedGraph element()
           
 BindingStreamConsumer explanationPartGenerator(ExplanationNode parent, ExplanationStore store)
          Creates a binding stream consumer that will instantiate the pattern's explanation template, and all of its child templates, and append the generated explanation parts to a given explanation node.
 ExplanationTemplate explanationTemplate()
           
 List nextDescendantsWithExplanation()
          Finds those children, grandchildren etc that have an associated explanation.
 String sharedVariable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphPatternTreeNode

public GraphPatternTreeNode(ExplanationTemplate explanation)
Creates a root graph pattern. It doesn't have a real corresponding ElementNamedGraph, only a dummy that mentions ?GRAPH.

Parameters:
explanation - The root explanation. May be null.

GraphPatternTreeNode

public GraphPatternTreeNode(String sharedVariable,
                            ElementNamedGraph element,
                            ExplanationTemplate explanation)
Creates a new GraphPattern which corresponds to one of the PATTERN blocks in a WIQA policy.

Parameters:
sharedVariable - The variable that is shared with the parent
element - The corresponding SPARQL syntax element
explanation - The corresponding explanation. May be null.
Method Detail

sharedVariable

public String sharedVariable()
Returns:
The variable that is shared with the parent, or null if this is the root

element

public ElementNamedGraph element()
Returns:
The graph pattern's parse tree element

addChild

public void addChild(GraphPatternTreeNode childPattern)
Parameters:
childPattern - Another pattern to be added as a child

children

public List children()
Returns:
A list of GraphPatterns, the children of this node

explanationTemplate

public ExplanationTemplate explanationTemplate()
Returns:
This pattern's explanation template, or null if it doesn't have one

nextDescendantsWithExplanation

public List nextDescendantsWithExplanation()
Finds those children, grandchildren etc that have an associated explanation.

Returns:
A list of GraphPatternTreeNodes

explanationPartGenerator

public BindingStreamConsumer explanationPartGenerator(ExplanationNode parent,
                                                      ExplanationStore store)
Creates a binding stream consumer that will instantiate the pattern's explanation template, and all of its child templates, and append the generated explanation parts to a given explanation node. Must not be called on GraphPatterns that don't have an explanation template.

Parameters:
parent - The explanation node to which newly generated explanation parts will be appended as children
store - An explanation store with explanations for functions and extensions
Returns:
A binding stream consumer