All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jamonapi.CompositeListener Maven / Gradle / Ivy

There is a newer version: 2.82
Show newest version
package com.jamonapi;

import com.jamonapi.utils.DetailData;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/** A class that can contain other listeners that can listen to jamon events of interest.
 * These classes will all implement the JAMonListener interface too.  This is an example of the
 * Gang of 4 Composite design pattern.
 * 
 * @author steve souza
 *
 */
public class CompositeListener implements JAMonListener, DetailData {

    // A variable that will hold the list of Listeners
    private List listenerList=new ArrayList(4);
    // The name of the composite listener
    private String name;

    /** Uses the CompositeListener name */
    public CompositeListener() {
        this("CompositeJAMonListener");
    }

    /** Pass in a Listener name that allows you to differentiate this listener from others */
    public CompositeListener(String name) {
        this.name=name;
    }

    /** Add a listener to the composite and return this object */
    public CompositeListener addListener(JAMonListener listener) {
        listenerList.add(listener);
        return this;
    }

    /** Return the listener associated with the passed in name */
    public JAMonListener getListener(String listenerName) {
        int rows=getNumListeners();

        for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy