View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.maven.scm.provider.bazaar.command.tag;
21  
22  import java.io.File;
23  import java.util.LinkedList;
24  import java.util.List;
25  
26  import org.apache.maven.scm.ScmFile;
27  import org.apache.maven.scm.ScmFileStatus;
28  import org.apache.maven.scm.log.ScmLogger;
29  import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
30  
31  /**
32   * Parse output from "bzr ls".
33   * @author <a href="mailto:johan.walles@gmail.com">Johan Walles</a>
34   * @author Olivier Lamy
35   *
36   */
37  class BazaarLsConsumer extends BazaarConsumer {
38      /**
39       * The root directory of this bazaar repository.
40       */
41      private File repositoryRoot;
42      
43      /**
44       * A list of the files found by ls.
45       */
46      private List<ScmFile> files;
47      
48      /**
49       * Create a new "bzr ls" consumer.
50       * @param repositoryRoot The root directory of this bazaar repository.
51       * @param wantedStatus The status we'll report for the files listed.
52       */
53      public BazaarLsConsumer(ScmLogger logger,
54              File repositoryRoot,
55              ScmFileStatus wantedStatus) 
56      {
57          super( logger );
58          files = new LinkedList<ScmFile>();
59      }
60      
61      public void doConsume( ScmFileStatus status, String trimmedLine ) {
62          if ( trimmedLine.endsWith( File.separator ) ) {
63              // Don't report directories
64              return;
65          }
66          
67          String path = new File( repositoryRoot, trimmedLine ).toString();
68          files.add( new ScmFile( path, ScmFileStatus.TAGGED ) );
69      }
70      
71      /**
72       * Answer what files were listed by bzr ls.
73       * @return A list of files listed by bzr ls.
74       */
75      public List<ScmFile> getListedFiles() {
76          return files;
77      }
78  }