KickJava   Java API By Example, From Geeks To Geeks.

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


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 NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.cvsclient.commandLine.command;
21
22 import java.io.File JavaDoc;
23 import java.util.ResourceBundle JavaDoc;
24
25 import org.netbeans.lib.cvsclient.command.*;
26 import org.netbeans.lib.cvsclient.command.export.*;
27 import org.netbeans.lib.cvsclient.commandLine.*;
28
29 /**
30  * Export sources from CVS repository.
31  *
32  * @author Martin Entlicher
33  */

34 public class export extends AbstractCommandProvider {
35
36     public String JavaDoc getName() {
37         return "export"; // NOI18N
38
}
39
40     public String JavaDoc[] getSynonyms() {
41         return new String JavaDoc[] { "ex", "exp" }; // NOI18N
42
}
43     
44     public Command createCommand(String JavaDoc[] args, int index, GlobalOptions gopt, String JavaDoc workDir) {
45         ExportCommand command = new ExportCommand();
46         command.setBuilder(null);
47         final String JavaDoc getOptString = command.getOptString();
48         GetOpt go = new GetOpt(args, getOptString);
49         int ch = -1;
50         go.optIndexSet(index);
51         boolean usagePrint = false;
52         String JavaDoc arg;
53         while ((ch = go.getopt()) != go.optEOF) {
54             boolean ok = command.setCVSCommand((char)ch, go.optArgGet());
55             if (!ok) {
56                 usagePrint = true;
57             }
58         }
59         if (usagePrint) {
60             throw new IllegalArgumentException JavaDoc(getUsage());
61         }
62         if (command.getExportByDate() == null && command.getExportByRevision() == null) {
63             throw new IllegalArgumentException JavaDoc("cvs [export]: "+ResourceBundle.getBundle(export.class.getPackage().getName()+".Bundle").getString("export.Msg_NeedTagOrDate")); // NOI18N)
64
}
65         int modulesArgsIndex = go.optIndexGet();
66         // test if we have been passed any module arguments
67
if (modulesArgsIndex < args.length) {
68             String JavaDoc[] modulesArgs = new String JavaDoc[args.length - modulesArgsIndex];
69             // send the arguments as absolute paths
70
for (int i = modulesArgsIndex; i < args.length; i++) {
71                 modulesArgs[i - modulesArgsIndex] = args[i];
72             }
73             command.setModules(modulesArgs);
74         }
75         return command;
76         
77     }
78     
79 }
80
Popular Tags