Class ProxyParseTreeListener
java.lang.Object
io.github.douira.glsl_transformer.transform.ProxyParseTreeListener
- All Implemented Interfaces:
ParseTreeListener
This class was taken from here
and was added to the public domain by the author DaveJarvis
Instances of this class allows multiple listeners to receive events while
walking the parse tree. For example:
ProxyParseTreeListener proxy = new ProxyParseTreeListener(); ParseTreeListener listener1 = ... ; ParseTreeListener listener2 = ... ; proxy.add( listener1 ); proxy.add( listener2 ); ParseTreeWalker.DEFAULT.walk( proxy, ctx );
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new proxy without an empty list of listeners.ProxyParseTreeListener(List<ParseTreeListener> listeners) Creates a new proxy with the given list of listeners. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ParseTreeListener listener) Adds the given listener to the list of event notification recipients.voidvoidbooleanisEmpty()Checks if the list of listeners is empty.booleanremove(ParseTreeListener listener) Removes the given listener to the list of event notification recipients.voidsetListeners(List<ParseTreeListener> listeners) Changes the list of listeners to receive events.voidvisitErrorNode(ErrorNode node) voidvisitTerminal(TerminalNode node)
-
Constructor Details
-
ProxyParseTreeListener
public ProxyParseTreeListener()Creates a new proxy without an empty list of listeners. Add listeners before walking the tree. -
ProxyParseTreeListener
Creates a new proxy with the given list of listeners.- Parameters:
listeners- A list of listerners to receive events.
-
-
Method Details
-
enterEveryRule
- Specified by:
enterEveryRulein interfaceParseTreeListener
-
exitEveryRule
- Specified by:
exitEveryRulein interfaceParseTreeListener
-
visitErrorNode
- Specified by:
visitErrorNodein interfaceParseTreeListener
-
visitTerminal
- Specified by:
visitTerminalin interfaceParseTreeListener
-
add
Adds the given listener to the list of event notification recipients.- Parameters:
listener- A listener to begin receiving events.
-
remove
Removes the given listener to the list of event notification recipients.- Parameters:
listener- A listener to stop receiving events.- Returns:
- false The listener was not registered to receive events.
-
setListeners
Changes the list of listeners to receive events. If the given list of listeners is null, an empty list will be created.- Parameters:
listeners- A list of listeners to receive tree walking events.
-
isEmpty
public boolean isEmpty()Checks if the list of listeners is empty.- Returns:
trueif there are not listeners in the list
-