Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.scripting.sai
Class FieldListenerMulticaster

java.lang.Object
  extended by org.web3d.vrml.scripting.sai.FieldListenerMulticaster
All Implemented Interfaces:
java.util.EventListener, X3DFieldEventListener

public class FieldListenerMulticaster
extends java.lang.Object
implements X3DFieldEventListener

A class which implements efficient and thread-safe multi-cast event dispatching for the events defined in this package.

This class will manage an immutable structure consisting of a chain of event listeners and will dispatch events to those listeners. Because the structure is immutable, it is safe to use this API to add/remove listeners during the process of an event dispatch operation.

An example of how this class could be used to implement a new component which fires "action" events:


 public myComponent extends Component {
   X3DFieldEventListener nodeListener = null;

   public void addFieldListener(X3DFieldEventListener l) {
     nodeListener = FieldListenerMulticaster.add(nodeListener, l);
   }

   public void removeFieldListener(X3DFieldEventListener l) {
     nodeListener = FieldListenerMulticaster.remove(nodeListener, l);
   }

   public void fireFieldChanged(int index) {
     if(nodeListener != null) {
       nodeListener.fieldChanged(index);
   }
 }
 

Version:
0.7 (27 August 1999)
Author:
Justin Couch

Constructor Summary
FieldListenerMulticaster(X3DFieldEventListener a, X3DFieldEventListener b)
          Creates an event multicaster instance which chains listener-a with listener-b.
 
Method Summary
static X3DFieldEventListener add(X3DFieldEventListener a, X3DFieldEventListener b)
          Adds input-method-listener-a with input-method-listener-b and returns the resulting multicast listener.
 void readableFieldChanged(X3DFieldEvent evt)
          Send a field change notification.
 X3DFieldEventListener remove(X3DFieldEventListener oldl)
          Removes a listener from this multicaster and returns the resulting multicast listener.
static X3DFieldEventListener remove(X3DFieldEventListener l, X3DFieldEventListener oldl)
          Removes the old component-listener from component-listener-l and returns the resulting multicast listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldListenerMulticaster

public FieldListenerMulticaster(X3DFieldEventListener a,
                                X3DFieldEventListener b)
Creates an event multicaster instance which chains listener-a with listener-b. Input parameters a and b should not be null, though implementations may vary in choosing whether or not to throw NullPointerException in that case.

Parameters:
a - listener-a
b - listener-b
Method Detail

remove

public X3DFieldEventListener remove(X3DFieldEventListener oldl)
Removes a listener from this multicaster and returns the resulting multicast listener.

Parameters:
oldl - the listener to be removed

add

public static X3DFieldEventListener add(X3DFieldEventListener a,
                                        X3DFieldEventListener b)
Adds input-method-listener-a with input-method-listener-b and returns the resulting multicast listener.

Parameters:
a - input-method-listener-a
b - input-method-listener-b

remove

public static X3DFieldEventListener remove(X3DFieldEventListener l,
                                           X3DFieldEventListener oldl)
Removes the old component-listener from component-listener-l and returns the resulting multicast listener.

Parameters:
l - component-listener-l
oldl - the component-listener being removed

readableFieldChanged

public void readableFieldChanged(X3DFieldEvent evt)
Send a field change notification.

Specified by:
readableFieldChanged in interface X3DFieldEventListener
Parameters:
evt - An event describing what happened

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium