Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.simulation.impl.command;
 
 
 import java.util.List;
 import java.util.Map;
 
 public class FiredRuleCounter implements AgendaEventListener {
 
     private List<StringinclusiveRuleNameList = null;
     private List<StringexclusiveRuleNameList = null;
 
     private Map<StringIntegerruleNameToFireCountMap = new HashMap<StringInteger>();
 
     public FiredRuleCounter() {
     }
 
     public List<StringgetInclusiveRuleNameList() {
         return ;
     }
 
     public void setInclusiveRuleNameList(List<StringinclusiveRuleNameList) {
         this. = inclusiveRuleNameList;
     }
 
     public List<StringgetExclusiveRuleNameList() {
         return ;
     }
 
     public void setExclusiveRuleNameList(List<StringexclusiveRuleNameList) {
         this. = exclusiveRuleNameList;
     }
 
     // Events
 
     public void matchCreated(MatchCreatedEvent event) {
     }
 
     public void matchCancelled(MatchCancelledEvent event) {
     }
 
     public void beforeMatchFired(BeforeMatchFiredEvent event) {
     }
 
     public void afterMatchFired(AfterMatchFiredEvent event) {
         String ruleName = event.getMatch().getRule().getName();
         if (acceptRuleName(ruleName)) {
             incrementFireCount(ruleName);
         }
     }
 
     private boolean acceptRuleName(String ruleName) {
         if ( != null) {
             if (!.contains(ruleName)) {
                 return false;
             }
         }
         if ( != null) {
             if (.contains(ruleName)) {
                 return false;
             }
         }
         return true;
     }
 
     private void incrementFireCount(String ruleName) {
         Integer fireCount = .get(ruleName);
         if (fireCount == null) {
             fireCount = 1;
         } else {
             fireCount++;
         }
         .put(ruleNamefireCount);
     }
    public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
    }
    public void agendaGroupPushed(AgendaGroupPushedEvent event) {
    }
    }
    }
    }
    }
    // Results
    public int getRuleNameFireCount(String ruleName) {
        Integer fireCount = .get(ruleName);
        return fireCount == null ? 0 : fireCount;
    }
New to GrepCode? Check out our FAQ X