FileDocCategorySizeDatePackage
CCMCheck.javaAPI DocApache Ant 1.705630Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.ccm

CCMCheck

public class CCMCheck extends Continuus
Class common to all check commands (checkout, checkin,checkin default task);
ant.task
ignore="true"

Fields Summary
private File
file
private String
comment
private String
task
protected Vector
filesets
public static final String
FLAG_COMMENT
-comment flag -- comment to attach to the file
public static final String
FLAG_TASK
-task flag -- associate checkout task with task
Constructors Summary
public CCMCheck()
Constructor for CCMCheck.


    // CheckStyle:VisibilityModifier ON

        
      
        super();
    
Methods Summary
public voidaddFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of files to copy.

param
set the set of files

        filesets.addElement(set);
    
private voidcheckOptions(org.apache.tools.ant.types.Commandline cmd)
Check the command line options.

        if (getComment() != null) {
            cmd.createArgument().setValue(FLAG_COMMENT);
            cmd.createArgument().setValue(getComment());
        }

        if (getTask() != null) {
            cmd.createArgument().setValue(FLAG_TASK);
            cmd.createArgument().setValue(getTask());
        }

        if (getFile() != null) {
            cmd.createArgument().setValue(file.getAbsolutePath());
        }
    
private voiddoit()
check the file given by getFile().

        Commandline commandLine = new Commandline();

        // build the command line from what we got the format is
        // ccm co /t .. files
        // as specified in the CCM.EXE help

        commandLine.setExecutable(getCcmCommand());
        commandLine.createArgument().setValue(getCcmAction());

        checkOptions(commandLine);

        int result = run(commandLine);
        if (Execute.isFailure(result)) {
            String msg = "Failed executing: " + commandLine.toString();
            throw new BuildException(msg, getLocation());
        }
    
public voidexecute()
Executes the task.

Builds a command line to execute ccm and then calls Exec's run method to execute the command line.

throws
BuildException on error


        if (file == null && filesets.size() == 0) {
            throw new BuildException(
                "Specify at least one source - a file or a fileset.");
        }

        if (file != null && file.exists() && file.isDirectory()) {
            throw new BuildException("CCMCheck cannot be generated for directories");
        }

        if (file != null  && filesets.size() > 0) {
            throw new BuildException("Choose between file and fileset !");
        }

        if (getFile() != null) {
            doit();
            return;
        }

        int sizeofFileSet = filesets.size();
        for (int i = 0; i < sizeofFileSet; i++) {
            FileSet fs = (FileSet) filesets.elementAt(i);
            DirectoryScanner ds = fs.getDirectoryScanner(getProject());
            String[] srcFiles = ds.getIncludedFiles();
            for (int j = 0; j < srcFiles.length; j++) {
                File src = new File(fs.getDir(getProject()), srcFiles[j]);
                setFile(src);
                doit();
            }
        }
    
public java.lang.StringgetComment()
Get the value of comment.

return
value of comment.

        return comment;
    
public java.io.FilegetFile()
Get the value of file.

return
value of file.

        return file;
    
public java.lang.StringgetTask()
Get the value of task.

return
value of task.

        return task;
    
public voidsetComment(java.lang.String v)
Specifies a comment.

param
v Value to assign to comment.

        this.comment = v;
    
public voidsetFile(java.io.File v)
Sets the path to the file that the command will operate on.

param
v Value to assign to file.

        log("working file " + v, Project.MSG_VERBOSE);
        this.file = v;
    
public voidsetTask(java.lang.String v)
Specifies the task number used to check in the file (may use 'default').

param
v Value to assign to task.

        this.task = v;