com.ibm.websphere.brb.query
Class OrNode
java.lang.Object
|
+--com.ibm.websphere.brb.query.QueryNode
|
+--com.ibm.websphere.brb.query.LogicalOpNode
|
+--com.ibm.websphere.brb.query.OrNode
- All Implemented Interfaces:
- java.io.Serializable
- public class OrNode
- extends LogicalOpNode
Represents a logical or
for a query.
To find all rules with classification of "gold" or "silver" you need
to combine two ClassificationNode
s using a logical or
.
The following example performs this query:
IRuleFolder root = RuleMgmtHelper.getRootFolder();
ClassificationNode gold = new ClassificationNode("gold", ClassificationNode.EQUAL);
ClassificationNode silver = new ClassificationNode("silver", ClassificationNode.EQUAL);
OrNode orNode = new OrNode(gold, silver);
Collection coll = root.findRules(orNode, true, IRule.TYPE_COPY);
OrNode
allows you to pass many nodes to be combined together.
The following forms a query that combines three nodes into the OrNode
:
IRuleFolder root = RuleMgmtHelper.getRootFolder();
ClassificationNode gold = new ClassificationNode("gold", ClassificationNode.EQUAL);
ClassificationNode silver = new ClassificationNode("silver", ClassificationNode.EQUAL);
ClassificationNode bronze = new ClassificationNode("bronze", ClassificationNode.EQUAL);
OrNode orNode = new OrNode(new QueryNode[] {gold, silver, bronze});
Collection coll = root.findRules(orNode, true, IRule.TYPE_COPY);
OrNode
s and AndNode
s can be combined together as well.
For example suppose I 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, bronze});
AndNode andNode = new AndNode(nameNode, orNode);
Collection coll = root.findRules(andNode, true, IRule.TYPE_COPY);
- See Also:
AndNode
, Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
OrNode
public OrNode(QueryNode[] nodesIn)
- Constructs an
OrNode
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
OrNode
public OrNode(QueryNode left,
QueryNode right)
- Constructs an
OrNode
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