Copyright (C) 2003,2004 dr. Cristiano Sadun

org.sadun.text.ffp
Class EchoListener

java.lang.Object
  extended byorg.sadun.text.ffp.BaseListener
      extended byorg.sadun.text.ffp.EchoListener
All Implemented Interfaces:
FlatFileParser.Listener

public class EchoListener
extends BaseListener

A FlatFileParser.Listener which echoes the parsed data when a LineFormat whose is found whose name matches a regular expression (provided at construction). For example,

  FlatFileParser ffp = new FlatFileParser();
 
  ..set up three LineFormat objects, one named "header", the second "data1" and the third "data2"
 
  ffp.addListener(new DumpListener("data*"));
 

Author:
Cristiano Sadun

Constructor Summary
EchoListener()
          Create an EchoListener which echoes every line on System out.
EchoListener(java.io.PrintStream out)
          Create an EchoListener which echoes every line on the given stream.
EchoListener(java.lang.String regexp)
          Create an EchoListener which echoes lines whose format name matches the given regular expression on System.out.
EchoListener(java.lang.String regexp, java.io.PrintStream out)
          Create an EchoListener which echoes lines whose format name matches the given regular expression on the given stream.
 
Method Summary
protected  void onFormatName(LineFormat format, int logicalLineCount, int physicalLineCount, java.lang.String[] values)
          Invoked when a line whose format name matches the name or regexp provided at construction is found.
 
Methods inherited from class org.sadun.text.ffp.BaseListener
lineParsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EchoListener

public EchoListener(java.lang.String regexp,
                    java.io.PrintStream out)
Create an EchoListener which echoes lines whose format name matches the given regular expression on the given stream.

Parameters:
regexp - the regular expression that the parsed line format's name must match
out - the stream to echo to

EchoListener

public EchoListener(java.lang.String regexp)
Create an EchoListener which echoes lines whose format name matches the given regular expression on System.out.

Parameters:
regexp - the regular expression that the parsed line format's name must match

EchoListener

public EchoListener(java.io.PrintStream out)
Create an EchoListener which echoes every line on the given stream.

Parameters:
out - the stream to echo to

EchoListener

public EchoListener()
Create an EchoListener which echoes every line on System out.

Method Detail

onFormatName

protected final void onFormatName(LineFormat format,
                                  int logicalLineCount,
                                  int physicalLineCount,
                                  java.lang.String[] values)
Description copied from class: BaseListener
Invoked when a line whose format name matches the name or regexp provided at construction is found.

Specified by:
onFormatName in class BaseListener
Parameters:
values - the parsed values

Copyright (C) 2003,2004 dr. Cristiano Sadun