⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traceable.java

📁 The Java Network Simulator is a Java implementation of the ns-2 simulator originally from Berkeley.n
💻 JAVA
字号:
package jns.trace;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;


public abstract class Traceable
{

    /**
     List of Trace objects that are listening to us.
     */
    Vector m_traces = null;

    public Traceable()
    {
        m_traces = new Vector();
    }

    public void attach(Trace trace)
    {
        m_traces.addElement(trace);
    }

    public void detach(Trace trace)
    {
    }


    /**
     Used by subclasses to send events to a Trace object. This gets rid of
     lots of if/else code by making the decision if anyone is listening
     in here.
     */
    protected void sendEvent(Event event)
    {
        Enumeration e = m_traces.elements();
        while(e.hasMoreElements())
        {
            Trace trace = (Trace) e.nextElement();

            try
            {
                trace.handleEvent(event);
            }
            catch(IOException xept)
            {
                System.out.println("ERROR: An I/O exception occured while writing" +
                                   " an event!");
            }
        }


    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -