001: package org.acm.seguin.pmd.swingui.event;
002:
003: import org.acm.seguin.pmd.RuleSet;
004:
005: import java.util.EventObject;
006: import java.util.Iterator;
007: import java.util.List;
008:
009: public class RulesInMemoryEvent extends EventObject {
010:
011: private int m_lowestPriorityForAnalysis;
012: private RuleSet m_rules;
013:
014: /**
015: *****************************************************************************
016: *
017: */
018: private RulesInMemoryEvent(Object source) {
019: super (source);
020: }
021:
022: /**
023: *****************************************************************************
024: *
025: */
026: private RulesInMemoryEvent(Object source,
027: int lowestPriorityForAnalysis) {
028: super (source);
029:
030: m_lowestPriorityForAnalysis = lowestPriorityForAnalysis;
031: }
032:
033: /**
034: *****************************************************************************
035: *
036: */
037: private RulesInMemoryEvent(Object source, RuleSet rules) {
038: super (source);
039:
040: m_rules = rules;
041: }
042:
043: /**
044: *****************************************************************************
045: *
046: */
047: public RuleSet getRules() {
048: return m_rules;
049: }
050:
051: /**
052: *****************************************************************************
053: *
054: * @param source
055: */
056: public static final void notifyRequestAllRules(Object source) {
057: RulesInMemoryEvent event = new RulesInMemoryEvent(source);
058: List listenerList = ListenerList
059: .getListeners(RulesInMemoryEventListener.class);
060: Iterator listeners = listenerList.iterator();
061:
062: while (listeners.hasNext()) {
063: RulesInMemoryEventListener listener;
064:
065: listener = (RulesInMemoryEventListener) listeners.next();
066: listener.requestAllRules(event);
067: }
068: }
069:
070: /**
071: *****************************************************************************
072: *
073: * @param source
074: */
075: public static final void notifyRequestIncludedRules(Object source,
076: int lowestPriorityForAnalysis) {
077: RulesInMemoryEvent event = new RulesInMemoryEvent(source,
078: lowestPriorityForAnalysis);
079: List listenerList = ListenerList
080: .getListeners(RulesInMemoryEventListener.class);
081: Iterator listeners = listenerList.iterator();
082:
083: while (listeners.hasNext()) {
084: RulesInMemoryEventListener listener;
085:
086: listener = (RulesInMemoryEventListener) listeners.next();
087: listener.requestIncludedRules(event);
088: }
089: }
090:
091: /**
092: *****************************************************************************
093: *
094: * @param source
095: */
096: public static final void notifyReturnedRules(Object source,
097: RuleSet rules) {
098: RulesInMemoryEvent event = new RulesInMemoryEvent(source, rules);
099: List listenerList = ListenerList
100: .getListeners(RulesInMemoryEventListener.class);
101: Iterator listeners = listenerList.iterator();
102:
103: while (listeners.hasNext()) {
104: RulesInMemoryEventListener listener;
105:
106: listener = (RulesInMemoryEventListener) listeners.next();
107: listener.returnedRules(event);
108: }
109: }
110: }
|