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