Coverage Report - org.apache.maven.scm.provider.clearcase.command.blame.ClearCaseBlameConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
ClearCaseBlameConsumer
92 %
13/14
50 %
2/4
1,667
 
 1  
 package org.apache.maven.scm.provider.clearcase.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 org.apache.maven.scm.command.blame.BlameLine;
 23  
 import org.apache.maven.scm.log.ScmLogger;
 24  
 import org.apache.maven.scm.util.AbstractConsumer;
 25  
 import org.apache.regexp.RE;
 26  
 
 27  
 import java.util.ArrayList;
 28  
 import java.util.Date;
 29  
 import java.util.List;
 30  
 
 31  
 /**
 32  
  * @author Jérémie Lagarde
 33  
  * @author Olivier Lamy
 34  
  * @since 1.4
 35  
  */
 36  
 public class ClearCaseBlameConsumer
 37  
     extends AbstractConsumer
 38  
 {
 39  
 
 40  
     private static final String CLEARCASE_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
 41  
 
 42  
     private static final String LINE_PATTERN = "VERSION:(.*)@@@USER:(.*)@@@DATE:(.*)@@@(.*)";
 43  
 
 44  
     private RE lineRegexp;
 45  
 
 46  1
     private List<BlameLine> lines = new ArrayList<BlameLine>();
 47  
 
 48  
     public ClearCaseBlameConsumer( ScmLogger logger )
 49  
     {
 50  1
         super( logger );
 51  1
         lineRegexp = new RE( LINE_PATTERN );
 52  1
     }
 53  
 
 54  
     public void consumeLine( String line )
 55  
     {
 56  12
         if ( lineRegexp.match( line ) )
 57  
         {
 58  12
             String revision = lineRegexp.getParen( 1 );
 59  
             // SCM-613
 60  12
             String author = lineRegexp.getParen( 2 ).toLowerCase();
 61  12
             String dateTimeStr = lineRegexp.getParen( 3 );
 62  
 
 63  12
             Date dateTime = parseDate( dateTimeStr, null, CLEARCASE_TIMESTAMP_PATTERN );
 64  12
             lines.add( new BlameLine( dateTime, revision, author ) );
 65  
 
 66  12
             if ( getLogger().isDebugEnabled() )
 67  
             {
 68  0
                 getLogger().debug( author + " " + dateTimeStr );
 69  
             }
 70  
         }
 71  12
     }
 72  
 
 73  
     public List<BlameLine> getLines()
 74  
     {
 75  3
         return lines;
 76  
     }
 77  
 }