Package eu.clarin.sru.fcs.qlparser
Class AbstractQueryNode<Q extends AbstractQueryNode<Q,T,V>,T extends AbstractQueryNode.AbstractQueryNodeType,V extends AbstractQueryNode.AbstractQueryVisitor>
- java.lang.Object
-
- eu.clarin.sru.fcs.qlparser.AbstractQueryNode<Q,T,V>
-
public abstract class AbstractQueryNode<Q extends AbstractQueryNode<Q,T,V>,T extends AbstractQueryNode.AbstractQueryNodeType,V extends AbstractQueryNode.AbstractQueryVisitor> extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAbstractQueryNode.AbstractQueryNodeTypeInterface for node types of query expression tree nodes.static interfaceAbstractQueryNode.AbstractQueryVisitorInterface implementing a Visitor pattern for query expression trees.static classAbstractQueryNode.SourceLocationSource information wrapping start and stop offsets in the query text for a query node.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractQueryNode(T nodeType)Constructor.protectedAbstractQueryNode(T nodeType, List<Q> children)Constructor.protectedAbstractQueryNode(T nodeType, Q child)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaccept(V visitor)QgetChild(int idx)Get a child node by index.<X extends Q>
XgetChild(Class<X> clazz, int idx)Get a child node of specified type by index.intgetChildCount()Get the number of children of this node.List<Q>getChildren()The children of this node.QgetFirstChild()Get this first child node.<X extends Q>
XgetFirstChild(Class<X> clazz)Get a first child node of specified type.QgetLastChild()Get this last child node.AbstractQueryNode.SourceLocationgetLocation()Get source location information about start/stop offsets for this query node in the query text content.TgetNodeType()Get the node type of this node.QgetParent()Get the parent node of this node.booleanhasNodeType(T nodeType)Check, if node if of given type.voidsetLocation(AbstractQueryNode.SourceLocation location)Set source location information.protected voidsetParent(Q parent)StringtoString()
-
-
-
Field Detail
-
nodeType
protected final T extends AbstractQueryNode.AbstractQueryNodeType nodeType
-
parent
protected Q extends AbstractQueryNode<Q,T,V> parent
-
location
protected AbstractQueryNode.SourceLocation location
-
-
Constructor Detail
-
AbstractQueryNode
protected AbstractQueryNode(T nodeType, List<Q> children)
Constructor.- Parameters:
nodeType- the type of the nodechildren- the children of this node ornullif none
-
AbstractQueryNode
protected AbstractQueryNode(T nodeType, Q child)
Constructor.- Parameters:
nodeType- the type of the nodechild- the child of this node ornullif none
-
AbstractQueryNode
protected AbstractQueryNode(T nodeType)
Constructor.- Parameters:
nodeType- the type of the node
-
-
Method Detail
-
getNodeType
public T getNodeType()
Get the node type of this node.- Returns:
- the node type
-
hasNodeType
public boolean hasNodeType(T nodeType)
Check, if node if of given type.- Parameters:
nodeType- type to check against- Returns:
trueif node is of given type,falseotherwise
-
getParent
public Q getParent()
Get the parent node of this node.- Returns:
- the parent node or
nullif this is the root node
-
setParent
protected final void setParent(Q parent)
-
getChildren
public List<Q> getChildren()
The children of this node.- Returns:
- the list of children of this node
-
getChildCount
public int getChildCount()
Get the number of children of this node.- Returns:
- the number of children of this node
-
getChild
public Q getChild(int idx)
Get a child node by index.- Parameters:
idx- the index of the child node- Returns:
- the child node of this node or
nullif index is out of bounds
-
getFirstChild
public Q getFirstChild()
Get this first child node.- Returns:
- the first child node of this node or
nullif none
-
getLastChild
public Q getLastChild()
Get this last child node.- Returns:
- the last child node of this node or
nullif none
-
getChild
public <X extends Q> X getChild(Class<X> clazz, int idx)
Get a child node of specified type by index. Only child nodes of the requested type are counted.- Type Parameters:
X- the class of the nodes to be considered- Parameters:
clazz- the type to nodes to be consideredidx- the index of the child node- Returns:
- the child node of this node or
nullif no child was found
-
getFirstChild
public <X extends Q> X getFirstChild(Class<X> clazz)
Get a first child node of specified type.- Type Parameters:
X- the class of the nodes to be considered- Parameters:
clazz- the type to nodes to be considered- Returns:
- the child node of this node or
nullif no child was found
-
getLocation
public AbstractQueryNode.SourceLocation getLocation()
Get source location information about start/stop offsets for this query node in the query text content.- Returns:
- the location information with the span convering the query node in the query
-
setLocation
public final void setLocation(AbstractQueryNode.SourceLocation location)
Set source location information.- Parameters:
location- the location information with the span convering the query node in the query
-
accept
public abstract void accept(V visitor)
-
-