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