1 package propagation.impl; 2 3 import propagation.Node; 4 import propagation.StateItem; 5 6 import java.util.List ; 7 8 public class ORSummaryRule extends AbstractPropagtionRule { 9 private static final String RULE_NAME = "OR-Rule"; 10 11 public void summaryUpperPropagate(Node node) { 12 long maxSeverity = 0; 13 14 List stateItems = node.getStateItems(); 15 int size = stateItems.size(); 16 for (int idx = 0; idx < size; idx++) { 17 StateItem stateItem = (StateItem) stateItems.get(idx); 18 19 maxSeverity = updateMaxSeverity(maxSeverity, stateItem); 20 } 21 22 List childNodes = node.getChildren(); 23 size = childNodes.size(); 24 for (int idx = 0; idx < size; idx++) { 25 Node child = (Node) childNodes.get(idx); 26 StateItem childSummary = child.getSummaryStateItem(); 27 28 maxSeverity = updateMaxSeverity(maxSeverity, childSummary); 29 } 30 31 long summaryState = STATE_CLEAR + maxSeverity; 32 StateItem summaryItem = node.getSummaryStateItem(); 33 boolean isSummaryChanged = summaryItem.setState(summaryState); 34 35 if (StateItem.STATE_CHANGED == isSummaryChanged) { 36 upperPropagate(node); 37 } 38 } 39 40 public String toString() { 41 return RULE_NAME; 42 } 43 } 44 | Popular Tags |