1. /*
  2. * Copyright 2001-2004 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. * FTPCommand stores a set of constants for FTP command codes. To interpret
  19. * the meaning of the codes, familiarity with RFC 959 is assumed.
  20. * The mnemonic constant names are transcriptions from the code descriptions
  21. * of RFC 959. For those who think in terms of the actual FTP commands,
  22. * a set of constants such as <a href="#USER"> USER </a> are provided
  23. * where the constant name is the same as the FTP command.
  24. * <p>
  25. * <p>
  26. * @author Daniel F. Savarese
  27. ***/
  28. public final class FTPCommand
  29. {
  30. public static final int USER = 0;
  31. public static final int PASS = 1;
  32. public static final int ACCT = 2;
  33. public static final int CWD = 3;
  34. public static final int CDUP = 4;
  35. public static final int SMNT = 5;
  36. public static final int REIN = 6;
  37. public static final int QUIT = 7;
  38. public static final int PORT = 8;
  39. public static final int PASV = 9;
  40. public static final int TYPE = 10;
  41. public static final int STRU = 11;
  42. public static final int MODE = 12;
  43. public static final int RETR = 13;
  44. public static final int STOR = 14;
  45. public static final int STOU = 15;
  46. public static final int APPE = 16;
  47. public static final int ALLO = 17;
  48. public static final int REST = 18;
  49. public static final int RNFR = 19;
  50. public static final int RNTO = 20;
  51. public static final int ABOR = 21;
  52. public static final int DELE = 22;
  53. public static final int RMD = 23;
  54. public static final int MKD = 24;
  55. public static final int PWD = 25;
  56. public static final int LIST = 26;
  57. public static final int NLST = 27;
  58. public static final int SITE = 28;
  59. public static final int SYST = 29;
  60. public static final int STAT = 30;
  61. public static final int HELP = 31;
  62. public static final int NOOP = 32;
  63. public static final int USERNAME = USER;
  64. public static final int PASSWORD = PASS;
  65. public static final int ACCOUNT = ACCT;
  66. public static final int CHANGE_WORKING_DIRECTORY = CWD;
  67. public static final int CHANGE_TO_PARENT_DIRECTORY = CDUP;
  68. public static final int STRUCTURE_MOUNT = SMNT;
  69. public static final int REINITIALIZE = REIN;
  70. public static final int LOGOUT = QUIT;
  71. public static final int DATA_PORT = PORT;
  72. public static final int PASSIVE = PASV;
  73. public static final int REPRESENTATION_TYPE = TYPE;
  74. public static final int FILE_STRUCTURE = STRU;
  75. public static final int TRANSFER_MODE = MODE;
  76. public static final int RETRIEVE = RETR;
  77. public static final int STORE = STOR;
  78. public static final int STORE_UNIQUE = STOU;
  79. public static final int APPEND = APPE;
  80. public static final int ALLOCATE = ALLO;
  81. public static final int RESTART = REST;
  82. public static final int RENAME_FROM = RNFR;
  83. public static final int RENAME_TO = RNTO;
  84. public static final int ABORT = ABOR;
  85. public static final int DELETE = DELE;
  86. public static final int REMOVE_DIRECTORY = RMD;
  87. public static final int MAKE_DIRECTORY = MKD;
  88. public static final int PRINT_WORKING_DIRECTORY = PWD;
  89. // public static final int LIST = LIST;
  90. public static final int NAME_LIST = NLST;
  91. public static final int SITE_PARAMETERS = SITE;
  92. public static final int SYSTEM = SYST;
  93. public static final int STATUS = STAT;
  94. //public static final int HELP = HELP;
  95. //public static final int NOOP = NOOP;
  96. // Cannot be instantiated
  97. private FTPCommand()
  98. {}
  99. static final String[] _commands = {
  100. "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
  101. "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO",
  102. "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST",
  103. "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP"
  104. };
  105. /**
  106. * Retrieve the FTP protocol command string corresponding to a specified
  107. * command code.
  108. * <p>
  109. * @param command The command code.
  110. * @return The FTP protcol command string corresponding to a specified
  111. * command code.
  112. */
  113. public static final String getCommand(int command)
  114. {
  115. return _commands[command];
  116. }
  117. }