com.flexive.shared.search.query
Class QueryOperatorNode

java.lang.Object
  extended by com.flexive.shared.search.query.QueryNode
      extended by com.flexive.shared.search.query.QueryOperatorNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
QueryRootNode

public class QueryOperatorNode
extends QueryNode

A "operator" node representing a conjunctive/disjunctive union of its children.

Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Nested Class Summary
static class QueryOperatorNode.Operator
          Node operators
 
Field Summary
 
Fields inherited from class com.flexive.shared.search.query.QueryNode
children, id, parent
 
Constructor Summary
QueryOperatorNode()
          Default constructor.
QueryOperatorNode(int id)
          Constructor.
QueryOperatorNode(int id, QueryOperatorNode.Operator operator)
          Constructor.
 
Method Summary
 void addChild(QueryNode child)
          Add a new child node after the last child.
 void addChild(QueryNode parentNode, QueryNode child)
          Add a new child to the given parent node.
 void addChildAfter(QueryNode afterNode, QueryNode child)
          Add a child after the given node.
 void buildSqlQuery(SqlQueryBuilder builder)
          Build the query represented by this node and its children.
 QueryNode findChild(int childId)
          Return the child node with the given ID.
 QueryNode getChild(int index)
          Return the child node at the given index.
protected  java.lang.String getNodeName()
          Return the informal representation of a node to be used in toString.
 QueryOperatorNode.Operator getOperator()
           
 SqlQueryBuilder getQueryBuilder()
           
 java.lang.String getSqlQuery()
          Return the SQL (sub-)query represented by this node and its children.
 boolean isValid()
          Return true if the node's value is valid, or false if it is not.
 QueryNode removeChild(QueryNode child)
          Remove a child node.
 void setOperator(QueryOperatorNode.Operator operator)
           
 void setQueryBuilder(SqlQueryBuilder queryBuilder)
           
 void visit(QueryNodeVisitor visitor)
          Visit this node.
 
Methods inherited from class com.flexive.shared.search.query.QueryNode
equals, getChildren, getId, getLabel, getLevel, getParent, getPath, hashCode, isHidden, isValueNode, isWideInput, setChildren, setId, setParent, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryOperatorNode

public QueryOperatorNode()
Default constructor.


QueryOperatorNode

public QueryOperatorNode(int id)
Constructor.

Parameters:
id - the node ID

QueryOperatorNode

public QueryOperatorNode(int id,
                         QueryOperatorNode.Operator operator)
Constructor.

Parameters:
id - the node ID.
operator - the operator value.
Method Detail

getOperator

public QueryOperatorNode.Operator getOperator()

setOperator

public void setOperator(QueryOperatorNode.Operator operator)

addChild

public void addChild(QueryNode child)
Add a new child node after the last child.

Overrides:
addChild in class QueryNode
Parameters:
child - The child node to be added

addChild

public void addChild(QueryNode parentNode,
                     QueryNode child)
Add a new child to the given parent node. The parent node may be the current node, or any of its immediate or transitive child nodes.

Overrides:
addChild in class QueryNode
Parameters:
parentNode - The parent node where the child should be inserted
child - The child node to be added

addChildAfter

public void addChildAfter(QueryNode afterNode,
                          QueryNode child)
Add a child after the given node. The after node may be an immediate or transitive child of the current node.

Overrides:
addChildAfter in class QueryNode
Parameters:
afterNode - node after which the child should be inserted
child - child node to be added

removeChild

public QueryNode removeChild(QueryNode child)
Remove a child node. Also searches all subtrees if the node is node an immediate child.

Overrides:
removeChild in class QueryNode
Parameters:
child - the child to be deleted
Returns:
the parent node of the deleted child, or null if the child does not exist

getChild

public QueryNode getChild(int index)
Return the child node at the given index.

Overrides:
getChild in class QueryNode
Parameters:
index - the child index in this parent's children list
Returns:
the child node at the given index.

findChild

public QueryNode findChild(int childId)
Return the child node with the given ID.

Overrides:
findChild in class QueryNode
Parameters:
childId - the requested child node ID
Returns:
the child node with the given ID

getNodeName

protected java.lang.String getNodeName()
Return the informal representation of a node to be used in toString.

Overrides:
getNodeName in class QueryNode
Returns:
the informal representation of a node to be used in toString.

isValid

public boolean isValid()
Return true if the node's value is valid, or false if it is not.

Specified by:
isValid in class QueryNode
Returns:
true if the node's value is valid, or false if it is not.

buildSqlQuery

public void buildSqlQuery(SqlQueryBuilder builder)
Build the query represented by this node and its children.

Specified by:
buildSqlQuery in class QueryNode
Parameters:
builder - an sql query builder

getSqlQuery

public java.lang.String getSqlQuery()
Return the SQL (sub-)query represented by this node and its children.

Returns:
the SQL (sub-)query represented by this node and its children.

visit

public void visit(QueryNodeVisitor visitor)
Visit this node.

Specified by:
visit in class QueryNode
Parameters:
visitor - the visitor

getQueryBuilder

public SqlQueryBuilder getQueryBuilder()

setQueryBuilder

public void setQueryBuilder(SqlQueryBuilder queryBuilder)