001    /*
002     * Copyright 2001-2005 The Apache Software Foundation
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.apache.commons.net.smtp;
017    
018    /***
019     * SMTPCommand stores a set of constants for SMTP command codes.  To interpret
020     * the meaning of the codes, familiarity with RFC 821 is assumed.
021     * The mnemonic constant names are transcriptions from the code descriptions
022     * of RFC 821.  For those who think in terms of the actual SMTP commands,
023     * a set of constants such as {@link #HELO  HELO } are provided
024     * where the constant name is the same as the SMTP command.
025     * <p>
026     * <p>
027     * @author Daniel F. Savarese
028     ***/
029    
030    public final class SMTPCommand
031    {
032    
033    
034        public static final int HELO = 0;
035        public static final int MAIL = 1;
036        public static final int RCPT = 2;
037        public static final int DATA = 3;
038        public static final int SEND = 4;
039        public static final int SOML = 5;
040        public static final int SAML = 6;
041        public static final int RSET = 7;
042        public static final int VRFY = 8;
043        public static final int EXPN = 9;
044        public static final int HELP = 10;
045        public static final int NOOP = 11;
046        public static final int TURN = 12;
047        public static final int QUIT = 13;
048    
049        public static final int HELLO = HELO;
050        public static final int LOGIN = HELO;
051        public static final int MAIL_FROM = MAIL;
052        public static final int RECIPIENT = RCPT;
053        public static final int SEND_MESSAGE_DATA = DATA;
054        public static final int SEND_FROM = SEND;
055        public static final int SEND_OR_MAIL_FROM = SOML;
056        public static final int SEND_AND_MAIL_FROM = SAML;
057        public static final int RESET = RSET;
058        public static final int VERIFY = VRFY;
059        public static final int EXPAND = EXPN;
060        // public static final int HELP = HELP;
061        // public static final int NOOP = NOOP;
062        // public static final int TURN = TURN;
063        // public static final int QUIT = QUIT;
064        public static final int LOGOUT = QUIT;
065    
066        // Cannot be instantiated
067        private SMTPCommand()
068        {}
069    
070        static final String[] _commands = {
071                                              "HELO", "MAIL FROM:", "RCPT TO:", "DATA", "SEND FROM:", "SOML FROM:",
072                                              "SAML FROM:", "RSET", "VRFY", "EXPN", "HELP", "NOOP", "TURN", "QUIT"
073                                          };
074    
075    
076        /***
077         * Retrieve the SMTP protocol command string corresponding to a specified
078         * command code.
079         * <p>
080         * @param command The command code.
081         * @return The SMTP protcol command string corresponding to a specified
082         *         command code.
083         ***/
084        public static final String getCommand(int command)
085        {
086            return _commands[command];
087        }
088    
089    }