1 package org.apache.maven.scm.provider.integrity.command.blame;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.command.blame.BlameLine;
23 import org.apache.maven.scm.log.ScmLogger;
24 import org.codehaus.plexus.util.StringUtils;
25 import org.codehaus.plexus.util.cli.StreamConsumer;
26
27 import java.text.ParseException;
28 import java.text.SimpleDateFormat;
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35
36
37
38 public class IntegrityBlameConsumer
39 implements StreamConsumer
40 {
41 private ScmLogger logger;
42
43 private List<BlameLine> blameList;
44
45 private SimpleDateFormat dateFormat;
46
47
48
49
50
51
52 public IntegrityBlameConsumer( ScmLogger logger )
53 {
54 this.logger = logger;
55 this.blameList = new ArrayList<BlameLine>();
56 this.dateFormat = new SimpleDateFormat( "MMM dd, yyyy z" );
57 }
58
59
60
61
62 public void consumeLine( String line )
63 {
64
65 logger.debug( line );
66 if ( null != line && line.trim().length() > 0 )
67 {
68 String[] tokens = StringUtils.split( line, "\t" );
69 if ( tokens.length != 3 )
70 {
71 logger.warn( "Failed to parse line: " + line );
72 }
73 else
74 {
75 try
76 {
77 blameList.add( new BlameLine( dateFormat.parse( tokens[0] ), tokens[1], tokens[2] ) );
78 }
79 catch ( ParseException e )
80 {
81 logger.error( "Failed to date string: " + tokens[0] );
82 }
83 }
84 }
85 }
86
87
88
89
90
91
92 public List<BlameLine> getBlameList()
93 {
94 return blameList;
95 }
96 }