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    
018    package org.apache.commons.net.pop3;
019    
020    /***
021     * POP3Command stores POP3 command code constants.
022     * <p>
023     * <p>
024     ***/
025    
026    public final class POP3Command
027    {
028        /*** Send user name. ***/
029        public static final int USER = 0;
030        /*** Send password. ***/
031        public static final int PASS = 1;
032        /*** Quit session. ***/
033        public static final int QUIT = 2;
034        /*** Get status. ***/
035        public static final int STAT = 3;
036        /*** List message(s). ***/
037        public static final int LIST = 4;
038        /*** Retrieve message(s). ***/
039        public static final int RETR = 5;
040        /*** Delete message(s). ***/
041        public static final int DELE = 6;
042        /*** No operation.  Used as a session keepalive. ***/
043        public static final int NOOP = 7;
044        /*** Reset session. ***/
045        public static final int RSET = 8;
046        /*** Authorization. ***/
047        public static final int APOP = 9;
048        /*** Retrieve top number lines from message. ***/
049        public static final int TOP = 10;
050        /*** List unique message identifier(s). ***/
051        public static final int UIDL = 11;
052        /** 
053         * The capabilities command.
054         * @since 3.0
055         */
056        public static final int CAPA = 12;
057        /**
058         * Authentication
059         * @since 3.0 
060         */
061        public static final int AUTH = 13;
062    
063        private static final int _NEXT_ = AUTH + 1; // update as necessary when adding new entries
064    
065        static final String[] _commands = {
066                                              "USER", "PASS", "QUIT", "STAT", "LIST", "RETR", "DELE", "NOOP", "RSET",
067                                              "APOP", "TOP", "UIDL", "CAPA", "AUTH",
068                                          };
069    
070        static {
071            if (_commands.length != _NEXT_) {
072                throw new RuntimeException("Error in array definition");
073            }        
074        }
075    
076        // Cannot be instantiated.
077        private POP3Command()
078        {}
079    
080        /***
081         * Get the POP3 protocol string command corresponding to a command code.
082         * <p>
083         * @return The POP3 protocol string command corresponding to a command code.
084         ***/
085        public static final String getCommand(int command)
086        {
087            return _commands[command];
088        }
089    }