1 package nl.toolforge.karma.core.vc.cvsimpl;
2
3 import org.apache.tools.ant.BuildEvent;
4 import org.apache.tools.ant.DefaultLogger;
5 import org.netbeans.lib.cvsclient.command.log.LogInformation;
6 import org.netbeans.lib.cvsclient.event.CVSListener;
7 import org.netbeans.lib.cvsclient.event.FileAddedEvent;
8 import org.netbeans.lib.cvsclient.event.FileInfoEvent;
9 import org.netbeans.lib.cvsclient.event.FileRemovedEvent;
10 import org.netbeans.lib.cvsclient.event.FileUpdatedEvent;
11 import org.netbeans.lib.cvsclient.event.ModuleExpansionEvent;
12 import org.netbeans.lib.cvsclient.event.TerminationEvent;
13
14
15
16
17
18 /***
19 * @author D.A. Smedes
20 * @version $Id: LogParser.java,v 1.1 2004/11/02 22:26:44 asmedes Exp $
21 */
22 public class LogParser extends DefaultLogger implements CVSListener {
23
24 private static final String SYM_NAME = "symbolic names:";
25 private static final String KEYWORD_SUBST = "keyword substitution: ";
26
27 private LogInformation logInfo = new LogInformation();
28
29 private boolean addingSymNames;
30
31 /***
32 * Filters symbolic names from a cvs log. The rest of the messages are ignored.
33 *
34 * @param event
35 */
36 public void messageLogged(BuildEvent event) {
37
38 int priority = event.getPriority();
39
40 if (priority <= msgOutputLevel) {
41
42 String line = event.getMessage();
43
44 if (addingSymNames) {
45 processSymbolicName(line);
46 } else if (line.startsWith(SYM_NAME)) {
47 addingSymNames = true;
48 } else if (line.startsWith(KEYWORD_SUBST)) {
49 addingSymNames = false;
50 }
51 }
52 System.out.println(event.getMessage());
53 }
54
55 private void processSymbolicName(String line) {
56 if (!line.startsWith(KEYWORD_SUBST)) {
57 line = line.trim();
58 int index = line.indexOf(':');
59 if (index > 0) {
60 String symName = line.substring(0, index).trim();
61 String revName = line.substring(index + 1, line.length()).trim();
62 logInfo.addSymbolicName(symName.intern(), revName.intern());
63 }
64 }
65 }
66
67 public LogInformation getLogInformation() {
68 return logInfo;
69 }
70
71
72
73
74 /***
75 * Not implemented for this implementation.
76 * @param e Not implemented for this implementation.
77 */
78 public void messageSent(org.netbeans.lib.cvsclient.event.MessageEvent e) { }
79
80 /***
81 * Not implemented for this implementation.
82 * @param e Not implemented for this implementation.
83 */
84 public void fileAdded(FileAddedEvent e) { }
85
86 /***
87 * Not implemented for this implementation.
88 * @param e Not implemented for this implementation.
89 */
90 public void fileRemoved(FileRemovedEvent e) { }
91
92 /***
93 * Not implemented for this implementation.
94 * @param e Not implemented for this implementation.
95 */
96 public void fileUpdated(FileUpdatedEvent e) { }
97
98 /***
99 * Not implemented for this implementation.
100 * @param e Not implemented for this implementation.
101 */
102 public void fileInfoGenerated(FileInfoEvent e) { }
103
104 /***
105 * Not implemented for this implementation.
106 * @param e Not implemented for this implementation.
107 */
108 public void commandTerminated(TerminationEvent e) { }
109
110 /***
111 * Not implemented for this implementation.
112 * @param e Not implemented for this implementation.
113 */
114 public void moduleExpanded(ModuleExpansionEvent e) { }
115 }