Package eu.clarin.sru.server.fcs.parser
Class QueryNode
- java.lang.Object
-
- eu.clarin.sru.server.fcs.parser.QueryNode
-
- Direct Known Subclasses:
Expression
,ExpressionAnd
,ExpressionGroup
,ExpressionNot
,ExpressionOr
,ExpressionWildcard
,QueryDisjunction
,QueryGroup
,QuerySegment
,QuerySequence
,QueryWithWithin
,SimpleWithin
public abstract class QueryNode extends Object
base class for FCS-QL expression tree nodes.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<QueryNode>
children
protected QueryNodeType
nodeType
static int
OCCURS_UNBOUNDED
Atom occurrence it not bound.protected QueryNode
parent
-
Constructor Summary
Constructors Modifier Constructor Description protected
QueryNode(QueryNodeType nodeType)
Constructor.protected
QueryNode(QueryNodeType nodeType, QueryNode child)
Constructor.protected
QueryNode(QueryNodeType nodeType, List<QueryNode> children)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
accept(QueryVisitor visitor)
QueryNode
getChild(int idx)
Get a child node by index.<T extends QueryNode>
TgetChild(Class<T> clazz, int idx)
Get a child node of specified type by index.int
getChildCount()
Get the number of children of this node.List<QueryNode>
getChildren()
The children of this node.QueryNode
getFirstChild()
Get this first child node.<T extends QueryNode>
TgetFirstChild(Class<T> clazz)
Get a first child node of specified type.QueryNode
getLastChild()
Get this last child node.QueryNodeType
getNodeType()
Get the node type of this node.QueryNode
getParent()
Get the parent node of this node.boolean
hasNodeType(QueryNodeType nodeType)
Check, if node if of given type.protected void
setParent(QueryNode parent)
String
toString()
-
-
-
Field Detail
-
OCCURS_UNBOUNDED
public static final int OCCURS_UNBOUNDED
Atom occurrence it not bound.- See Also:
- Constant Field Values
-
nodeType
protected final QueryNodeType nodeType
-
parent
protected QueryNode parent
-
-
Constructor Detail
-
QueryNode
protected QueryNode(QueryNodeType nodeType, List<QueryNode> children)
Constructor.- Parameters:
nodeType
- the type of the nodechildren
- the children of this node ornull
if none
-
QueryNode
protected QueryNode(QueryNodeType nodeType, QueryNode child)
Constructor.- Parameters:
nodeType
- the type of the nodechild
- the child of this node ornull
if none
-
QueryNode
protected QueryNode(QueryNodeType nodeType)
Constructor.- Parameters:
nodeType
- the type of the node
-
-
Method Detail
-
getNodeType
public QueryNodeType getNodeType()
Get the node type of this node.- Returns:
- the node type
-
hasNodeType
public boolean hasNodeType(QueryNodeType nodeType)
Check, if node if of given type.- Parameters:
nodeType
- type to check against- Returns:
true
if node is of given type,false
otherwise
-
getParent
public QueryNode getParent()
Get the parent node of this node.- Returns:
- the parent node or
null
if this is the root node
-
getChildren
public List<QueryNode> 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 QueryNode 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
null
if index is out of bounds
-
getFirstChild
public QueryNode getFirstChild()
Get this first child node.- Returns:
- the first child node of this node or
null
if none
-
getLastChild
public QueryNode getLastChild()
Get this last child node.- Returns:
- the last child node of this node or
null
if none
-
getChild
public <T extends QueryNode> T getChild(Class<T> clazz, int idx)
Get a child node of specified type by index. Only child nodes of the requested type are counted.- Type Parameters:
T
- 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
null
if no child was found
-
getFirstChild
public <T extends QueryNode> T getFirstChild(Class<T> clazz)
Get a first child node of specified type.- Type Parameters:
T
- 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
null
if no child was found
-
accept
public abstract void accept(QueryVisitor visitor)
-
setParent
protected final void setParent(QueryNode parent)
-
-