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   * POP3MessageInfo is used to return information about messages stored on a POP3 server. Its fields are used to mean slightly different things depending on the
22   * information being returned.
23   * <p>
24   * In response to a status command, <code> number </code> contains the number of messages in the mailbox, <code> size </code> contains the size of the mailbox
25   * in bytes, and <code> identifier </code> is null.
26   * <p>
27   * In response to a message listings, <code> number </code> contains the message number, <code> size </code> contains the size of the message in bytes, and
28   * <code> identifier </code> is null.
29   * <p>
30   * In response to unique identifier listings, <code> number </code> contains the message number, <code> size </code> is undefined, and <code> identifier </code>
31   * contains the message's unique identifier.
32   */
33  
34  public final class POP3MessageInfo {
35      public int number;
36      public int size;
37      public String identifier;
38  
39      /**
40       * Creates a POP3MessageInfo instance with <code>number</code> and <code> size </code> set to 0, and <code>identifier</code> set to null.
41       */
42      public POP3MessageInfo() {
43          this(0, null, 0);
44      }
45  
46      /**
47       * Creates a POP3MessageInfo instance with <code>number</code> set to <code> num </code>, <code> size </code> set to <code> octets </code>, and
48       * <code>identifier</code> set to null.
49       *
50       * @param num    the number
51       * @param octets the size
52       */
53      public POP3MessageInfo(final int num, final int octets) {
54          this(num, null, octets);
55      }
56  
57      /**
58       * Creates a POP3MessageInfo instance with <code>number</code> set to <code> num </code>, <code> size </code> undefined, and <code>identifier</code> set to
59       * <code>uid</code>.
60       *
61       * @param num the number
62       * @param uid the UID
63       */
64      public POP3MessageInfo(final int num, final String uid) {
65          this(num, uid, -1);
66      }
67  
68      private POP3MessageInfo(final int num, final String uid, final int size) {
69          this.number = num;
70          this.size = size;
71          this.identifier = uid;
72      }
73  
74      /**
75       * @since 3.6
76       */
77      @Override
78      public String toString() {
79          return "Number: " + number + ". Size: " + size + ". Id: " + identifier;
80      }
81  }