1 package org.apache.maven.scm.provider.bazaar.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.ScmFileStatus;
23 import org.apache.maven.scm.command.blame.BlameLine;
24 import org.apache.maven.scm.log.ScmLogger;
25 import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
26
27 import java.util.ArrayList;
28 import java.util.Date;
29 import java.util.List;
30
31
32
33
34
35
36 public class BazaarBlameConsumer
37 extends BazaarConsumer
38 {
39 private static final String BAZAAR_TIMESTAMP_PATTERN = "yyyyMMdd";
40
41 private List<BlameLine> lines = new ArrayList<BlameLine>();
42
43 public BazaarBlameConsumer( ScmLogger logger )
44 {
45 super( logger );
46 }
47
48 public void doConsume( ScmFileStatus status, String trimmedLine )
49 {
50
51 String annotation = trimmedLine.substring( 0, trimmedLine.indexOf( '|' ) ).trim();
52
53 String dateStr = annotation.substring( annotation.lastIndexOf( ' ' ) + 1 );
54 annotation = annotation.substring( 0, annotation.lastIndexOf( ' ' ) );
55
56 String author = annotation.substring( annotation.lastIndexOf( ' ' ) + 1 );
57 annotation = annotation.substring( 0, annotation.lastIndexOf( ' ' ) );
58
59 String revision = annotation.trim();
60
61 Date date = parseDate( dateStr, null, BAZAAR_TIMESTAMP_PATTERN );
62
63 lines.add( new BlameLine( date, revision, author ) );
64 }
65
66 public List<BlameLine> getLines()
67 {
68 return lines;
69 }
70 }