1 package org.apache.maven.scm.provider.accurev.cli;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.List;
24 import java.util.regex.Matcher;
25 import java.util.regex.Pattern;
26
27 import org.codehaus.plexus.util.cli.StreamConsumer;
28
29
30
31
32 class FileConsumer
33 implements StreamConsumer
34 {
35 private Pattern filePattern;
36
37 public FileConsumer( List<File> matchedFilesAccumulator, Pattern filematcher )
38 {
39 this.matchedFiles = matchedFilesAccumulator;
40 this.filePattern = filematcher;
41 }
42
43 private List<File> matchedFiles;
44
45
46 public static final Pattern ADD_PATTERN = Pattern.compile( "Added and kept element [/\\\\]\\.[/\\\\](\\S+)\\s*" );
47
48 public static final Pattern UPDATE_PATTERN = Pattern
49 .compile( "Updating element [/\\\\]\\.[/\\\\](\\S+)\\s*|Content.*of \"(.*)\".*" );
50
51 public static final Pattern POPULATE_PATTERN = Pattern.compile( "Populating element [/\\\\]\\.[/\\\\](\\S+)\\s*" );
52
53 public static final Pattern PROMOTE_PATTERN = Pattern.compile( "Promoted element [/\\\\]\\.[/\\\\](\\S+)\\s*" );
54
55 public static final Pattern STAT_PATTERN = Pattern.compile( "[/\\\\]\\.[/\\\\](.*)" );
56
57
58
59
60 public static final Pattern DEFUNCT_PATTERN = Pattern.compile( "Removing \"(\\S+)\".*" );
61
62 public void consumeLine( String line )
63 {
64
65 Matcher m = filePattern.matcher( line );
66 if ( m.matches() )
67 {
68
69 int i = 1;
70 String fileName = null;
71 while ( fileName == null && i <= m.groupCount() )
72 {
73 fileName = m.group( i++ );
74 }
75
76 if ( fileName != null )
77 {
78 matchedFiles.add( new File( fileName ) );
79 }
80 }
81
82 }
83 }