org.perf4j.helpers
Class StopWatchLogIterator

java.lang.Object
  extended by org.perf4j.helpers.StopWatchLogIterator
All Implemented Interfaces:
java.util.Iterator<StopWatch>

public class StopWatchLogIterator
extends java.lang.Object
implements java.util.Iterator<StopWatch>

The StopWatchLogIterator class takes input from a Reader and parses it so that deserialized StopWatch instances can be returned with each call to next(). Log messages that are not recognized as StopWatch calls are just ignored.

Author:
Alex Devine

Constructor Summary
StopWatchLogIterator(java.lang.Readable log)
          Creates a new StopWatchLogIterator to parse input from the specified Readable instance.
 
Method Summary
protected  java.lang.String getStopWatchParsePattern()
          Helper method gets the pattern that is used to parse StopWatches from the log.
 boolean hasNext()
           
 StopWatch next()
           
protected  StopWatch parseStopWatchFromLogMatch(java.util.regex.MatchResult matchResult)
          Helper method returns a new StopWatch from the MatchResult returned when a log messages matches the getStopWatchParsePattern() pattern string.
 void remove()
          Remove is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StopWatchLogIterator

public StopWatchLogIterator(java.lang.Readable log)
Creates a new StopWatchLogIterator to parse input from the specified Readable instance.

Parameters:
log - The log containing the data to be parsed.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<StopWatch>

next

public StopWatch next()
Specified by:
next in interface java.util.Iterator<StopWatch>

remove

public void remove()
Remove is not supported.

Specified by:
remove in interface java.util.Iterator<StopWatch>
Throws:
java.lang.UnsupportedOperationException - Always thrown.

getStopWatchParsePattern

protected java.lang.String getStopWatchParsePattern()
Helper method gets the pattern that is used to parse StopWatches from the log. The following is true of the capturing groups of this pattern:
  1. The start time in milliseconds, parseable as a long
  2. The elapsed time in milliseconds, parseable as a long
  3. The tag name
  4. Optional, if not null the message text.

Returns:
The pattern string used to parse the log data.

parseStopWatchFromLogMatch

protected StopWatch parseStopWatchFromLogMatch(java.util.regex.MatchResult matchResult)
Helper method returns a new StopWatch from the MatchResult returned when a log messages matches the getStopWatchParsePattern() pattern string.

Parameters:
matchResult - The regex match result
Returns:
A new StopWatch that reflects the data from the match result.


Copyright © 2008 perf4j.org. All Rights Reserved.