1 22 package org.netbeans.lib.cvsclient.command.status; 23 24 import java.io.*; 25 import java.util.*; 26 27 import org.netbeans.lib.cvsclient.command.*; 28 import org.netbeans.lib.cvsclient.file.*; 29 30 36 public class StatusInformation extends FileInfoContainer { 37 39 private File file; 40 private FileStatus status; 41 private String workingRevision; 42 private String repositoryRevision; 43 private String repositoryFileName; 44 private String stickyDate; 45 private String stickyOptions; 46 private String stickyTag; 47 48 51 private List tags; 52 53 private StringBuffer symNamesBuffer; 54 55 public StatusInformation() { 56 setAllExistingTags(null); 57 } 58 59 63 public File getFile() { 64 return file; 65 } 66 67 71 public void setFile(File file) { 72 this.file = file; 73 } 74 75 79 public FileStatus getStatus() { 80 return status; 81 } 82 83 87 public void setStatus(FileStatus status) { 88 this.status = status; 89 } 90 91 95 public String getStatusString() { 96 if (status == null) { 97 return null; 98 } 99 100 return status.toString(); 101 } 102 103 106 public void setStatusString(String statusString) { 107 setStatus(FileStatus.getStatusForString(statusString)); 108 } 109 110 114 public String getWorkingRevision() { 115 return workingRevision; 116 } 117 118 122 public void setWorkingRevision(String workingRevision) { 123 this.workingRevision = workingRevision; 124 } 125 126 130 public String getRepositoryRevision() { 131 return repositoryRevision; 132 } 133 134 138 public void setRepositoryRevision(String repositoryRevision) { 139 this.repositoryRevision = repositoryRevision; 140 } 141 142 146 public String getRepositoryFileName() { 147 return repositoryFileName; 148 } 149 150 154 public void setRepositoryFileName(String repositoryFileName) { 155 this.repositoryFileName = repositoryFileName; 156 } 157 158 162 public String getStickyTag() { 163 return stickyTag; 164 } 165 166 170 public void setStickyTag(String stickyTag) { 171 this.stickyTag = stickyTag; 172 } 173 174 178 public String getStickyDate() { 179 return stickyDate; 180 } 181 182 186 public void setStickyDate(String stickyDate) { 187 this.stickyDate = stickyDate; 188 } 189 190 194 public String getStickyOptions() { 195 return stickyOptions; 196 } 197 198 202 public void setStickyOptions(String stickyOptions) { 203 this.stickyOptions = stickyOptions; 204 } 205 206 public void addExistingTag(String tagName, String revisionNumber) { 207 if (symNamesBuffer == null) { 208 symNamesBuffer = new StringBuffer (); 209 } 210 symNamesBuffer.append(tagName); 211 symNamesBuffer.append(" "); symNamesBuffer.append(revisionNumber); 213 symNamesBuffer.append("\n"); } 215 216 private void createSymNames() { 217 tags = new LinkedList(); 218 219 if (symNamesBuffer == null) { 220 return; 221 } 222 223 int length = 0; 224 int lastLength = 0; 225 while (length < symNamesBuffer.length()) { 226 while (length < symNamesBuffer.length() && symNamesBuffer.charAt(length) != '\n') { 227 length++; 228 } 229 230 if (length > lastLength) { 231 String line = symNamesBuffer.substring(lastLength, length); 232 String symName = line.substring(0, line.indexOf(' ')); 233 String revisionNumber = line.substring(line.indexOf(' ') + 1); 234 SymName newName = new SymName(); 235 newName.setTag(symName); 236 newName.setRevision(revisionNumber); 237 tags.add(newName); 238 lastLength = length + 1; 239 length++; 240 } 241 } 242 243 symNamesBuffer = null; 244 } 245 246 public List getAllExistingTags() { 247 if (tags == null) { 248 createSymNames(); 249 } 250 return tags; 251 } 252 253 public void setAllExistingTags(List tags) { 254 this.tags = tags; 255 } 256 257 259 public List getSymNamesForRevision(String revNumber) { 260 if (tags == null) { 261 createSymNames(); 262 } 263 264 List list = new LinkedList(); 265 266 for (Iterator it = tags.iterator(); it.hasNext();) { 267 StatusInformation.SymName item = (StatusInformation.SymName)it.next(); 268 if (item.getRevision().equals(revNumber)) { 269 list.add(item); 270 } 271 } 272 return list; 273 } 274 275 279 public StatusInformation.SymName getSymNameForTag(String tagName) { 280 if (tags == null) { 281 createSymNames(); 282 } 283 284 for (Iterator it = tags.iterator(); it.hasNext();) { 285 StatusInformation.SymName item = (StatusInformation.SymName)it.next(); 286 if (item.getTag().equals(tagName)) { 287 return item; 288 } 289 } 290 return null; 291 } 292 293 296 public String toString() { 297 StringBuffer buf = new StringBuffer (); 298 buf.append("\nFile: "); buf.append((file != null) ? file.getAbsolutePath() 300 : "null"); buf.append("\nStatus is: "); buf.append(getStatusString()); 303 buf.append("\nWorking revision: "); buf.append(workingRevision); 305 buf.append("\nRepository revision: "); buf.append("\nSticky date: "); buf.append(stickyDate); 308 buf.append("\nSticky options: "); buf.append(stickyOptions); 310 buf.append("\nSticky tag: "); buf.append(stickyTag); 312 if (tags != null && tags.size() > 0) { 313 buf.append("\nExisting Tags:"); for (Iterator it = tags.iterator(); it.hasNext();) { 316 buf.append("\n "); buf.append(it.next().toString()); 318 } 319 } 320 return buf.toString(); 321 } 322 323 327 public static class SymName { 328 private String tag; 329 private String revision; 330 331 public SymName() { 332 } 333 334 public String getTag() { 335 return tag; 336 } 337 338 public void setTag(String symName) { 339 tag = symName; 340 } 341 342 public void setRevision(String rev) { 343 revision = rev; 344 } 345 346 public String getRevision() { 347 return revision; 348 } 349 350 public String toString() { 351 return getTag() + " : " + getRevision(); } 353 } 354 } 355 | Popular Tags |