com.ibm.websphere.brb.query
Class AndNode
java.lang.Object
|
+--com.ibm.websphere.brb.query.QueryNode
|
+--com.ibm.websphere.brb.query.LogicalOpNode
|
+--com.ibm.websphere.brb.query.AndNode
- All Implemented Interfaces:
- java.io.Serializable
- public class AndNode
- extends LogicalOpNode
Represents a logical and
for a query.
To find all rules named "isEligible" with classification of "SeniorCitizen" you need
to combine a RuleNameNode
with a ClassificationNode
using a logical and
.
The following example performs this query:
IRuleFolder root = RuleMgmtHelper.getRootFolder();
RuleNameNode nameNode = new RuleNameNode("isEligible", RuleNameNode.EQUAL);
ClassificationNode cNode = new ClassificationNode("SeniorCitizen", ClassificationNode.EQUAL);
AndNode andNode = new AndNode(nameNode, cNode);
Collection coll = root.findRules(andNode, true, IRule.TYPE_COPY);
AndNode
allows you to pass many nodes to be combined together. The following
forms a query that combines four nodes into the AndNode:
IRuleFolder root = RuleMgmtHelper.getRootFolder();
RuleNameNode nameNode = new RuleNameNode("isEligible", RuleNameNode.EQUAL);
ClassificationNode cNode = new ClassificationNode("Senior%", ClassificationNode.LIKE);
// In effect in the year 2000
StartDateNode sdNode = new StartDateNode(new Date(2000, 01, 01), StartDateNode.AFTER_INCLUSIVE);
EndDateNode edNode = new EndDateNode(new Date(2001, 01, 01), StartDateNode.BEFORE_EXCLUSIVE);
AndNode andNode = new AndNode(new QueryNode[] { nameNode, cNode, sdNode, edNode} );
Collection coll = root.findRules(andNode, true, IRule.TYPE_COPY);
OrNode
s and AndNode
s can be combined together as well.
For example suppose you want to find rules that start with "is" that have a
classification of "gold" or "silver":
IRuleFolder root = RuleMgmtHelper.getRootFolder();
RuleNameNode nameNode = new RuleNameNode("is%", RuleNameNode.LIKE);
ClassificationNode gold = new ClassificationNode("gold", ClassificationNode.EQUAL);
ClassificationNode silver = new ClassificationNode("silver", ClassificationNode.EQUAL);
OrNode orNode = new OrNode(new QueryNode[] {gold, silver});
AndNode andNode = new AndNode(nameNode, orNode);
Collection coll = root.findRules(andNode, true, IRule.TYPE_COPY);
- See Also:
OrNode
, Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
AndNode
public AndNode(QueryNode[] nodesIn)
- Constructs an
AndNode
with an arbitrary
number of sub-nodes. The sub-nodes can be any type of QueryNode
,
including other LogicalOpNode
s or AttributeNode
s. Each
sub-node will be combined together to form a valid expression.
The input array nodesIn
must be non-null. The array
must contain at least two elements. An IllegalArgumentException
is thrown if the array does not meet this criteria.
- Parameters:
nodesIn
- the nodes that are to be combined together.- Throws:
java.lang.IllegalArgumentException
- if input array is null or if it does not contain at least two QueryNode
s
AndNode
public AndNode(QueryNode left,
QueryNode right)
- Constructs an
AndNode
with two sub-nodes.
The sub-nodes can be any type of QueryNode
,
including other LogicalOpNode
s or AttributeNode
s.
The sub-nodes will be combined together to form a valid expression.
left
and right
must be non-null.
An IllegalArgumentException
is thrown if they do not meet this criteria.
- Parameters:
left
- the node to the left of the logical operatorright
- the node to the right of the logical operator- Throws:
java.lang.IllegalArgumentException
- if either input parameter is null