|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.lib.cvsclient.command.diff;
import java.io.*;
import org.netbeans.lib.cvsclient.*;
import org.netbeans.lib.cvsclient.command.*;
import org.netbeans.lib.cvsclient.connection.*;
import org.netbeans.lib.cvsclient.event.*;
import org.netbeans.lib.cvsclient.request.*;
/**
* The status command looks up the status of files in the repository
* @author Robert Greig
*/
public class DiffCommand extends BasicCommand {
/**
* The event manager to use
*/
protected EventManager eventManager;
/**
* Holds value of property beforeDate.
*/
private String beforeDate1;
/**
* Holds value of property firstRevision.
*/
private String revision1;
/**
* Holds value of property secondRevision.
*/
private String revision2;
/**
* Holds value of property beforeDate2.
*/
private String beforeDate2;
/**
* Keyword substitution. The -k switch in command line cvs.
*/
private String keywordSubst;
/** Holds value of property ignoreAllWhitespace. */
private boolean ignoreAllWhitespace;
/** Holds value of property ignoreBlankLines. */
private boolean ignoreBlankLines;
/** Holds value of property ignoreCase. */
private boolean ignoreCase;
/** Holds value of property ignoreSpaceChange. */
private boolean ignoreSpaceChange;
/** Holds value of property contextDiff. */
private boolean contextDiff;
/** Holds value of property unifiedDiff. */
private boolean unifiedDiff;
/**
* Construct a new diff command
*/
public DiffCommand() {
}
/**
* Create a builder for this command.
* @param eventMan the event manager used to receive events.
*/
public Builder createBuilder(EventManager eventMan) {
if (isContextDiff() || isUnifiedDiff()) {
return null;
}
return new SimpleDiffBuilder(eventMan, this);
}
/**
* Execute a command
* @param client the client services object that provides any necessary
* services to this command, including the ability to actually process
* all the requests.
*/
public void execute(ClientServices client, EventManager em)
throws CommandException, AuthenticationException {
client.ensureConnection();
eventManager = em;
super.execute(client, em);
try {
// parameters come now..
addRDSwitches();
if (getKeywordSubst() != null && !getKeywordSubst().equals("")) { //NOI18N
requests.add(new ArgumentRequest("-k" + getKeywordSubst())); //NOI18N
}
addArgumentRequest(isIgnoreAllWhitespace(), "-w"); //NOI18N
addArgumentRequest(isIgnoreBlankLines(), "-B"); //NOI18N
addArgumentRequest(isIgnoreSpaceChange(), "-b"); //NOI18N
addArgumentRequest(isIgnoreCase(), "-i"); //NOI18N
addArgumentRequest(isContextDiff(), "-c"); //NOI18N
addArgumentRequest(isUnifiedDiff(), "-u"); //NOI18N
addRequestForWorkingDirectory(client);
addArgumentRequests();
addRequest(CommandRequest.DIFF);
client.processRequests(requests);
}
catch (CommandException ex) {
throw ex;
}
catch (Exception ex) {
throw new CommandException(ex, ex.getLocalizedMessage());
}
finally {
requests.clear();
}
}
/**
* includes the logic of setting the -r and -D switches to the diff command
*/
private void addRDSwitches() {
if (getRevision2() != null) {
requests.add(1, new ArgumentRequest("-r")); //NOI18N
requests.add(2, new ArgumentRequest(getRevision2()));
}
else {
if (getBeforeDate2() != null) {
requests.add(1, new ArgumentRequest("-D " + getBeforeDate2())); //NOI18N
}
}
// -r switch has precendence over the -d switch - is that right??
if (getRevision1() != null) {
requests.add(1, new ArgumentRequest("-r")); //NOI18N
requests.add(2, new ArgumentRequest(getRevision1()));
}
else {
if (getBeforeDate1() != null) {
requests.add(1, new ArgumentRequest("-D " + getBeforeDate1())); //NOI18N
}
else {
// when neither revision nor flag is set for the command, it is assumed
// that the second parameters are not set either..
return;
}
}
}
/** called when server responses with "ok" or "error", (when the command finishes)
*/
public void commandTerminated(TerminationEvent e) {
if (builder != null) {
builder.outputDone();
}
}
/** Getter for property beforeDate.
* @return Value of property beforeDate.
*/
public String getBeforeDate1() {
return beforeDate1;
}
/** Setter for property beforeDate.
* @param beforeDate New value of property beforeDate.
*/
public void setBeforeDate1(String beforeDate) {
this.beforeDate1 = beforeDate;
}
/** Getter for property firstRevision.
* @return Value of property firstRevision.
*/
public String getRevision1() {
return revision1;
}
/** Setter for property firstRevision.
* @param firstRevision New value of property firstRevision.
*/
public void setRevision1(String firstRevision) {
revision1 = firstRevision;
}
/** Getter for property secondRevision.
* @return Value of property secondRevision.
*/
public String getRevision2() {
return revision2;
}
/** Setter for property secondRevision.
* @param secondRevision New value of property secondRevision.
*/
public void setRevision2(String secondRevision) {
this.revision2 = secondRevision;
}
/** Getter for property beforeDate2.
* @return Value of property beforeDate2.
*/
public String getBeforeDate2() {
return beforeDate2;
}
/** Setter for property beforeDate2.
* @param beforeDate2 New value of property beforeDate2.
*/
public void setBeforeDate2(String beforeDate2) {
this.beforeDate2 = beforeDate2;
}
/**
* Getter for property keywordSubst.
* @return Value of property keywordSubst.
*/
public String getKeywordSubst() {
return keywordSubst;
}
/**
* Setter for property keywordSubst.
* @param keywordSubst New value of property keywordSubst.
*/
public void setKeywordSubst(String keywordSubst) {
this.keywordSubst = keywordSubst;
}
/** This method returns how the command would looklike when typed on the command line.
* Each command is responsible for constructing this information.
* @returns
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.