1 19 package org.netbeans.lib.cvsclient.command.log; 20 21 import java.io.*; 22 import java.util.*; 23 24 import org.netbeans.lib.cvsclient.*; 25 import org.netbeans.lib.cvsclient.command.*; 26 import org.netbeans.lib.cvsclient.connection.*; 27 import org.netbeans.lib.cvsclient.event.*; 28 import org.netbeans.lib.cvsclient.request.*; 29 30 36 public class RlogCommand extends BasicCommand { 37 38 39 42 private final List modules = new LinkedList(); 43 44 47 private boolean defaultBranch; 48 49 52 private String dateFilter; 53 54 57 private boolean headerOnly; 58 59 62 private boolean suppressHeader; 63 64 67 private boolean noTags; 68 69 72 private String revisionFilter; 73 74 77 private String stateFilter; 78 79 82 private String userFilter; 83 84 87 private boolean headerAndDescOnly; 88 89 public RlogCommand() { 90 resetCVSCommand(); 91 } 92 93 97 public void setModule(String module) { 98 modules.add(module); 99 } 100 101 104 105 public void clearModules() { 106 this.modules.clear(); 107 } 108 109 113 public void setModules(String [] modules) { 114 clearModules(); 115 if (modules == null) { 116 return; 117 } 118 for (int i = 0; i < modules.length; i++) { 119 String module = modules[i]; 120 this.modules.add(module); 121 } 122 } 123 124 public String [] getModules() { 125 String [] mods = new String [modules.size()]; 126 mods = (String [])modules.toArray(mods); 127 return mods; 128 } 129 130 135 public boolean isDefaultBranch() { 136 return defaultBranch; 137 } 138 139 144 public void setDefaultBranch(boolean defaultBranch) { 145 this.defaultBranch = defaultBranch; 146 } 147 148 152 public String getDateFilter() { 153 return dateFilter; 154 } 155 156 159 public void setDateFilter(String dateFilter) { 160 this.dateFilter = dateFilter; 161 } 162 163 166 public boolean isHeaderOnly() { 167 return headerOnly; 168 } 169 170 173 public void setHeaderOnly(boolean headerOnly) { 174 this.headerOnly = headerOnly; 175 } 176 177 180 public boolean isSuppressHeader() { 181 return suppressHeader; 182 } 183 184 187 public void setSuppressHeader(boolean suppressHeader) { 188 this.suppressHeader = suppressHeader; 189 } 190 191 194 public boolean isNoTags() { 195 return noTags; 196 } 197 198 201 public void setNoTags(boolean noTags) { 202 this.noTags = noTags; 203 } 204 205 208 public String getRevisionFilter() { 209 return revisionFilter; 210 } 211 212 216 public void setRevisionFilter(String revisionFilter) { 217 this.revisionFilter = revisionFilter; 218 } 219 220 223 public String getStateFilter() { 224 return stateFilter; 225 } 226 227 230 public void setStateFilter(String stateFilter) { 231 this.stateFilter = stateFilter; 232 } 233 234 237 public String getUserFilter() { 238 return userFilter; 239 } 240 241 244 public void setUserFilter(String userFilter) { 245 this.userFilter = userFilter; 246 } 247 248 251 public boolean isHeaderAndDescOnly() { 252 return headerAndDescOnly; 253 } 254 255 258 public void setHeaderAndDescOnly(boolean headerAndDescOnly) { 259 this.headerAndDescOnly = headerAndDescOnly; 260 } 261 262 263 269 public void execute(ClientServices client, EventManager em) 270 throws CommandException, AuthenticationException { 271 272 client.ensureConnection(); 273 super.execute(client, em); 274 275 if (!isRecursive()) 279 { 280 requests.add(new ArgumentRequest("-l")); } 282 if (defaultBranch) { 284 requests.add(new ArgumentRequest("-b")); } 286 if (headerAndDescOnly) { 287 requests.add(new ArgumentRequest("-t")); } 289 if (headerOnly) { 290 requests.add(new ArgumentRequest("-h")); } 292 if (suppressHeader) { 293 requests.add(new ArgumentRequest("-S")); } 295 if (noTags) { 296 requests.add(new ArgumentRequest("-N")); } 298 if (userFilter != null) { 299 requests.add(new ArgumentRequest("-w" + userFilter)); } 301 if (revisionFilter != null) { 302 requests.add(new ArgumentRequest("-r" + revisionFilter)); } 304 if (stateFilter != null) { 305 requests.add(new ArgumentRequest("-s" + stateFilter)); } 307 if (dateFilter != null) { 308 requests.add(new ArgumentRequest("-d" + dateFilter)); } 310 311 for (Iterator it = modules.iterator(); it.hasNext();) { 312 String module = (String )it.next(); 313 requests.add(new ArgumentRequest(module)); 314 } 315 316 requests.add(CommandRequest.RLOG); 317 try { 318 client.processRequests(requests); 319 requests.clear(); 320 321 } 322 catch (CommandException ex) { 323 throw ex; 324 } 325 catch (Exception ex) { 326 throw new CommandException(ex, ex.getLocalizedMessage()); 327 } 328 } 329 330 334 protected boolean assumeLocalPathWhenUnspecified() { 335 return false; 336 } 337 338 public String getCVSCommand() { 339 StringBuffer toReturn = new StringBuffer ("rlog "); toReturn.append(getCVSArguments()); 341 if (modules != null && modules.size() > 0) { 342 for (Iterator it = modules.iterator(); it.hasNext();) { 343 String module = (String )it.next(); 344 toReturn.append(module); 345 toReturn.append(' '); 346 } 347 } 348 else { 349 String localizedMsg = CommandException.getLocalMessage("ExportCommand.moduleEmpty.text"); toReturn.append(" "); toReturn.append(localizedMsg); 352 } 353 return toReturn.toString(); 354 } 355 356 public String getCVSArguments() { 357 StringBuffer toReturn = new StringBuffer (""); if (isDefaultBranch()) { 359 toReturn.append("-b "); } 361 if (isHeaderAndDescOnly()) { 362 toReturn.append("-t "); } 364 if (isHeaderOnly()) { 365 toReturn.append("-h "); } 367 if (isSuppressHeader()) { 368 toReturn.append("-S "); } 370 if (isNoTags()) { 371 toReturn.append("-N "); } 373 if (!isRecursive()) { 374 toReturn.append("-l "); } 376 if (userFilter != null) { 377 toReturn.append("-w"); toReturn.append(userFilter); 379 toReturn.append(' '); 380 } 381 if (revisionFilter != null) { 382 toReturn.append("-r"); toReturn.append(revisionFilter); 384 toReturn.append(' '); 385 } 386 if (stateFilter != null) { 387 toReturn.append("-s"); toReturn.append(stateFilter); 389 toReturn.append(' '); 390 } 391 if (dateFilter != null) { 392 toReturn.append("-d"); toReturn.append(dateFilter); 394 toReturn.append(' '); 395 } 396 return toReturn.toString(); 397 } 398 399 public boolean setCVSCommand(char opt, String optArg) { 400 if (opt == 'R') { 401 setRecursive(true); 402 } 403 else if (opt == 'l') { 404 setRecursive(false); 405 } 406 else if (opt == 'b') { 407 setDefaultBranch(true); 408 } 409 else if (opt == 'h') { 410 setHeaderOnly(true); 411 } 412 else if (opt == 't') { 413 setHeaderAndDescOnly(true); 414 } 415 else if (opt == 'S') { 416 setSuppressHeader(true); 417 } 418 else if (opt == 'N') { 419 setNoTags(true); 420 } 421 else if (opt == 'd') { 422 setDateFilter(optArg); 423 } 424 else if (opt == 'r') { 425 setRevisionFilter(optArg == null ? "" : optArg); } 428 else if (opt == 's') { 429 setStateFilter(optArg); 430 } 431 else if (opt == 'w') { 432 setUserFilter(optArg == null ? "" : optArg); } 434 else { 435 return false; 436 } 437 return true; 438 } 439 440 public void resetCVSCommand() { 441 setRecursive(true); 442 setDefaultBranch(false); 443 setHeaderOnly(false); 444 setHeaderAndDescOnly(false); 445 setSuppressHeader(false); 446 setNoTags(false); 447 setDateFilter(null); 448 setRevisionFilter(null); 449 setStateFilter(null); 450 setUserFilter(null); 451 } 452 453 456 public String getOptString() { 457 return "RlbhStNd:r:s:w:"; } 459 460 461 465 public Builder createBuilder(EventManager eventMan) { 466 return new LogBuilder(eventMan, this); 467 } 468 } 469 | Popular Tags |