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