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 018package org.apache.commons.net.ftp; 019 020/** 021 * FTPCommand stores a set of constants for FTP command codes. To interpret the meaning of the codes, familiarity with RFC 959 is assumed. The mnemonic constant 022 * names are transcriptions from the code descriptions of RFC 959. For those who think in terms of the actual FTP commands, a set of constants such as 023 * {@link #USER USER } are provided where the constant name is the same as the FTP command. 024 * 025 * @deprecated use {@link FTPCmd} instead 026 */ 027@Deprecated 028public final class FTPCommand { 029 030 public static final int USER = 0; 031 public static final int PASS = 1; 032 public static final int ACCT = 2; 033 public static final int CWD = 3; 034 public static final int CDUP = 4; 035 public static final int SMNT = 5; 036 public static final int REIN = 6; 037 public static final int QUIT = 7; 038 public static final int PORT = 8; 039 public static final int PASV = 9; 040 public static final int TYPE = 10; 041 public static final int STRU = 11; 042 public static final int MODE = 12; 043 public static final int RETR = 13; 044 public static final int STOR = 14; 045 public static final int STOU = 15; 046 public static final int APPE = 16; 047 public static final int ALLO = 17; 048 public static final int REST = 18; 049 public static final int RNFR = 19; 050 public static final int RNTO = 20; 051 public static final int ABOR = 21; 052 public static final int DELE = 22; 053 public static final int RMD = 23; 054 public static final int MKD = 24; 055 public static final int PWD = 25; 056 public static final int LIST = 26; 057 public static final int NLST = 27; 058 public static final int SITE = 28; 059 public static final int SYST = 29; 060 public static final int STAT = 30; 061 public static final int HELP = 31; 062 public static final int NOOP = 32; 063 /** @since 2.0 */ 064 public static final int MDTM = 33; 065 /** @since 2.2 */ 066 public static final int FEAT = 34; 067 /** @since 2.2 */ 068 public static final int MFMT = 35; 069 /** @since 2.2 */ 070 public static final int EPSV = 36; 071 /** @since 2.2 */ 072 public static final int EPRT = 37; 073 074 /** 075 * Machine parseable list for a directory 076 * 077 * @since 3.0 078 */ 079 public static final int MLSD = 38; 080 081 /** 082 * Machine parseable list for a single file 083 * 084 * @since 3.0 085 */ 086 public static final int MLST = 39; 087 088 // Must agree with final entry above; used to check array size 089 private static final int LAST = MLST; 090 091 public static final int USERNAME = USER; 092 public static final int PASSWORD = PASS; 093 public static final int ACCOUNT = ACCT; 094 public static final int CHANGE_WORKING_DIRECTORY = CWD; 095 public static final int CHANGE_TO_PARENT_DIRECTORY = CDUP; 096 public static final int STRUCTURE_MOUNT = SMNT; 097 public static final int REINITIALIZE = REIN; 098 public static final int LOGOUT = QUIT; 099 public static final int DATA_PORT = PORT; 100 public static final int PASSIVE = PASV; 101 public static final int REPRESENTATION_TYPE = TYPE; 102 public static final int FILE_STRUCTURE = STRU; 103 public static final int TRANSFER_MODE = MODE; 104 public static final int RETRIEVE = RETR; 105 public static final int STORE = STOR; 106 public static final int STORE_UNIQUE = STOU; 107 public static final int APPEND = APPE; 108 public static final int ALLOCATE = ALLO; 109 public static final int RESTART = REST; 110 public static final int RENAME_FROM = RNFR; 111 public static final int RENAME_TO = RNTO; 112 public static final int ABORT = ABOR; 113 public static final int DELETE = DELE; 114 public static final int REMOVE_DIRECTORY = RMD; 115 public static final int MAKE_DIRECTORY = MKD; 116 public static final int PRINT_WORKING_DIRECTORY = PWD; 117 // public static final int LIST = LIST; 118 public static final int NAME_LIST = NLST; 119 public static final int SITE_PARAMETERS = SITE; 120 public static final int SYSTEM = SYST; 121 public static final int STATUS = STAT; 122 // public static final int HELP = HELP; 123 // public static final int NOOP = NOOP; 124 125 /** @since 2.0 */ 126 public static final int MOD_TIME = MDTM; 127 128 /** @since 2.2 */ 129 public static final int FEATURES = FEAT; 130 /** @since 2.2 */ 131 public static final int GET_MOD_TIME = MDTM; 132 /** @since 2.2 */ 133 public static final int SET_MOD_TIME = MFMT; 134 135 private static final String[] COMMANDS = { "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT", "PASV", "TYPE", "STRU", "MODE", "RETR", 136 "STOR", "STOU", "APPE", "ALLO", "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST", "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", 137 "MDTM", "FEAT", "MFMT", "EPSV", "EPRT", "MLSD", "MLST" }; 138 139 // default access needed for Unit test 140 static void checkArray() { 141 final int expectedLength = LAST + 1; 142 if (COMMANDS.length != expectedLength) { 143 throw new RuntimeException("Incorrect _commands array. Should have length " + expectedLength + " found " + COMMANDS.length); 144 } 145 } 146 147 /** 148 * Retrieve the FTP protocol command string corresponding to a specified command code. 149 * 150 * @param command The command code. 151 * @return The FTP protcol command string corresponding to a specified command code. 152 */ 153 public static String getCommand(final int command) { 154 return COMMANDS[command]; 155 } 156 157 // Cannot be instantiated 158 private FTPCommand() { 159 } 160}