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