ca.utoronto.JCVSReport.metric
Class RegexMatchCounter

java.lang.Object
  extended byca.utoronto.JCVSReport.metric.BasicMetric
      extended byca.utoronto.JCVSReport.metric.RegexMatchCounter
All Implemented Interfaces:
Metric
Direct Known Subclasses:
RegexLineCounter, SyntaxTreeRegexMatchCounter

public class RegexMatchCounter
extends BasicMetric

Metric: Gather one metric from a revision of a file and add it to the Bloof database

Author:
David James, Olga Rodimina

Field Summary
 
Fields inherited from class ca.utoronto.JCVSReport.metric.BasicMetric
id, insertMetric, props
 
Constructor Summary
RegexMatchCounter()
           
 
Method Summary
 int countMatches(String contents, Pattern regex)
          Returns number of matches for a specified regular expression
 void init(MetricDatabase database, String id, ResourceBundle props)
          Initialize Metric from properties file
 void processRevision(String revisionId, String contents)
          Process the contents of a revision of a file with this metric
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexMatchCounter

public RegexMatchCounter()
Method Detail

init

public void init(MetricDatabase database,
                 String id,
                 ResourceBundle props)
          throws Exception
Initialize Metric from properties file

Specified by:
init in interface Metric
Overrides:
init in class BasicMetric
Parameters:
database - Where to insert the metrics
id - The id number of the metric
props - The properties of this metric as specified in the .properties file
Throws:
Exception

processRevision

public void processRevision(String revisionId,
                            String contents)
                     throws Exception
Process the contents of a revision of a file with this metric

Parameters:
revisionId - A unique ID for this revision of this file
contents - The contents of the file as a string
Throws:
Exception

countMatches

public int countMatches(String contents,
                        Pattern regex)
Returns number of matches for a specified regular expression

Parameters:
contents - The contents of the file as a string
regex - regular expression to match


JCVSReport: Easy Progress Reports for CVS/Java Projects. By David James.