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
39 public class IntegrityBlameConsumer
40 implements StreamConsumer
41 {
42 private ScmLogger logger;
43
44 private List<BlameLine> blameList;
45
46 private SimpleDateFormat dateFormat;
47
48
49
50
51
52
53 public IntegrityBlameConsumer( ScmLogger logger )
54 {
55 this.logger = logger;
56 this.blameList = new ArrayList<BlameLine>();
57 this.dateFormat = new SimpleDateFormat( "MMM dd, yyyy z" );
58 }
59
60
61
62
63 public void consumeLine( String line )
64 {
65
66 logger.debug( line );
67 if ( null != line && line.trim().length() > 0 )
68 {
69 String[] tokens = StringUtils.split( line, "\t" );
70 if ( tokens.length != 3 )
71 {
72 logger.warn( "Failed to parse line: " + line );
73 }
74 else
75 {
76 try
77 {
78 blameList.add( new BlameLine( dateFormat.parse( tokens[0] ), tokens[1], tokens[2] ) );
79 }
80 catch ( ParseException e )
81 {
82 logger.error( "Failed to date string: " + tokens[0] );
83 }
84 }
85 }
86 }
87
88
89
90
91
92
93 public List<BlameLine> getBlameList()
94 {
95 return blameList;
96 }
97 }