Coverage Report - org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
CvsListConsumer
0 %
0/14
0 %
0/8
2,333
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.list;
 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.LinkedList;
 23  
 import java.util.List;
 24  
 
 25  
 import org.apache.maven.scm.ScmFile;
 26  
 import org.apache.maven.scm.ScmFileStatus;
 27  
 import org.apache.maven.scm.log.ScmLogger;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 30  
 
 31  
 /**
 32  
  * Parses CVS/Entries format, for example, like
 33  
  *
 34  
  * <pre>
 35  
  * /checkoutlist/1.9/Wed Jan 26 19:08:06 2005/-kkv/
 36  
  * /commitinfo/1.10/Tue Jan 11 01:25:34 2005/-kkv/
 37  
  * /config/1.15/Sun Jan 23 02:15:57 2005/-kkv/
 38  
  * D/directory1////
 39  
  * D/directory2////
 40  
  * </pre>
 41  
  *
 42  
  * @author <a href="mailto:szakusov@emdev.ru">Sergey Zakusov</a>: implemented to fix "Unknown file status" problem
 43  
  * @version $Id: CvsListConsumer.java 1055646 2011-01-05 21:22:58Z olamy $
 44  
  */
 45  
 public class CvsListConsumer
 46  
     implements StreamConsumer
 47  
 {
 48  
     private ScmLogger logger;
 49  
 
 50  
     private List<ScmFile> entries;
 51  
 
 52  
     /**
 53  
      * @param logger is a logger
 54  
      */
 55  
     public CvsListConsumer( ScmLogger logger )
 56  0
     {
 57  0
         this.logger = logger;
 58  0
         this.entries = new LinkedList<ScmFile>();
 59  0
     }
 60  
 
 61  
     /** {@inheritDoc} */
 62  
     public void consumeLine( String i_line )
 63  
     {
 64  0
         if ( logger.isDebugEnabled() )
 65  
         {
 66  0
             logger.debug( i_line );
 67  
         }
 68  
 
 69  0
         String[] params = i_line.split( "/" );
 70  0
         if ( params.length < 2 )
 71  
         {
 72  0
             if ( StringUtils.isNotEmpty( i_line ) )
 73  
             {
 74  0
                 if ( logger.isWarnEnabled() )
 75  
                 {
 76  0
                     logger.warn( "Unable to parse it as CVS/Entries format: " + i_line + "." );
 77  
                 }
 78  
             }
 79  
         }
 80  
         else
 81  
         {
 82  0
             entries.add( new ScmFile( params[1], ScmFileStatus.UNKNOWN ) );
 83  
         }
 84  0
     }
 85  
 
 86  
     /**
 87  
      * @return Parse result
 88  
      */
 89  
     public List<ScmFile> getEntries()
 90  
     {
 91  0
         return entries;
 92  
     }
 93  
 }