View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.net.smtp;
19  
20  /***
21   * SMTPCommand stores a set of constants for SMTP command codes.  To interpret
22   * the meaning of the codes, familiarity with RFC 821 is assumed.
23   * The mnemonic constant names are transcriptions from the code descriptions
24   * of RFC 821.  For those who think in terms of the actual SMTP commands,
25   * a set of constants such as {@link #HELO  HELO } are provided
26   * where the constant name is the same as the SMTP command.
27   * <p>
28   * <p>
29   * @author Daniel F. Savarese
30   ***/
31  
32  public final class SMTPCommand
33  {
34  
35  
36      public static final int HELO = 0;
37      public static final int MAIL = 1;
38      public static final int RCPT = 2;
39      public static final int DATA = 3;
40      public static final int SEND = 4;
41      public static final int SOML = 5;
42      public static final int SAML = 6;
43      public static final int RSET = 7;
44      public static final int VRFY = 8;
45      public static final int EXPN = 9;
46      public static final int HELP = 10;
47      public static final int NOOP = 11;
48      public static final int TURN = 12;
49      public static final int QUIT = 13;
50  
51      public static final int HELLO = HELO;
52      public static final int LOGIN = HELO;
53      public static final int MAIL_FROM = MAIL;
54      public static final int RECIPIENT = RCPT;
55      public static final int SEND_MESSAGE_DATA = DATA;
56      public static final int SEND_FROM = SEND;
57      public static final int SEND_OR_MAIL_FROM = SOML;
58      public static final int SEND_AND_MAIL_FROM = SAML;
59      public static final int RESET = RSET;
60      public static final int VERIFY = VRFY;
61      public static final int EXPAND = EXPN;
62      // public static final int HELP = HELP;
63      // public static final int NOOP = NOOP;
64      // public static final int TURN = TURN;
65      // public static final int QUIT = QUIT;
66      public static final int LOGOUT = QUIT;
67  
68      // Cannot be instantiated
69      private SMTPCommand()
70      {}
71  
72      static final String[] _commands = {
73                                            "HELO", "MAIL FROM:", "RCPT TO:", "DATA", "SEND FROM:", "SOML FROM:",
74                                            "SAML FROM:", "RSET", "VRFY", "EXPN", "HELP", "NOOP", "TURN", "QUIT"
75                                        };
76  
77  
78      /***
79       * Retrieve the SMTP protocol command string corresponding to a specified
80       * command code.
81       * <p>
82       * @param command The command code.
83       * @return The SMTP protcol command string corresponding to a specified
84       *         command code.
85       ***/
86      public static final String getCommand(int command)
87      {
88          return _commands[command];
89      }
90  
91  }