KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.*;
25
26 import org.netbeans.lib.cvsclient.command.*;
27 import org.netbeans.lib.cvsclient.command.update.*;
28 import org.netbeans.lib.cvsclient.commandLine.*;
29
30 /**
31  * A factory class for creating and configuring an update command
32  * @author Robert Greig
33  */

34 public class update extends AbstractCommandProvider {
35     
36     public String JavaDoc[] getSynonyms() {
37         return new String JavaDoc[] { "up", "upd" }; // NOI18N
38
}
39     
40     public Command createCommand(String JavaDoc[] args, int index, GlobalOptions gopt, String JavaDoc workDir) {
41         UpdateCommand command = new UpdateCommand();
42         command.setBuilder(null);
43         final String JavaDoc getOptString = command.getOptString();
44         GetOpt go = new GetOpt(args, getOptString);
45         int ch = -1;
46         go.optIndexSet(index);
47         boolean usagePrint = false;
48         while ((ch = go.getopt()) != go.optEOF) {
49             boolean ok = command.setCVSCommand((char)ch, go.optArgGet());
50 /*
51             if ((char)ch == 'R')
52                 command.setRecursive(true);
53             else if ((char)ch == 'l')
54                 command.setRecursive(false);
55             else if ((char)ch == 'd')
56                 command.setBuildDirectories(true);
57             else if ((char)ch == 'P')
58                 command.setPruneDirectories(true);
59             else
60  */

61             if (!ok) {
62                 usagePrint = true;
63             }
64         }
65         if (usagePrint) {
66             throw new IllegalArgumentException JavaDoc(getUsage());
67         }
68         int fileArgsIndex = go.optIndexGet();
69         // test if we have been passed any file arguments
70
if (fileArgsIndex < args.length) {
71             File[] fileArgs = new File[args.length - fileArgsIndex];
72             // send the arguments as absolute paths
73
if (workDir == null) {
74                 workDir = System.getProperty("user.dir");
75             }
76             File workingDir = new File(workDir);
77             for (int i = fileArgsIndex; i < args.length; i++) {
78                 fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]);
79             }
80             command.setFiles(fileArgs);
81         }
82         return command;
83     }
84     
85 }
Popular Tags