|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectUI.Run.GEVAStreamParser<E>
public abstract class GEVAStreamParser<E extends GEVAStreamParser.Event>
Base class from which all parsers are derived. This also handles dispatching the event to the listeners of the event as well as contains the base Event class. Inheriting classes should also fill the E template with the type of events it generates when it parses. Note. all the parsers that inherit from this need to be registered with the GEVAStreamReader through the addListener method and this is currently (2008y08M08d) done in GEVARun under the comment '//[BEGIN_STREAM_LISTENER[' To create a new parser, first create a new class that extends from this class. In the new class, add a new nested Event class that extends from this class's nested Event class and pass the event class name as the template parameter when extending this class in the format ClassName.EventName. All current (2008y08M08d) extended classes of this class use a singleton pattern, so this could be added too. Implement the abstract parseLine which takes in a Line object (defined as nested class within this class). This can be used to get the line text as well as communicate with other parsers (all parsers receive the same Line object which is mutable). Parse the line text and if it's something that the parser understands, generate an event for it by calling super.fireParserListener passing as instance of the nested Event class and it will be dispatched to all listeners. To add listeners to the new parser, this is currently (2008y08M08d) done in GEVARun under the comment '//[BEGIN_STREAM_LISTENER[' Note. if adding a new parser to parse the output GEVA writes about its configuration, instead, update the GEVAConfigurationStreamParser's Event and parseLine details. GEVAConfigurationStreamParser is set up to parse all these details, and only generate one event after they've all been parsed, rather than one event per line like most other parsers. The end of the configuration is determined by watching for the line containing Constants.GRAPH_DATA_BEGIN (currently (2008y08M08d) "#---Data---")
Nested Class Summary | |
---|---|
protected static class |
GEVAStreamParser.Event
Base listen event class. |
static class |
GEVAStreamParser.Extension
Base from which all extensions inherit |
protected class |
GEVAStreamParser.Line
Proxy to GEVAStreamReader.Event to pass on to inheriting classes so they don't have to deal with the Reader directly. |
protected static class |
GEVAStreamParser.LineEvent
Base listen event class, which simply gives the listener the line that was (or wasn't, as the case may be when using this event) parsed |
protected static interface |
GEVAStreamParser.Listener<E>
Listener interface which inheriting classes must extend, even if just to an empty type, so that listeners can listen on the specific listener for a given class |
Field Summary | |
---|---|
static int |
ID_ERR_OUT
Write using error formatting |
static int |
ID_STD_OUT
Write using output formatting |
Constructor Summary | |
---|---|
GEVAStreamParser()
|
Method Summary | |
---|---|
void |
addParserListener(GEVAStreamParser.Listener<E> listener)
Add a class to listen to parsing events by the inheriting parser |
static void |
begin()
|
static void |
end()
|
protected void |
fireParserListener(E event)
Called by inheriting classes when they have to say lineParsed to any listening listeners. |
void |
injectLine(java.lang.String text)
Fake a stream reader event causing all listeners to be notified of the line passed in as if it came from ID_STD_OUT |
void |
injectLine(java.lang.String text,
int streamId)
Fake a stream reader event causing all listeners to be notified of the line passed in as if it came from the given streamId |
protected abstract void |
parseLine(GEVAStreamParser.Line line)
Parse the line and generate the necessary events by calling fireParserListener. |
void |
removeParserListener(GEVAStreamParser.Listener<E> listener)
Remove a class from listen to parsing events |
void |
streamListener(GEVAStreamReader.Event event)
Listens to the stream reader for new lines to be parsed and sends them on to the inheriting class for parsing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ID_STD_OUT
public static final int ID_ERR_OUT
Constructor Detail |
---|
public GEVAStreamParser()
Method Detail |
---|
public static void begin()
public static void end()
public final void streamListener(GEVAStreamReader.Event event)
streamListener
in interface GEVAStreamReader.Listener
public void injectLine(java.lang.String text, int streamId)
public void injectLine(java.lang.String text)
protected abstract void parseLine(GEVAStreamParser.Line line)
public void addParserListener(GEVAStreamParser.Listener<E> listener)
public void removeParserListener(GEVAStreamParser.Listener<E> listener)
protected void fireParserListener(E event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |