KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > command > checkout > ModuleListBuilder


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.cvsclient.command.checkout;
21
22 import java.util.*;
23
24 import org.netbeans.lib.cvsclient.command.*;
25 import org.netbeans.lib.cvsclient.event.*;
26
27 /**
28  * Handles the building of module list information object and the firing of
29  * events when complete objects are built.
30  *
31  * @author Milos Kleint
32  */

33 public class ModuleListBuilder implements Builder {
34     /**
35      * The module object that is currently being built.
36      */

37     private ModuleListInformation moduleInformation;
38
39     /**
40      * The event manager to use.
41      */

42     private final EventManager eventManager;
43
44     private final CheckoutCommand checkoutCommand;
45
46     public ModuleListBuilder(EventManager eventMan, CheckoutCommand comm) {
47         eventManager = eventMan;
48         checkoutCommand = comm;
49     }
50
51     public void outputDone() {
52         if (moduleInformation != null) {
53             eventManager.fireCVSEvent(new FileInfoEvent(this, moduleInformation));
54             moduleInformation = null;
55         }
56     }
57
58     public void parseLine(String JavaDoc line, boolean isErrorMessage) {
59         line = line.replace('\t', ' ');
60         if (!line.startsWith(" ")) { //NOI18N
61
processModule(line, true);
62         }
63         else {
64             processModule(line, false);
65         }
66     }
67
68     protected void processModule(String JavaDoc line, boolean firstLine) {
69         StringTokenizer tok = new StringTokenizer(line, " ", false); //NOI18N
70
if (firstLine) {
71             outputDone();
72             moduleInformation = new ModuleListInformation();
73             String JavaDoc modName = tok.nextToken();
74             moduleInformation.setModuleName(modName);
75             if (checkoutCommand.isShowModulesWithStatus()) {
76                 String JavaDoc stat = tok.nextToken();
77                 moduleInformation.setModuleStatus(stat);
78             }
79         }
80         while (tok.hasMoreTokens()) {
81             String JavaDoc nextTok = tok.nextToken();
82             if (nextTok.startsWith("-")) { //NOI18N
83
moduleInformation.setType(nextTok);
84                 continue;
85             }
86             moduleInformation.addPath(nextTok);
87         }
88     }
89
90     public void parseEnhancedMessage(String JavaDoc key, Object JavaDoc value) {
91     }
92 }
93
Popular Tags