Coverage Report - org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
CvsBlameConsumer
0 %
0/16
0 %
0/8
2,333
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.blame;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  * http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.Date;
 24  
 import java.util.List;
 25  
 import java.util.Locale;
 26  
 
 27  
 import org.apache.maven.scm.command.blame.BlameLine;
 28  
 import org.apache.maven.scm.log.ScmLogger;
 29  
 import org.apache.maven.scm.util.AbstractConsumer;
 30  
 import org.apache.regexp.RE;
 31  
 
 32  
 /**
 33  
  * @author Evgeny Mandrikov
 34  
  * @author Olivier Lamy
 35  
  * @since 1.4
 36  
  */
 37  
 public class CvsBlameConsumer
 38  
     extends AbstractConsumer
 39  
 {
 40  
     private static final String CVS_TIMESTAMP_PATTERN = "dd-MMM-yy";
 41  
 
 42  
     /* 1.1          (tor      24-Mar-03): */
 43  
 
 44  
     private static final String LINE_PATTERN = "(.*)\\((.*)\\s+(.*)\\)";
 45  
 
 46  
     /**
 47  
      * @see #LINE_PATTERN
 48  
      */
 49  
     private RE lineRegexp;
 50  
 
 51  0
     private List<BlameLine> lines = new ArrayList<BlameLine>();
 52  
 
 53  
     public CvsBlameConsumer( ScmLogger logger )
 54  
     {
 55  0
         super( logger );
 56  
 
 57  0
         lineRegexp = new RE( LINE_PATTERN );
 58  0
     }
 59  
 
 60  
     public void consumeLine( String line )
 61  
     {
 62  0
         if (line != null && line.indexOf( ':' ) > 0 )
 63  
         {
 64  0
             String annotation = line.substring( 0, line.indexOf( ':' ) );
 65  0
             if ( lineRegexp.match( annotation ) )
 66  
             {
 67  0
                 String revision = lineRegexp.getParen( 1 ).trim();
 68  0
                 String author = lineRegexp.getParen( 2 ).trim();
 69  0
                 String dateTimeStr = lineRegexp.getParen( 3 ).trim();
 70  
 
 71  0
                 Date dateTime = parseDate( dateTimeStr, null, CVS_TIMESTAMP_PATTERN, Locale.US );
 72  0
                 lines.add( new BlameLine( dateTime, revision, author ) );
 73  
 
 74  0
                 if ( getLogger().isDebugEnabled() )
 75  
                 {
 76  0
                     getLogger().debug( author + " " + dateTimeStr );
 77  
                 }
 78  
             }
 79  
         }
 80  0
     }
 81  
 
 82  
     public List<BlameLine> getLines()
 83  
     {
 84  0
         return lines;
 85  
     }
 86  
 
 87  
 }