001    /*
002     * Copyright 2001-2005 The Apache Software Foundation
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.apache.commons.net.ftp;
017    
018    /***
019     * FTPCommand stores a set of constants for FTP command codes.  To interpret
020     * the meaning of the codes, familiarity with RFC 959 is assumed.
021     * The mnemonic constant names are transcriptions from the code descriptions
022     * of RFC 959.  For those who think in terms of the actual FTP commands,
023     * a set of constants such as {@link #USER  USER } are provided
024     * where the constant name is the same as the FTP command.
025     * <p>
026     * <p>
027     * @author Daniel F. Savarese
028     ***/
029    
030    public final class FTPCommand
031    {
032    
033    
034        public static final int USER = 0;
035        public static final int PASS = 1;
036        public static final int ACCT = 2;
037        public static final int CWD = 3;
038        public static final int CDUP = 4;
039        public static final int SMNT = 5;
040        public static final int REIN = 6;
041        public static final int QUIT = 7;
042        public static final int PORT = 8;
043        public static final int PASV = 9;
044        public static final int TYPE = 10;
045        public static final int STRU = 11;
046        public static final int MODE = 12;
047        public static final int RETR = 13;
048        public static final int STOR = 14;
049        public static final int STOU = 15;
050        public static final int APPE = 16;
051        public static final int ALLO = 17;
052        public static final int REST = 18;
053        public static final int RNFR = 19;
054        public static final int RNTO = 20;
055        public static final int ABOR = 21;
056        public static final int DELE = 22;
057        public static final int RMD = 23;
058        public static final int MKD = 24;
059        public static final int PWD = 25;
060        public static final int LIST = 26;
061        public static final int NLST = 27;
062        public static final int SITE = 28;
063        public static final int SYST = 29;
064        public static final int STAT = 30;
065        public static final int HELP = 31;
066        public static final int NOOP = 32;
067    
068        public static final int USERNAME = USER;
069        public static final int PASSWORD = PASS;
070        public static final int ACCOUNT = ACCT;
071        public static final int CHANGE_WORKING_DIRECTORY = CWD;
072        public static final int CHANGE_TO_PARENT_DIRECTORY = CDUP;
073        public static final int STRUCTURE_MOUNT = SMNT;
074        public static final int REINITIALIZE = REIN;
075        public static final int LOGOUT = QUIT;
076        public static final int DATA_PORT = PORT;
077        public static final int PASSIVE = PASV;
078        public static final int REPRESENTATION_TYPE = TYPE;
079        public static final int FILE_STRUCTURE = STRU;
080        public static final int TRANSFER_MODE = MODE;
081        public static final int RETRIEVE = RETR;
082        public static final int STORE = STOR;
083        public static final int STORE_UNIQUE = STOU;
084        public static final int APPEND = APPE;
085        public static final int ALLOCATE = ALLO;
086        public static final int RESTART = REST;
087        public static final int RENAME_FROM = RNFR;
088        public static final int RENAME_TO = RNTO;
089        public static final int ABORT = ABOR;
090        public static final int DELETE = DELE;
091        public static final int REMOVE_DIRECTORY = RMD;
092        public static final int MAKE_DIRECTORY = MKD;
093        public static final int PRINT_WORKING_DIRECTORY = PWD;
094        //  public static final int LIST = LIST;
095        public static final int NAME_LIST = NLST;
096        public static final int SITE_PARAMETERS = SITE;
097        public static final int SYSTEM = SYST;
098        public static final int STATUS = STAT;
099        //public static final int HELP = HELP;
100        //public static final int NOOP = NOOP;
101    
102        // Cannot be instantiated
103        private FTPCommand()
104        {}
105    
106        static final String[] _commands = {
107                                              "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
108                                              "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO",
109                                              "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST",
110                                              "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP"
111                                          };
112    
113        /**
114         * Retrieve the FTP protocol command string corresponding to a specified
115         * command code.
116         * <p>
117         * @param command The command code.
118         * @return The FTP protcol command string corresponding to a specified
119         *         command code.
120         */
121        public static final String getCommand(int command)
122        {
123            return _commands[command];
124        }
125    }