Browse Source

Layout code

Enforce naming guidelines


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270638 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 24 years ago
parent
commit
3fa5d5e35c
7 changed files with 176 additions and 195 deletions
  1. +34
    -35
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java
  2. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java
  3. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java
  4. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java
  5. +83
    -90
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java
  6. +32
    -41
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java
  7. +20
    -22
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java

+ 34
- 35
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java View File

@@ -54,22 +54,21 @@

package org.apache.tools.ant.taskdefs.optional.ccm;

import java.io.File;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;


import java.io.File;

/**
* Class common to all check commands (checkout, checkin,checkin default task);
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMCheck extends Continuus {

private File _file = null;
private String _comment = null;
private String _task = null;
private File file = null;
private String comment = null;
private String task = null;

public CCMCheck() {
super();
@@ -80,51 +79,51 @@ public class CCMCheck extends Continuus {
* @return value of file.
*/
public File getFile() {
return _file;
return file;
}
/**
* Set the value of file.
* @param v Value to assign to file.
*/
public void setFile(File v) {
this._file = v;
public void setFile(File v) {
this.file = v;
}
/**
* Get the value of comment.
* @return value of comment.
*/
public String getComment() {
return _comment;
return comment;
}
/**
* Set the value of comment.
* @param v Value to assign to comment.
*/
public void setComment(String v) {
this._comment = v;
public void setComment(String v) {
this.comment = v;
}

/**
* Get the value of task.
* @return value of task.
*/
public String getTask() {
return _task;
return task;
}
/**
* Set the value of task.
* @param v Value to assign to task.
*/
public void setTask(String v) {
this._task = v;
public void setTask(String v) {
this.task = v;
}
/**
* Executes the task.
* <p>
@@ -142,11 +141,11 @@ public class CCMCheck extends Continuus {
// as specified in the CLEARTOOL.EXE help
commandLine.setExecutable(getCcmCommand());
commandLine.createArgument().setValue(getCcmAction());
checkOptions(commandLine);

result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
@@ -156,30 +155,30 @@ public class CCMCheck extends Continuus {
/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
private void checkOptions(Commandline cmd) {
if (getComment() != null) {
cmd.createArgument().setValue(FLAG_COMMENT);
cmd.createArgument().setValue(getComment());
}

if ( getTask() != null) {
if (getTask() != null) {
cmd.createArgument().setValue(FLAG_TASK);
cmd.createArgument().setValue(getTask());
} // end of if ()
if ( getFile() != null ) {
cmd.createArgument().setValue(_file.getAbsolutePath());
} // end of if ()
cmd.createArgument().setValue(getTask());
} // end of if ()
if (getFile() != null) {
cmd.createArgument().setValue(file.getAbsolutePath());
} // end of if ()
}
/**
* -comment flag -- comment to attach to the file
*/
public final static String FLAG_COMMENT = "/comment";
/**
* -task flag -- associate checckout task with task
*/
public final static String FLAG_TASK = "/task";
public final static String FLAG_TASK = "/task";
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java View File

@@ -61,11 +61,11 @@ import java.util.Date;
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMCheckin extends CCMCheck {
public CCMCheckin() {
super();
setCcmAction(COMMAND_CHECKIN);
setComment("Checkin "+ new Date());
setComment("Checkin " + new Date());
}

}


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckinDefault.java View File

@@ -59,13 +59,13 @@ package org.apache.tools.ant.taskdefs.optional.ccm;
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMCheckinDefault extends CCMCheck {
public CCMCheckinDefault(){
public CCMCheckinDefault() {
super();
setCcmAction(COMMAND_CHECKIN);
setTask(DEFAULT_TASK);
}

public final static String DEFAULT_TASK = "default";
public final static String DEFAULT_TASK = "default";
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java View File

@@ -59,8 +59,8 @@ package org.apache.tools.ant.taskdefs.optional.ccm;
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMCheckout extends CCMCheck {
public CCMCheckout(){
public CCMCheckout() {
super();
setCcmAction(COMMAND_CHECKOUT);
}


+ 83
- 90
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java View File

@@ -56,7 +56,6 @@ package org.apache.tools.ant.taskdefs.optional.ccm;


import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -72,21 +71,21 @@ import org.apache.tools.ant.types.Commandline;
* Task allows to create new ccm task and set it as the default
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {

private String comment = null;
private String platform = null;
private String resolver = null;
private String release = null;
private String comment = null;
private String platform = null;
private String resolver = null;
private String release = null;
private String subSystem = null;
private String task = null;
private String task = null;

public CCMCreateTask() {
super();
setCcmAction(COMMAND_CREATE_TASK);
}

/**
* Executes the task.
* <p>
@@ -99,15 +98,15 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
Project aProj = getProject();
int result = 0;

// build the command line from what we got the format
// build the command line from what we got the format
// as specified in the CCM.EXE help
commandLine.setExecutable(getCcmCommand());
commandLine.createArgument().setValue(getCcmAction());
checkOptions(commandLine);
result = run(commandLine,this);
if ( result != 0 ) {
result = run(commandLine, this);
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
@@ -118,10 +117,10 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
commandLine2.createArgument().setValue(COMMAND_DEFAULT_TASK);
commandLine2.createArgument().setValue(getTask());

log(commandLine.toString(),Project.MSG_DEBUG);
log(commandLine.toString(), Project.MSG_DEBUG);

result = run(commandLine2);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine2.toString();
throw new BuildException(msg, location);
}
@@ -132,34 +131,34 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
private void checkOptions(Commandline cmd) {
if (getComment() != null) {
cmd.createArgument().setValue(FLAG_COMMENT);
cmd.createArgument().setValue("\""+getComment()+"\"");
cmd.createArgument().setValue("\"" + getComment() + "\"");
}

if ( getPlatform() != null) {
if (getPlatform() != null) {
cmd.createArgument().setValue(FLAG_PLATFORM);
cmd.createArgument().setValue(getPlatform());
} // end of if ()
cmd.createArgument().setValue(getPlatform());
} // end of if ()

if ( getResolver() != null) {
if (getResolver() != null) {
cmd.createArgument().setValue(FLAG_RESOLVER);
cmd.createArgument().setValue(getResolver());
cmd.createArgument().setValue(getResolver());
} // end of if ()
if ( getSubSystem() != null) {
if (getSubSystem() != null) {
cmd.createArgument().setValue(FLAG_SUBSYSTEM);
cmd.createArgument().setValue("\""+getSubSystem()+"\"");
} // end of if ()
if ( getRelease() != null ) {
cmd.createArgument().setValue("\"" + getSubSystem() + "\"");
} // end of if ()
if (getRelease() != null) {
cmd.createArgument().setValue(FLAG_RELEASE);
cmd.createArgument().setValue(getRelease());
} // end of if ()
cmd.createArgument().setValue(getRelease());
} // end of if ()
}
/**
* Get the value of comment.
* @return value of comment.
@@ -167,16 +166,16 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public String getComment() {
return comment;
}
/**
* Set the value of comment.
* @param v Value to assign to comment.
*/
public void setComment(String v) {
public void setComment(String v) {
this.comment = v;
}
/**
* Get the value of platform.
* @return value of platform.
@@ -184,16 +183,16 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public String getPlatform() {
return platform;
}
/**
* Set the value of platform.
* @param v Value to assign to platform.
*/
public void setPlatform(String v) {
public void setPlatform(String v) {
this.platform = v;
}
/**
* Get the value of resolver.
* @return value of resolver.
@@ -201,16 +200,16 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public String getResolver() {
return resolver;
}
/**
* Set the value of resolver.
* @param v Value to assign to resolver.
*/
public void setResolver(String v) {
public void setResolver(String v) {
this.resolver = v;
}

/**
* Get the value of release.
* @return value of release.
@@ -218,15 +217,15 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public String getRelease() {
return release;
}
/**
* Set the value of release.
* @param v Value to assign to release.
*/
public void setRelease(String v) {
public void setRelease(String v) {
this.release = v;
}
}
/**
* Get the value of subSystem.
* @return value of subSystem.
@@ -234,76 +233,76 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
public String getSubSystem() {
return subSystem;
}
/**
* Set the value of subSystem.
* @param v Value to assign to subSystem.
*/
public void setSubSystem(String v) {
public void setSubSystem(String v) {
this.subSystem = v;
}
/**
* Get the value of task.
* @return value of task.
*/
public String getTask() {
public String getTask() {
return task;
}
/**
* Set the value of task.
* @param v Value to assign to task.
*/
public void setTask(String v) {
public void setTask(String v) {
this.task = v;
}
/**
* /comment -- comments associated to the task
*/
public final static String FLAG_COMMENT = "/synopsis";
/**
* /platform flag -- target platform
*/
public final static String FLAG_PLATFORM = "/plat";
public final static String FLAG_PLATFORM = "/plat";

/**
* /resolver flag
*/
public final static String FLAG_RESOLVER = "/resolver";
public final static String FLAG_RESOLVER = "/resolver";

/**
* /release flag
*/
public final static String FLAG_RELEASE = "/release";
public final static String FLAG_RELEASE = "/release";

/**
* /release flag
*/
public final static String FLAG_SUBSYSTEM = "/subsystem";
public final static String FLAG_SUBSYSTEM = "/subsystem";

/**
* -task flag -- associate checckout task with task
*/
public final static String FLAG_TASK = "/task";
public final static String FLAG_TASK = "/task";


// implementation of org.apache.tools.ant.taskdefs.ExecuteStreamHandler interface
/**
*
* @exception java.io.IOException
*/
public void start() throws IOException {
public void start() throws IOException {
}

/**
*
*/
public void stop(){
public void stop() {
}

/**
@@ -311,7 +310,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
* @param param1
* @exception java.io.IOException
*/
public void setProcessInputStream(OutputStream param1) throws IOException {
public void setProcessInputStream(OutputStream param1) throws IOException {
}

/**
@@ -319,48 +318,42 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler {
* @param param1
* @exception java.io.IOException
*/
public void setProcessErrorStream(InputStream is) throws IOException {
public void setProcessErrorStream(InputStream is) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String s = reader.readLine();
if ( s != null)
{
log("err "+s,Project.MSG_DEBUG);
} // end of if ()
if (s != null) {
log("err " + s, Project.MSG_DEBUG);
} // end of if ()
}

/**
* read the output stream to retrieve the new task number.
* @param is InputStream
* @exception java.io.IOException
* @exception java.io.IOException
*/
public void setProcessOutputStream(InputStream is) throws IOException {
public void setProcessOutputStream(InputStream is) throws IOException {

String buffer = "";
try
{
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
buffer = reader.readLine();
if ( buffer != null)
{
log("buffer:" +buffer,Project.MSG_DEBUG);
String taskstring = buffer.substring(buffer.indexOf(' ')).trim();
taskstring = taskstring.substring(0,taskstring.lastIndexOf(' ')).trim();
if (buffer != null) {
log("buffer:" + buffer, Project.MSG_DEBUG);
String taskstring = buffer.substring(buffer.indexOf(' ')).trim();
taskstring = taskstring.substring(0, taskstring.lastIndexOf(' ')).trim();
setTask(taskstring);
log("task is "+getTask(),Project.MSG_DEBUG);
} // end of if ()
}
catch ( NullPointerException npe)
{
log("error procession stream , null pointer exception",Project.MSG_ERR);
log("task is " + getTask(), Project.MSG_DEBUG);
} // end of if ()
} catch (NullPointerException npe) {
log("error procession stream , null pointer exception", Project.MSG_ERR);
npe.printStackTrace();
throw new BuildException(npe.getClass().getName());
} // end of catch
catch (Exception e)
{
log("error procession stream "+e.getMessage(),Project.MSG_ERR);
} // end of catch
catch (Exception e) {
log("error procession stream " + e.getMessage(), Project.MSG_ERR);
throw new BuildException(e.getMessage());
} // end of try-catch
}

}


+ 32
- 41
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java View File

@@ -55,24 +55,18 @@
package org.apache.tools.ant.taskdefs.optional.ccm;








import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;


/**
* Task allows to reconfigure a project, recurcively or not
* Task allows to reconfigure a project, recurcively or not
* @author Benoit Moussaud benoit.moussaud@criltelecom.com
*/
public class CCMReconfigure extends Continuus {

private String project = null;
private String project = null;
private boolean recurse = false;
private boolean verbose = false;

@@ -81,7 +75,7 @@ public class CCMReconfigure extends Continuus {
setCcmAction(COMMAND_RECONFIGURE);
}

/**
* Executes the task.
* <p>
@@ -94,15 +88,15 @@ public class CCMReconfigure extends Continuus {
Project aProj = getProject();
int result = 0;

// build the command line from what we got the format
// build the command line from what we got the format
// as specified in the CCM.EXE help
commandLine.setExecutable(getCcmCommand());
commandLine.createArgument().setValue(getCcmAction());
checkOptions(commandLine);
result = run(commandLine);
if ( result != 0 ) {
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
@@ -112,92 +106,89 @@ public class CCMReconfigure extends Continuus {
/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
private void checkOptions(Commandline cmd) {

if ( isRecurse() == true) {
if (isRecurse() == true) {
cmd.createArgument().setValue(FLAG_RECURSE);
} // end of if ()
} // end of if ()

if ( isVerbose() == true) {
if (isVerbose() == true) {
cmd.createArgument().setValue(FLAG_VERBOSE);
} // end of if ()
} // end of if ()

if (getCcmProject() != null) {
cmd.createArgument().setValue(FLAG_PROJECT);
cmd.createArgument().setValue(getCcmProject());
}

}
}
/**
* Get the value of project.
* @return value of project.
*/
public String getCcmProject() {
public String getCcmProject() {
return project;
}
/**
* Set the value of project.
* @param v Value to assign to project.
*/
public void setCcmProject(String v) {
public void setCcmProject(String v) {
this.project = v;
}
/**
* Get the value of recurse.
* @return value of recurse.
*/
public boolean isRecurse() {
public boolean isRecurse() {
return recurse;
}
/**
* Set the value of recurse.
* @param v Value to assign to recurse.
*/
public void setRecurse(boolean v) {
public void setRecurse(boolean v) {
this.recurse = v;
}


/**
* Get the value of verbose.
* @return value of verbose.
*/
public boolean isVerbose()
{
public boolean isVerbose() {
return verbose;
}
/**
* Set the value of verbose.
* @param v Value to assign to verbose.
*/
public void setVerbose(boolean v)
{
public void setVerbose(boolean v) {
this.verbose = v;
}
/**
* /recurse --
* /recurse --
*/
public final static String FLAG_RECURSE = "/recurse";

/**
* /recurse --
* /recurse --
*/
public final static String FLAG_VERBOSE = "/verbose";

/**
* /project flag -- target project
*/
public final static String FLAG_PROJECT = "/project";
public final static String FLAG_PROJECT = "/project";

}


+ 20
- 22
src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -54,22 +54,21 @@

package org.apache.tools.ant.taskdefs.optional.ccm;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;



/**
* A base class for creating tasks for executing commands on Continuus 5.1
* <p>
* The class extends the task as it operates by executing the ccm.exe program
* supplied with Continuus/Synergy. By default the task expects the ccm executable to be
* in the path,
* in the path,
* you can override this be specifying the ccmdir attribute.
* </p>
*
@@ -77,32 +76,32 @@ import org.apache.tools.ant.types.Commandline;
*/
public abstract class Continuus extends Task {

private String _ccmDir = "";
private String _ccmAction = "";
private String ccmDir = "";
private String ccmAction = "";
/**
* Get the value of ccmAction.
* @return value of ccmAction.
*/
public String getCcmAction() {
return _ccmAction;
return ccmAction;
}
/**
* Set the value of ccmAction.
* @param v Value to assign to ccmAction.
*/
public void setCcmAction(String v) {
this._ccmAction = v;
public void setCcmAction(String v) {
this.ccmAction = v;
}
/**
* Set the directory where the ccm executable is located
* @param dir the directory containing the ccm executable
*/
public final void setCcmDir(String dir) {
_ccmDir = project.translatePath(dir);
ccmDir = project.translatePath(dir);
}

/**
@@ -110,8 +109,8 @@ public abstract class Continuus extends Task {
* @return String containing path to the executable
*/
protected final String getCcmCommand() {
String toReturn = _ccmDir;
if ( !toReturn.equals("") && !toReturn.endsWith("/") ) {
String toReturn = ccmDir;
if (!toReturn.equals("") && !toReturn.endsWith("/")) {
toReturn += "/";
}

@@ -122,20 +121,19 @@ public abstract class Continuus extends Task {


protected int run(Commandline cmd, ExecuteStreamHandler handler) {
try {
try {
Execute exe = new Execute(handler);
exe.setAntRun(getProject());
exe.setAntRun(getProject());
exe.setWorkingDirectory(getProject().getBaseDir());
exe.setCommandline(cmd.getCommandline());
return exe.execute();
}
catch (java.io.IOException e) {
} catch (java.io.IOException e) {
throw new BuildException(e, location);
}
}

protected int run(Commandline cmd) {
return run(cmd,new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN));
protected int run(Commandline cmd) {
return run(cmd, new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN));
}

/**


Loading…
Cancel
Save