View Javadoc

    1   /*
    2    * Copyright 2001-2005 The Apache Software Foundation
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *     http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  package org.apache.commons.net.ftp;
    17
    18  /****
    19   * FTPCommand stores a set of constants for FTP command codes.  To interpret
    20   * the meaning of the codes, familiarity with RFC 959 is assumed.
    21   * The mnemonic constant names are transcriptions from the code descriptions
    22   * of RFC 959.  For those who think in terms of the actual FTP commands,
    23   * a set of constants such as {@link #USER  USER } are provided
    24   * where the constant name is the same as the FTP command.
    25   * <p>
    26   * <p>
    27   * @author Daniel F. Savarese
    28   ***/
    29
    30  public final class FTPCommand
    31  {
    32
    33
    34      public static final int USER = 0;
    35      public static final int PASS = 1;
    36      public static final int ACCT = 2;
    37      public static final int CWD = 3;
    38      public static final int CDUP = 4;
    39      public static final int SMNT = 5;
    40      public static final int REIN = 6;
    41      public static final int QUIT = 7;
    42      public static final int PORT = 8;
    43      public static final int PASV = 9;
    44      public static final int TYPE = 10;
    45      public static final int STRU = 11;
    46      public static final int MODE = 12;
    47      public static final int RETR = 13;
    48      public static final int STOR = 14;
    49      public static final int STOU = 15;
    50      public static final int APPE = 16;
    51      public static final int ALLO = 17;
    52      public static final int REST = 18;
    53      public static final int RNFR = 19;
    54      public static final int RNTO = 20;
    55      public static final int ABOR = 21;
    56      public static final int DELE = 22;
    57      public static final int RMD = 23;
    58      public static final int MKD = 24;
    59      public static final int PWD = 25;
    60      public static final int LIST = 26;
    61      public static final int NLST = 27;
    62      public static final int SITE = 28;
    63      public static final int SYST = 29;
    64      public static final int STAT = 30;
    65      public static final int HELP = 31;
    66      public static final int NOOP = 32;
    67
    68      public static final int USERNAME = USER;
    69      public static final int PASSWORD = PASS;
    70      public static final int ACCOUNT = ACCT;
    71      public static final int CHANGE_WORKING_DIRECTORY = CWD;
    72      public static final int CHANGE_TO_PARENT_DIRECTORY = CDUP;
    73      public static final int STRUCTURE_MOUNT = SMNT;
    74      public static final int REINITIALIZE = REIN;
    75      public static final int LOGOUT = QUIT;
    76      public static final int DATA_PORT = PORT;
    77      public static final int PASSIVE = PASV;
    78      public static final int REPRESENTATION_TYPE = TYPE;
    79      public static final int FILE_STRUCTURE = STRU;
    80      public static final int TRANSFER_MODE = MODE;
    81      public static final int RETRIEVE = RETR;
    82      public static final int STORE = STOR;
    83      public static final int STORE_UNIQUE = STOU;
    84      public static final int APPEND = APPE;
    85      public static final int ALLOCATE = ALLO;
    86      public static final int RESTART = REST;
    87      public static final int RENAME_FROM = RNFR;
    88      public static final int RENAME_TO = RNTO;
    89      public static final int ABORT = ABOR;
    90      public static final int DELETE = DELE;
    91      public static final int REMOVE_DIRECTORY = RMD;
    92      public static final int MAKE_DIRECTORY = MKD;
    93      public static final int PRINT_WORKING_DIRECTORY = PWD;
    94      //  public static final int LIST = LIST;
    95      public static final int NAME_LIST = NLST;
    96      public static final int SITE_PARAMETERS = SITE;
    97      public static final int SYSTEM = SYST;
    98      public static final int STATUS = STAT;
    99      //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 }