|
Copyright (C) 2003,2004 dr. Cristiano Sadun | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.text.ffp.DispatcherListener
A dispatcher that allows to have different listeners receiving parsing events from
a FlatFileParser
depending on the
line format
which matched the line,
instead of one monolithic one receiving all parsing events.
It's useful when the flat file contains more than a few different formats -
avoiding to have a big switch statement (or multiple if s) to do
something different depending on which
line format
has actually matched a
line.
Constructor Summary | |
DispatcherListener()
Create a dispatcher listener which does not require that all events are associated to a listener (see DispatcherListener(boolean) ). |
|
DispatcherListener(boolean allowLostEvents)
Create a dispatcher listener, with no other listeners associated. |
Method Summary | |
void |
associateListener(LineFormat format,
FlatFileParser.Listener listener)
|
boolean |
isAllowLostEvents()
If true, the dispatcher allows parsing events which are not associated to any listener to be ignored; otherwise, events which are not associated to any listener will raise a NoAssociatedListenerException . |
void |
lineParsed(LineFormat format,
int logicalLinecount,
int physicalLineCount,
java.lang.String[] values)
Receive a parsing event and invoke the associated listener, if any. |
void |
setAllowLostEvents(boolean allowLostEvents)
Set whether or not true, the dispatcher allows parsing events which are not associated to any listener to be ignored. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DispatcherListener(boolean allowLostEvents)
associateListener(LineFormat, FlatFileParser.Listener)
overload to
associate a listener to a specific condition or line format.
allowLostEvents
- if true, the listener will not require that all events
are associated to a listener.public DispatcherListener()
DispatcherListener(boolean)
).
Method Detail |
public final void lineParsed(LineFormat format, int logicalLinecount, int physicalLineCount, java.lang.String[] values) throws AbortFFPException
lineParsed
in interface FlatFileParser.Listener
format
- the LineFormat
object which has executed the parsingvalues
- the values resulting from the parsing
AbortFFPException
FlatFileParser.Listener.lineParsed(org.sadun.text.ffp.LineFormat,
int, int, java.lang.String[])
public void associateListener(LineFormat format, FlatFileParser.Listener listener)
public boolean isAllowLostEvents()
NoAssociatedListenerException
.
public void setAllowLostEvents(boolean allowLostEvents)
NoAssociatedListenerException
.
allowLostEvents
- Set whether or not the dispatcher allows parsing events which
are not associated to any listener to be ignored.
|
Copyright (C) 2003,2004 dr. Cristiano Sadun | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |