FileDocCategorySizeDatePackage
InputBufferEventSupport.javaAPI DocGlassfish v2 API2706Wed Feb 08 12:31:18 GMT 2006persistence.antlr.debug

InputBufferEventSupport

public class InputBufferEventSupport extends Object

Fields Summary
private Object
source
private Vector
inputBufferListeners
private InputBufferEvent
inputBufferEvent
protected static final int
CONSUME
protected static final int
LA
protected static final int
MARK
protected static final int
REWIND
Constructors Summary
public InputBufferEventSupport(Object source)



	   
		inputBufferEvent = new InputBufferEvent(source);
		this.source = source;
	
Methods Summary
public voidaddInputBufferListener(persistence.antlr.debug.InputBufferListener l)

		if (inputBufferListeners == null) inputBufferListeners = new Vector();
		inputBufferListeners.addElement(l);
	
public voidfireConsume(char c)

		inputBufferEvent.setValues(InputBufferEvent.CONSUME, c, 0);
		fireEvents(CONSUME, inputBufferListeners);		
	
public voidfireEvent(int type, persistence.antlr.debug.ListenerBase l)

		switch(type) {
			case CONSUME: ((InputBufferListener)l).inputBufferConsume(inputBufferEvent); break;
			case LA:      ((InputBufferListener)l).inputBufferLA(inputBufferEvent); break;
			case MARK:    ((InputBufferListener)l).inputBufferMark(inputBufferEvent); break;
			case REWIND:  ((InputBufferListener)l).inputBufferRewind(inputBufferEvent); break;
			default:
				throw new IllegalArgumentException("bad type "+type+" for fireEvent()");
		}	
	
public voidfireEvents(int type, java.util.Vector listeners)

		Vector targets=null;
		ListenerBase l=null;
		
		synchronized (this) {
			if (listeners == null) return;
			targets = (Vector)listeners.clone();
		}
		
		if (targets != null)
			for (int i = 0; i < targets.size(); i++) {
				l = (ListenerBase)targets.elementAt(i);
				fireEvent(type, l);
			}
	
public voidfireLA(char c, int la)

		inputBufferEvent.setValues(InputBufferEvent.LA, c, la);
		fireEvents(LA, inputBufferListeners);
	
public voidfireMark(int pos)

		inputBufferEvent.setValues(InputBufferEvent.MARK, ' ", pos);
		fireEvents(MARK, inputBufferListeners);
	
public voidfireRewind(int pos)

		inputBufferEvent.setValues(InputBufferEvent.REWIND, ' ", pos);
		fireEvents(REWIND, inputBufferListeners);
	
public java.util.VectorgetInputBufferListeners()

		return inputBufferListeners;
	
protected voidrefresh(java.util.Vector listeners)

		Vector v;
		synchronized (listeners) {
			v = (Vector)listeners.clone();
		}
		if (v != null)
			for (int i = 0; i < v.size(); i++)
				((ListenerBase)v.elementAt(i)).refresh();
	
public voidrefreshListeners()

		refresh(inputBufferListeners);
	
public voidremoveInputBufferListener(persistence.antlr.debug.InputBufferListener l)

		if (inputBufferListeners != null)
			inputBufferListeners.removeElement(l);