View Javadoc
1   package org.apache.maven.scm.provider.svn.svnexe.command.mkdir;
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.ArrayList;
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.util.AbstractConsumer;
28  import org.codehaus.plexus.util.StringUtils;
29  
30  /**
31   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
32   *
33   */
34  public class SvnMkdirConsumer
35          extends AbstractConsumer
36  {
37      private static final String COMMITTED_REVISION_TOKEN = "Committed revision";
38  
39      private int revision;
40      
41      private final List<ScmFile> createdDirs = new ArrayList<>();
42  
43      /** {@inheritDoc} */
44      public void consumeLine( String line )
45      {
46          if ( StringUtils.isBlank( line ) )
47          {
48              return;
49          }
50          
51          String statusString = line.substring( 0, 1 );
52          ScmFileStatus status;
53         
54          if ( line.startsWith( COMMITTED_REVISION_TOKEN ) )
55          {
56              String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 );
57  
58              revision = Integer.parseInt( revisionString );
59              
60              return;
61          }
62          else if ( statusString.equals( "A" ) )
63          {
64              String file = line.substring( 3 );
65              
66              status = ScmFileStatus.ADDED;
67              
68              createdDirs.add( new ScmFile( file, status ) );
69          }        
70          else
71          {
72              if ( logger.isInfoEnabled() )
73              {
74                  logger.info( "Unknown line: '" + line + "'" );
75              }
76  
77              return;
78          }
79      }
80  
81      public int getRevision()
82      {
83          return revision;
84      }
85      
86      public List<ScmFile> getCreatedDirs()
87      {
88          return createdDirs;
89      }
90  }