fmpp.progresslisteners
Class StatisticsProgressListener

java.lang.Object
  extended by fmpp.progresslisteners.StatisticsProgressListener
All Implemented Interfaces:
ProgressListener

public class StatisticsProgressListener
extends java.lang.Object
implements ProgressListener

Spins some counters regarding the work of the Engine. All methods of this listener can be called from multiple threads. The current state of counters can be read while the engine is working.


Field Summary
 
Fields inherited from interface fmpp.ProgressListener
EVENT_BEGIN_FILE_PROCESSING, EVENT_BEGIN_PROCESSING_SESSION, EVENT_END_FILE_PROCESSING, EVENT_END_PROCESSING_SESSION, EVENT_IGNORING_DIR, EVENT_SOURCE_NOT_MODIFIED, EVENT_WARNING
 
Constructor Summary
StatisticsProgressListener()
           
 
Method Summary
 int getAccessed()
          Number of files that the engine has tried to process.
 int getCopied()
          Number of files successfully copied.
 int getExecuted()
          Number of files successfully executed (templates).
 int getFailed()
          Number of files where processing was failed.
 long getProcessingTime()
          The duration of the last BEGIN_ALL_PROCESSING-END_ALL_PROCESSING in milliseconds, or -1 if that is not known.
 int getSuccesful()
          Number of files where processing was successfull.
 int getWarnings()
          Total number of warnings.
 int getXmlRendered()
          Number of XML files successfully rendered.
 void notifyProgressEvent(Engine engine, int event, java.io.File src, int pMode, java.lang.Throwable error, java.lang.Object param)
          Method called be the engine to notify events.
 void reset()
          Rests all counters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatisticsProgressListener

public StatisticsProgressListener()
Method Detail

notifyProgressEvent

public void notifyProgressEvent(Engine engine,
                                int event,
                                java.io.File src,
                                int pMode,
                                java.lang.Throwable error,
                                java.lang.Object param)
Description copied from interface: ProgressListener
Method called be the engine to notify events.

It is guaranteed that this method will not be called concurrently as far as the listener is added to a single Engine instance only.

Specified by:
notifyProgressEvent in interface ProgressListener
Parameters:
engine - The engine instance where the event has occured.
event - The code of the envent: an EVENT_... constant. As new event types can be introduced with new FMPP versions (even if it happens very seldom), a progress listener implementation should survive events that it does not understand. That is, it must not stop with an error, but it should silently ignore the event.
src - Depending on event the source file or null.
pMode - Depending on event the proccessing mode (Engine.PMODE_... constant) or Engine.PMODE_NONE. Note that new processing modes may be added as FMPP evolvers, so values that are not known be the progress listener should be handler nicely, and never cause error.
error - The error, or null if there was no error.
param - Extra information about the event. The class and meaning of object depends on the concrete event:
  • For EVENT_WARNING it is a String that describles the reason of warning.

reset

public void reset()
Rests all counters.


getProcessingTime

public long getProcessingTime()
The duration of the last BEGIN_ALL_PROCESSING-END_ALL_PROCESSING in milliseconds, or -1 if that is not known.


getCopied

public int getCopied()
Number of files successfully copied.


getExecuted

public int getExecuted()
Number of files successfully executed (templates).


getXmlRendered

public int getXmlRendered()
Number of XML files successfully rendered.


getFailed

public int getFailed()
Number of files where processing was failed.


getSuccesful

public int getSuccesful()
Number of files where processing was successfull.


getAccessed

public int getAccessed()
Number of files that the engine has tried to process.


getWarnings

public int getWarnings()
Total number of warnings.