1 19 package org.netbeans.lib.cvsclient.command.log; 20 21 import java.io.*; 22 import java.util.*; 23 import java.text.SimpleDateFormat ; 24 25 import org.netbeans.lib.cvsclient.command.*; 26 import org.netbeans.lib.cvsclient.util.*; 27 28 34 public class LogInformation extends FileInfoContainer { 35 private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss Z"); private File file; 37 private String repositoryFilename; 38 private String headRevision; 39 private String branch; 40 private String accessList; 41 private String keywordSubstitution; 42 private String totalRevisions; 43 private String selectedRevisions; 44 private String description; 45 private String locks; 46 private final List revisions = new ArrayList(); 47 private final List symbolicNames = new ArrayList(); 48 49 public LogInformation() { 50 } 51 52 55 public File getFile() { 56 return file; 57 } 58 59 62 public void setFile(File file) { 63 this.file = file; 64 } 65 66 69 public String getRepositoryFilename() { 70 return repositoryFilename; 71 } 72 73 76 public void setRepositoryFilename(String repositoryFilename) { 77 this.repositoryFilename = repositoryFilename; 78 } 79 80 83 public String getHeadRevision() { 84 return headRevision; 85 } 86 87 90 public void setHeadRevision(String headRevision) { 91 this.headRevision = headRevision; 92 } 93 94 97 public String getBranch() { 98 return branch; 99 } 100 101 104 public void setBranch(String branch) { 105 this.branch = branch; 106 } 107 108 111 public String getAccessList() { 112 return accessList; 113 } 114 115 118 public void setAccessList(String accessList) { 119 this.accessList = accessList; 120 } 121 122 125 public String getKeywordSubstitution() { 126 return keywordSubstitution; 127 } 128 129 132 public void setKeywordSubstitution(String keywordSubstitution) { 133 this.keywordSubstitution = keywordSubstitution; 134 } 135 136 139 public String getTotalRevisions() { 140 return totalRevisions; 141 } 142 143 146 public void setTotalRevisions(String totalRevisions) { 147 this.totalRevisions = totalRevisions; 148 } 149 150 153 public String getSelectedRevisions() { 154 return selectedRevisions; 155 } 156 157 160 public void setSelectedRevisions(String selectedRevisions) { 161 this.selectedRevisions = selectedRevisions; 162 } 163 164 167 public String getDescription() { 168 return description; 169 } 170 171 174 public void setDescription(String description) { 175 this.description = description; 176 } 177 178 181 public String getLocks() { 182 return locks; 183 } 184 185 188 public void setLocks(String locks) { 189 this.locks = locks; 190 } 191 192 194 195 public void addRevision(LogInformation.Revision newRevision) { 196 revisions.add(newRevision); 197 } 198 199 202 public List getRevisionList() { 203 return revisions; 204 } 205 206 208 public LogInformation.Revision getRevision(String number) { 209 Iterator it = revisions.iterator(); 210 LogInformation.Revision item; 211 while (it.hasNext()) { 212 item = (LogInformation.Revision)it.next(); 213 if (item.getNumber().equals(number)) { 214 return item; 215 } 216 } 217 return null; 218 } 219 220 223 public void addSymbolicName(String symName, String revisionNumber) { 224 SymName newName = new SymName(); 225 newName.setName(symName); 226 newName.setRevision(revisionNumber); 227 symbolicNames.add(newName); 228 } 229 230 public List getAllSymbolicNames() { 231 return symbolicNames; 232 } 233 234 236 public List getSymNamesForRevision(String revNumber) { 237 Iterator it = symbolicNames.iterator(); 238 LogInformation.SymName item; 239 List list = new LinkedList(); 240 while (it.hasNext()) { 241 item = (LogInformation.SymName)it.next(); 242 if (item.getRevision().equals(revNumber)) { 243 list.add(item); 244 } 245 } 246 return list; 247 } 248 249 251 public LogInformation.SymName getSymName(String symName) { 252 Iterator it = symbolicNames.iterator(); 253 LogInformation.SymName item; 254 while (it.hasNext()) { 255 item = (LogInformation.SymName)it.next(); 256 if (item.getName().equals(symName)) { 257 return item; 258 } 259 } 260 return null; 261 } 262 263 public Revision createNewRevision(String number) { 264 Revision rev = new Revision(); 265 rev.setNumber(number); 266 return rev; 267 } 268 269 272 public String toString() { 273 StringBuffer buf = new StringBuffer (30); 274 buf.append("\nFile: " + ((file != null)?file.getAbsolutePath():"null")); buf.append("\nRepositoryFile: " + repositoryFilename); buf.append("\nHead revision: " + headRevision); return buf.toString(); 278 } 279 280 public class SymName { 281 private String name; 282 private String revision; 283 284 public SymName() { 285 } 286 287 public String getName() { 288 return name; 289 } 290 291 public void setName(String symName) { 292 name = symName; 293 } 294 295 public void setRevision(String rev) { 296 revision = rev; 297 } 298 299 public String getRevision() { 300 return revision; 301 } 302 303 308 public final boolean isBranch() { 309 boolean branch = false; 310 String [] nums = revision.split("\\."); 311 if (nums.length > 2 && (nums.length % 2) == 0) { 312 String lastButOne = nums[nums.length -2]; 313 branch = "0".equals(lastButOne); } 315 return branch; 316 } 317 } 318 319 public class Revision { 320 321 324 private String number; 325 328 private Date date; 329 332 private String dateString; 333 336 private String author; 337 340 private String state; 341 344 private String lines; 345 348 private String commitID; 349 352 private String message; 353 356 private String branches; 357 358 public Revision() { 359 370 } 371 372 373 public LogInformation getLogInfoHeader() { 374 return LogInformation.this; 375 } 376 377 public String getNumber() { 378 return number; 379 } 380 381 public void setNumber(String number) { 382 this.number = number; 383 } 384 385 public Date getDate() { 386 return date; 387 } 388 389 public String getDateString() { 390 return dateString; 391 } 392 393 396 public void setDateString(String dateString) { 397 this.dateString = dateString; 398 399 if (dateString == null) { 400 this.date = null; 401 return; 402 } 403 404 try { 406 dateString = dateString.replace('/', '-') + " +0000"; 409 this.date = DATE_FORMAT.parse(dateString); 410 } 411 catch (Exception ex) { 412 BugLog.getInstance().bug("Couldn't parse date " + dateString); 413 } 414 } 415 416 public void setDate(Date date, String dateString) { 417 this.dateString = dateString; 418 this.date = date; 419 } 420 421 public String getAuthor() { 422 return author; 423 } 424 425 public void setAuthor(String author) { 426 this.author = author; 427 } 428 429 public String getState() { 430 return state; 431 } 432 433 public void setState(String state) { 434 this.state = state; 435 } 436 437 public String getLines() { 438 return lines; 439 } 440 441 public void setLines(String lines) { 442 this.lines = lines; 443 } 444 445 public String getCommitID() { 446 return commitID; 447 } 448 449 public void setCommitID(String commitID) { 450 this.commitID = commitID; 451 } 452 455 public int getAddedLines() { 456 if (lines != null) { 457 int start = lines.indexOf('+'); 458 int end = lines.indexOf(' '); 459 if (start >= 0 && end > start) { 460 String added = lines.substring(start + 1, end); 461 try { 462 int toReturn = Integer.parseInt(added); 463 return toReturn; 464 } catch (NumberFormatException exc) { 465 } 467 } 468 } 469 return 0; 470 } 471 472 public int getRemovedLines() { 473 if (lines != null) { 474 int start = lines.indexOf('-'); 475 if (start >= 0) { 476 String removed = lines.substring(start + 1); 477 try { 478 int toReturn = Integer.parseInt(removed); 479 return toReturn; 480 } catch (NumberFormatException exc) { 481 } 483 } 484 } 485 return 0; 486 487 } 488 489 public String getMessage() { 490 return message; 491 } 492 493 public void setMessage(String message) { 494 this.message = message; 495 } 496 497 public String getBranches() { 498 return branches; 499 } 500 501 public void setBranches(String branches) { 502 this.branches = branches; 503 } 504 } 505 } 506 | Popular Tags |