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