Coverage Report - org.apache.maven.scm.provider.tfs.command.blame.TfsBlameConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
TfsBlameConsumer
100 %
12/12
50 %
1/2
1,333
 
 1  
 package org.apache.maven.scm.provider.tfs.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 Evgeny Mandrikov
 33  
  * @since 1.4
 34  
  */
 35  
 public class TfsBlameConsumer
 36  
     extends AbstractConsumer
 37  
 {
 38  
     private static final String TFS_TIMESTAMP_PATTERN = "MM/dd/yyyy";
 39  
 
 40  
     /* 3 username 3/13/2006 line */
 41  
     // TODO simplify
 42  
 
 43  
     private static final String LINE_PATTERN = "([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)";
 44  
 
 45  
     /**
 46  
      * @see #LINE_PATTERN
 47  
      */
 48  
     private RE lineRegexp;
 49  
 
 50  1
     private List<BlameLine> lines = new ArrayList<BlameLine>();
 51  
 
 52  
     public TfsBlameConsumer( ScmLogger logger )
 53  
     {
 54  1
         super( logger );
 55  1
         lineRegexp = new RE( LINE_PATTERN );
 56  1
     }
 57  
 
 58  
     public void consumeLine( String line )
 59  
     {
 60  3
         if ( lineRegexp.match( line ) )
 61  
         {
 62  3
             String revision = lineRegexp.getParen( 1 ).trim();
 63  3
             String author = lineRegexp.getParen( 2 ).trim();
 64  3
             String dateStr = lineRegexp.getParen( 3 ).trim();
 65  
 
 66  3
             Date date = parseDate( dateStr, null, TFS_TIMESTAMP_PATTERN );
 67  
 
 68  3
             lines.add( new BlameLine( date, revision, author ) );
 69  
         }
 70  3
     }
 71  
 
 72  
     public List<BlameLine> getLines()
 73  
     {
 74  3
         return lines;
 75  
     }
 76  
 }