public interface Graph
A
Graph
represents a single relational data source for XL's
relational query and rewriting facilities within the context of a single
thread (i.e., the methods are not thread-safe). While a
RuntimeModel
provides methods for obtaining information
and performing operations which are common to a set of
relational data sources with an equal structure, a
Graph
provides methods which operate on a single instance
of these data sources within a fixed thread.
E.g., a RuntimeModel
could represent
features of XML documents in general, while a Graph
of this
model represents a single XML document. Thus, a RuntimeModel
provides a set of common operations, a Graph
provides the data.- Author:
- Ole Kniemeyer
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canEnumerateEdges
(EdgeDirection dir, boolean constEdge, Serializable edge) boolean
canEnumerateNodes
(Type type) Can nodes of the specifiedtype
be enumerated?createMatcher
(Pattern pred, XBitSet providedConstants, IntList neededConstantsOut) Creates an instance ofProducer
.Creates a query state to be used for queries which use this graph.void
enumerateEdges
(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) void
enumerateNodes
(Type type, QueryState qs, int tp, MatchConsumer consumer, int arg) This methods enumerates all nodes of this graph of the given type to the givenMatchConsumer
via the given query state.void
enumerateSpaces
(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) This method enumerates all edges that possibly related 2 nodes with a spacing pattern inbetween them.getModel()
Returns this graph's run-time model.getRoot()
Returns the root node of this graph.Returns the root node of the type graph for this graphReturns the ordered scale values of the nodes in the type graph
-
Method Details
-
getModel
RuntimeModel getModel()Returns this graph's run-time model.- Returns:
- the run-time model
-
createQueryState
QueryState createQueryState()Creates a query state to be used for queries which use this graph. The returned query state has to be an instance of the type defined byCompiletimeModel.getQueryStateType()
of the corresponding compile-time model.- Returns:
- a new query state
-
createProducer
Creates an instance ofProducer
. This factory method creates an instance of a subclass ofProducer
which will be exclusively used later on in the context of the current match represented byqs
. The instance must be an instance of the class returned byCompiletimeModel.getProducerType()
for the corresponding compile-time model.The usage of producers is specified by the XL programming language.
- Parameters:
qs
- query state which holds current match for which the producer shall produce a replacement- Returns:
- a producer for use in the context of
qs
-
createMatcher
-
canEnumerateNodes
Can nodes of the specifiedtype
be enumerated? This method returnstrue
iff this graph can enumerate nodes of the giventype
using the methodenumerateNodes(de.grogra.reflect.Type, de.grogra.xl.query.QueryState, int, de.grogra.xl.query.MatchConsumer, int)
.- Parameters:
type
- the type of nodes- Returns:
true
iff nodes oftype
can be enumerated
-
enumerateNodes
This methods enumerates all nodes of this graph of the given type to the givenMatchConsumer
via the given query state. I.e., for every nodec
of this extent that has typetype
, the following statement is executed:qs.amatch (tp, c, consumer, arg);
- Parameters:
type
- the type of nodesqs
- the query state on which theamatch
-method has to be invokedtp
- the index-parameter for theamatch
-methodconsumer
- the consumer-parameter for theamatch
-methodarg
- the arg-parameter for theamatch
-method
-
canEnumerateEdges
-
enumerateEdges
void enumerateEdges(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) -
getRoot
Object getRoot()Returns the root node of this graph.- Returns:
- the root
-
getTypeRoot
Object getTypeRoot()Returns the root node of the type graph for this graph- Returns:
- the root of the type graph
-
enumerateSpaces
void enumerateSpaces(Object node, EdgeDirection dir, Type edgeType, QueryState qs, int toIndex, int patternIndex, Serializable pattern, int matchIndex, MatchConsumer consumer, int arg) This method enumerates all edges that possibly related 2 nodes with a spacing pattern inbetween them.- Parameters:
node
-dir
-edgeType
-qs
-toIndex
-patternIndex
-pattern
-matchIndex
-consumer
-arg
-
-
sortedTypeGraph
Returns the ordered scale values of the nodes in the type graph- Returns:
- HashMap instance containing mappings from the type graph nodes to scale values
-