org.perf4j.helpers
Class StopWatchParser

java.lang.Object
  extended by org.perf4j.helpers.StopWatchParser

public class StopWatchParser
extends Object

This helper class is used to parse StopWatches from log message.

Author:
Alex Devine

Field Summary
static String DEFAULT_MATCH_PATTERN
          The default regex used to parse StopWatches from Strings.
 
Constructor Summary
StopWatchParser()
          Creates a StopWatchParser that uses the DEFAULT_MATCH_PATTERN to parse StopWatch message strings.
StopWatchParser(String matchPattern)
          Creates a StopWatchParser that uses the specified regex pattern string to parse StopWatch message strings.
 
Method Summary
 Pattern getPattern()
          Gets the Pattern object used by this StopWatchParser to parse StopWatch message strings.
 MatchResult match(String message)
          Gets the MatchResult object that is returned when the Pattern used by this parser matches the specified message.
 StopWatch parseStopWatch(String message)
          This method parses a StopWatch from the given message string.
 StopWatch parseStopWatchFromLogMatch(MatchResult matchResult)
          Helper method returns a new StopWatch from the MatchResult returned when a log messages matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MATCH_PATTERN

public static final String DEFAULT_MATCH_PATTERN
The default regex used to parse StopWatches from Strings. 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.

See Also:
Constant Field Values
Constructor Detail

StopWatchParser

public StopWatchParser()
Creates a StopWatchParser that uses the DEFAULT_MATCH_PATTERN to parse StopWatch message strings.


StopWatchParser

public StopWatchParser(String matchPattern)
Creates a StopWatchParser that uses the specified regex pattern string to parse StopWatch message strings.

Parameters:
matchPattern - The regex pattern String to use to parse log messages
Throws:
PatternSyntaxException - Thrown if matchPattern is not a valid regex pattern.
Method Detail

getPattern

public Pattern getPattern()
Gets the Pattern object used by this StopWatchParser to parse StopWatch message strings.

Returns:
The Pattern object.

parseStopWatch

public StopWatch parseStopWatch(String message)
This method parses a StopWatch from the given message string.

Parameters:
message - The message to parse, which was likely created with the StopWatch stop, lap or toString methods.
Returns:
The parsed StopWatch, or null if the StopWatch couldn't be parsed.

match

public MatchResult match(String message)
Gets the MatchResult object that is returned when the Pattern used by this parser matches the specified message.

Parameters:
message - The StopWatch message to parse.
Returns:
The MatchResult from matching the message, or null if it didn't match.

parseStopWatchFromLogMatch

public StopWatch parseStopWatchFromLogMatch(MatchResult matchResult)
Helper method returns a new StopWatch from the MatchResult returned when a log messages matches.

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


Copyright © 2008-2009 perf4j.org. All Rights Reserved.