1 19 package org.netbeans.lib.cvsclient.command.watchers; 20 21 import java.io.*; 22 23 import org.netbeans.lib.cvsclient.command.*; 24 import org.netbeans.lib.cvsclient.event.*; 25 import org.netbeans.lib.cvsclient.util.*; 26 27 33 public class WatchersBuilder implements Builder { 34 35 private static final String UNKNOWN_FILE = "? "; 37 40 private WatchersInformation watchersInfo; 41 42 45 private final EventManager eventManager; 46 47 51 private final String localPath; 52 53 58 public WatchersBuilder(EventManager eventManager, String localPath) { 59 this.eventManager = eventManager; 60 this.localPath = localPath; 61 } 62 63 public void outputDone() { 64 if (watchersInfo != null) { 65 eventManager.fireCVSEvent(new FileInfoEvent(this, watchersInfo)); 66 watchersInfo = null; 67 } 68 } 69 70 public void parseLine(String line, boolean isErrorMessage) { 71 if (line.startsWith(UNKNOWN_FILE)) { 72 File file = new File(localPath, line.substring(UNKNOWN_FILE.length())); 73 watchersInfo = new WatchersInformation(file); 74 outputDone(); 75 return; 76 } 77 78 if (isErrorMessage) { 79 return; 80 } 81 82 if (line.startsWith(" ") || line.startsWith("\t")) { BugLog.getInstance().assertNotNull(watchersInfo); 84 85 watchersInfo.addWatcher(line); 86 return; 87 } 88 89 outputDone(); 91 String trimmedLine = line.trim().replace('\t', ' '); 92 int spaceIndex = trimmedLine.indexOf(' '); 93 94 BugLog.getInstance().assertTrue(spaceIndex > 0, "Wrong line = " + line); 95 96 File file = new File(localPath, 97 trimmedLine.substring(0, spaceIndex)); 98 String watcher = trimmedLine.substring(spaceIndex + 1); 99 watchersInfo = new WatchersInformation(file); 100 watchersInfo.addWatcher(watcher); 101 } 102 103 public void parseEnhancedMessage(String key, Object value) { 104 } 105 } 106 | Popular Tags |