Package propagation.impl

Source Code of propagation.impl.ORSummaryRule

package propagation.impl;

import propagation.Node;
import propagation.StateItem;

import java.util.List;

public class ORSummaryRule extends AbstractPropagtionRule {
   private static final String RULE_NAME = "OR-Rule";

   public void summaryUpperPropagate(Node node) {
      long maxSeverity = 0;

      List stateItems = node.getStateItems();
      int size = stateItems.size();
      for (int idx = 0; idx < size; idx++) {
         StateItem stateItem = (StateItem) stateItems.get(idx);

         maxSeverity = updateMaxSeverity(maxSeverity, stateItem);
      }

      List childNodes = node.getChildren();
      size = childNodes.size();
      for (int idx = 0; idx < size; idx++) {
         Node child = (Node) childNodes.get(idx);
         StateItem childSummary = child.getSummaryStateItem();

         maxSeverity = updateMaxSeverity(maxSeverity, childSummary);
      }

      long summaryState = STATE_CLEAR + maxSeverity;
      StateItem summaryItem = node.getSummaryStateItem();
      boolean isSummaryChanged = summaryItem.setState(summaryState);

      if (StateItem.STATE_CHANGED == isSummaryChanged) {
         upperPropagate(node);
      }
   }

   public String toString() {
      return RULE_NAME;
   }
}
TOP

Related Classes of propagation.impl.ORSummaryRule

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.