com.edustructures.sifworks
Class ConditionGroup

java.lang.Object
  extended by com.edustructures.sifworks.ConditionGroup

public class ConditionGroup
extends java.lang.Object

A group of query conditions.

A ConditionGroup is a container for Condition objects that are evaluated together as a group using the Boolean operator passed to the constructor. ConditionGroups may be nested such that each ConditionGroup is evaluated using the Boolean operator passed to the constructor.

Version:
1.0

Constructor Summary
ConditionGroup(GroupOperators ops)
          Constructs a ConditionGroup
 
Method Summary
 void addCondition(Condition cond)
          Adds a Condition to this group
 void addCondition(ElementDef field, ComparisonOperators ops, java.lang.String value)
          Adds a condition to this group.
 void addCondition(java.lang.String xPath, ComparisonOperators ops, java.lang.String value)
          Add a condition to this group using a deeply nested path.
 void addGroup(ConditionGroup group)
          Adds a nested ConditionGroup to this group
 Condition[] getConditions()
          Gets the conditions in this group.
 ConditionGroup[] getGroups()
          Gets the nested ConditionGroups in this group.
 GroupOperators getOperator()
          Gets the Boolean operator for joining all conditions in this group
 Condition hasCondition(ElementDef elementOrAttr)
          Deprecated. Please use hasCondition(String) to support deeply nested query conditions
 Condition hasCondition(java.lang.String xPath)
          Tests if this ConditionGroup has a Condition for a specific XPath.
 boolean hasConditions()
          Determines if there are any conditions in this group, including any nested ConditionGroups
 int size()
          Gets the number of conditions in this group.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionGroup

public ConditionGroup(GroupOperators ops)
Constructs a ConditionGroup

Parameters:
ops - The Boolean operator to use when joining conditions in this group; either Condition.AND or Condition.OR
Method Detail

getOperator

public GroupOperators getOperator()
Gets the Boolean operator for joining all conditions in this group

Returns:
A constant from the Condition class (e.g. Condition.AND)

getConditions

public Condition[] getConditions()
Gets the conditions in this group. If the group consists of only nested ConditionGroups, an empty array is returned; use the getConditionGroups method to retrieve the nested groups.

Returns:
An array of Conditions added to this group, or an empty array if the group consists of only nested ConditionGroups

getGroups

public ConditionGroup[] getGroups()
Gets the nested ConditionGroups in this group. If the group does not contain any nested ConditionGroups and is comprised of only Condition elements, an empty array is returned

Returns:
An array of ConditionGroup

addCondition

public void addCondition(Condition cond)
Adds a Condition to this group

Parameters:
cond - The condition to add to this group of conditions

addCondition

public void addCondition(ElementDef field,
                         ComparisonOperators ops,
                         java.lang.String value)
Adds a condition to this group.

This method of adding conditions is convenient for adding conditions involving root attributes or elements to a query. If you need to add conditions on deeply nested elements, use addCondition(String, ComparisonOperators, String)

Parameters:
field - The metadata element that represents the field, such as StudentDTD.STUDENTPERSONAL_REFID
ops - The ComparisonOperator to use for this query condition
value - The value to compare to this field using the comparison operator

addCondition

public void addCondition(java.lang.String xPath,
                         ComparisonOperators ops,
                         java.lang.String value)
Add a condition to this group using a deeply nested path. Using this method of adding query condition allows for specifying deeply nested query conditions. However, the xpath specified here is specific to the version of SIF

To ensure your code works with all versions of SIF, you should use addCondition(ElementDef, ComparisonOperators, String) whenever possible.

Parameters:
xPath - The XPath representation of this field
ops - The ComparisonOperator to apply
value - The value to compare the field to

addGroup

public void addGroup(ConditionGroup group)
Adds a nested ConditionGroup to this group

Parameters:
group - The ConditionGropu to add to this group

hasConditions

public boolean hasConditions()
Determines if there are any conditions in this group, including any nested ConditionGroups

Returns:
True if this group contains any conditions

hasCondition

public Condition hasCondition(ElementDef elementOrAttr)
Deprecated. Please use hasCondition(String) to support deeply nested query conditions

Tests if this ConditionGroup has a Condition for a specific element or attribute. Nested ConditionGroups are not included in the search.

Parameters:
elementOrAttr - The ElementDef constant from the SIFDTD class that identifies the specific attribute or element to search for
Returns:
The matching Condition object or null if the group does not contain a Condition for the specified element or attribute

hasCondition

public Condition hasCondition(java.lang.String xPath)
Tests if this ConditionGroup has a Condition for a specific XPath. Nested ConditionGroups are not included in the search.

Parameters:
xPath - The xPath representation of the query field. e.g. "Name/FirstName"
Returns:
The matching Condition object or null if the root condition group does not contain a Condition for the specified path.

size

public int size()
Gets the number of conditions in this group.

Returns:
The number of conditions that will be returned by the getConditions method, or 0 if there are no conditions in the group or if the group is comprised of only nested ConditionGroups


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.