Coverage Report - org.apache.maven.scm.provider.cvslib.command.tag.CvsTagConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
CvsTagConsumer
0 %
0/19
0 %
0/12
3,333
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.tag;
 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.ScmFile;
 23  
 import org.apache.maven.scm.ScmFileStatus;
 24  
 import org.apache.maven.scm.log.ScmLogger;
 25  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 26  
 import org.codehaus.plexus.util.StringUtils;
 27  
 
 28  
 import java.util.ArrayList;
 29  
 import java.util.List;
 30  
 
 31  
 /**
 32  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 33  
  * @author Olivier Lamy
 34  
  * @version $Id: CvsTagConsumer.java 1054399 2011-01-02 13:19:52Z olamy $
 35  
  */
 36  
 public class CvsTagConsumer
 37  
     implements StreamConsumer
 38  
 {
 39  
     private ScmLogger logger;
 40  
 
 41  0
     private List<ScmFile> files = new ArrayList<ScmFile>();
 42  
 
 43  
     public CvsTagConsumer( ScmLogger logger )
 44  0
     {
 45  0
         this.logger = logger;
 46  0
     }
 47  
 
 48  
     /** {@inheritDoc} */
 49  
     public void consumeLine( String line )
 50  
     {
 51  0
         if ( logger.isDebugEnabled() )
 52  
         {
 53  0
             logger.debug( line );
 54  
         }
 55  
 
 56  0
         if ( line.length() < 3 )
 57  
         {
 58  0
             if ( StringUtils.isNotEmpty( line ) )
 59  
             {
 60  0
                 if ( logger.isWarnEnabled() )
 61  
                 {
 62  0
                     logger.warn( "Unable to parse output from command: line length must be bigger than 3. ("
 63  
                         + line + ")." );
 64  
                 }
 65  
             }
 66  0
             return;
 67  
         }
 68  
 
 69  0
         String status = line.substring( 0, 2 );
 70  
 
 71  0
         String file = line.substring( 2 );
 72  
 
 73  0
         if ( status.equals( "T " ) )
 74  
         {
 75  0
             files.add( new ScmFile( file, ScmFileStatus.TAGGED ) );
 76  
         }
 77  
         else
 78  
         {
 79  0
             if ( logger.isWarnEnabled() )
 80  
             {
 81  0
                 logger.warn( "Unknown status: '" + status + "'." );
 82  
             }
 83  
         }
 84  0
     }
 85  
 
 86  
     public List<ScmFile> getTaggedFiles()
 87  
     {
 88  0
         return files;
 89  
     }
 90  
 }