1 package org.apache.maven.scm.provider.svn.svnexe.command.mkdir;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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.log.ScmLogger;
28 import org.codehaus.plexus.util.StringUtils;
29 import org.codehaus.plexus.util.cli.StreamConsumer;
30
31
32
33
34
35 public class SvnMkdirConsumer
36 implements StreamConsumer
37 {
38 private ScmLogger logger;
39
40 private static final String COMMITTED_REVISION_TOKEN = "Committed revision";
41
42 private int revision;
43
44 private List<ScmFile> createdDirs = new ArrayList<ScmFile>();
45
46 public SvnMkdirConsumer( ScmLogger logger )
47 {
48 this.logger = logger;
49 }
50
51
52 public void consumeLine( String line )
53 {
54 if ( StringUtils.isBlank( line ) )
55 {
56 return;
57 }
58
59 String statusString = line.substring( 0, 1 );
60 ScmFileStatus status;
61
62 if ( line.startsWith( COMMITTED_REVISION_TOKEN ) )
63 {
64 String revisionString = line.substring( COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1 );
65
66 revision = Integer.parseInt( revisionString );
67
68 return;
69 }
70 else if ( statusString.equals( "A" ) )
71 {
72 String file = line.substring( 3 );
73
74 status = ScmFileStatus.ADDED;
75
76 createdDirs.add( new ScmFile( file, status ) );
77 }
78 else
79 {
80 if ( logger.isInfoEnabled() )
81 {
82 logger.info( "Unknown line: '" + line + "'" );
83 }
84
85 return;
86 }
87 }
88
89 public int getRevision()
90 {
91 return revision;
92 }
93
94 public List<ScmFile> getCreatedDirs()
95 {
96 return createdDirs;
97 }
98 }