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