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 * https://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.pop3;
19
20 /**
21 * POP3Command stores POP3 command code constants.
22 */
23
24 public final class POP3Command {
25
26 /** Send user name. */
27 public static final int USER = 0;
28
29 /** Send password. */
30 public static final int PASS = 1;
31
32 /** Quit session. */
33 public static final int QUIT = 2;
34
35 /** Gets status. */
36 public static final int STAT = 3;
37
38 /** List message(s). */
39 public static final int LIST = 4;
40
41 /** Retrieve message(s). */
42 public static final int RETR = 5;
43
44 /** Delete message(s). */
45 public static final int DELE = 6;
46
47 /** No operation. Used as a session keepalive. */
48 public static final int NOOP = 7;
49
50 /** Reset session. */
51 public static final int RSET = 8;
52
53 /** Authorization. */
54 public static final int APOP = 9;
55
56 /** Retrieve top number lines from message. */
57 public static final int TOP = 10;
58
59 /** List unique message identifier(s). */
60 public static final int UIDL = 11;
61
62 /**
63 * The capabilities command.
64 *
65 * @since 3.0
66 */
67 public static final int CAPA = 12;
68
69 /**
70 * Authentication
71 *
72 * @since 3.0
73 */
74 public static final int AUTH = 13;
75
76 private static final int NEXT = AUTH + 1; // update as necessary when adding new entries
77
78 static final String[] commands = { "USER", "PASS", "QUIT", "STAT", "LIST", "RETR", "DELE", "NOOP", "RSET", "APOP", "TOP", "UIDL", "CAPA", "AUTH", };
79
80 static {
81 if (commands.length != NEXT) {
82 throw new IllegalStateException("Error in array definition");
83 }
84 }
85
86 /**
87 * Gets the POP3 protocol string command corresponding to a command code.
88 *
89 * @param command the command code
90 * @return The POP3 protocol string command corresponding to a command code.
91 */
92 public static String getCommand(final int command) {
93 return commands[command];
94 }
95
96 /** Cannot be instantiated. */
97 private POP3Command() {
98 }
99 }