KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > commandLine > command > checkout


1 /*****************************************************************************
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14
15  * The Original Software is the CVS Client Library.
16  * The Initial Developer of the Original Software is Robert Greig.
17  * Portions created by Robert Greig are Copyright (C) 2000.
18  * All Rights Reserved.
19
20  * Contributor(s): Robert Greig.
21  *****************************************************************************/

22 package org.netbeans.lib.cvsclient.commandLine.command;
23
24 import org.netbeans.lib.cvsclient.command.*;
25 import org.netbeans.lib.cvsclient.command.checkout.*;
26 import org.netbeans.lib.cvsclient.commandLine.*;
27
28 /**
29  * A factory class for creating and configuring a checkout command
30  * @author Robert Greig
31  */

32 public class checkout extends AbstractCommandProvider {
33
34     public String JavaDoc[] getSynonyms() {
35         return new String JavaDoc[] { "co", "get" };
36     }
37     
38     public Command createCommand(String JavaDoc[] args, int index, GlobalOptions gopt, String JavaDoc workDir) {
39         CheckoutCommand command = new CheckoutCommand();
40         command.setBuilder(null);
41         final String JavaDoc getOptString = command.getOptString();
42         GetOpt go = new GetOpt(args, getOptString);
43         int ch = -1;
44         go.optIndexSet(index);
45         boolean usagePrint = false;
46         while ((ch = go.getopt()) != go.optEOF) {
47             boolean ok = command.setCVSCommand((char)ch, go.optArgGet());
48             if (!ok) {
49                 usagePrint = true;
50             }
51         }
52         if (usagePrint) {
53             throw new IllegalArgumentException JavaDoc(getUsage());
54         }
55         int modulesArgsIndex = go.optIndexGet();
56         // test if we have been passed any file arguments
57
if (modulesArgsIndex < args.length) {
58             String JavaDoc[] modulesArgs = new String JavaDoc[args.length - modulesArgsIndex];
59             // send the arguments as absolute paths
60
for (int i = modulesArgsIndex; i < args.length; i++) {
61                 modulesArgs[i - modulesArgsIndex] = args[i];
62             }
63             command.setModules(modulesArgs);
64         }
65         return command;
66     }
67     
68 }
Popular Tags