1 19 20 package org.netbeans.lib.cvsclient.command.watchers; 21 22 import java.io.*; 23 import java.util.*; 24 25 import org.netbeans.lib.cvsclient.command.*; 26 import org.netbeans.lib.cvsclient.util.*; 27 28 35 public class WatchersInformation extends FileInfoContainer { 36 37 public static final String WATCH_EDIT = "edit"; public static final String WATCH_UNEDIT = "unedit"; public static final String WATCH_COMMIT = "commit"; public static final String WATCH_TEMP_EDIT = "tedit"; public static final String WATCH_TEMP_UNEDIT = "tunedit"; public static final String WATCH_TEMP_COMMIT = "tcommit"; 44 47 private final File file; 48 49 53 private final List userList = new LinkedList(); 54 55 58 public WatchersInformation(File file) { 59 this.file = file; 60 } 61 62 65 public File getFile() { 66 return file; 67 } 68 69 74 void addWatcher(String watchingInfo) { 75 String temp = watchingInfo.trim(); 76 temp = temp.replace('\t', ' '); 77 int spaceIndex = temp.indexOf(' '); 78 if (spaceIndex < 0) { 79 } 81 else { 82 String user = temp.substring(0, spaceIndex); 83 String watches = temp.substring(spaceIndex + 1); 84 this.userList.add(new WatchersInformation.Watcher(user, watches)); 85 } 86 } 87 88 92 public Iterator getWatchersIterator() { 93 return this.userList.iterator(); 94 } 95 96 100 public static class Watcher { 101 102 private final String userName; 103 private final String watches; 104 private boolean watchingEdit; 105 private boolean watchingUnedit; 106 private boolean watchingCommit; 107 private boolean temporaryEdit; 108 private boolean temporaryUnedit; 109 private boolean temporaryCommit; 110 111 115 Watcher(String userName, String watches) { 116 this.userName = userName; 117 this.watches = watches; 118 119 final StringTokenizer tok = new StringTokenizer(watches, " ", false); 120 while (tok.hasMoreTokens()) { 121 String token = tok.nextToken(); 122 if (WATCH_EDIT.equals(token)) { 123 watchingEdit = true; 124 } 125 else if (WATCH_UNEDIT.equals(token)) { 126 watchingUnedit = true; 127 } 128 else if (WATCH_COMMIT.equals(token)) { 129 watchingCommit = true; 130 } 131 else if (WATCH_TEMP_COMMIT.equals(token)) { 132 temporaryCommit = true; 133 } 134 else if (WATCH_TEMP_EDIT.equals(token)) { 135 temporaryEdit = true; 136 } 137 else if (WATCH_TEMP_UNEDIT.equals(token)) { 138 temporaryUnedit = true; 139 } 140 else { 141 BugLog.getInstance().bug("unknown = " + token); 142 } 143 } 144 } 145 146 149 public String getUserName() { 150 return userName; 151 } 152 153 156 public String getWatches() { 157 return watches; 158 } 159 160 163 public boolean isWatchingCommit() { 164 return watchingCommit; 165 } 166 167 170 public boolean isWatchingEdit() { 171 return watchingEdit; 172 } 173 174 177 public boolean isWatchingUnedit() { 178 return watchingUnedit; 179 } 180 181 184 public boolean isTempWatchingCommit() { 185 return temporaryCommit; 186 } 187 188 191 public boolean isTempWatchingEdit() { 192 return temporaryEdit; 193 } 194 195 198 public boolean isTempWatchingUnedit() { 199 return temporaryUnedit; 200 } 201 } 202 } 203 | Popular Tags |