POP3MessageInfo.java

  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. package org.apache.commons.net.pop3;

  18. /**
  19.  * 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
  20.  * information being returned.
  21.  * <p>
  22.  * 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
  23.  * in bytes, and <code>identifier</code> is null.
  24.  * <p>
  25.  * 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
  26.  * <code>identifier</code> is null.
  27.  * <p>
  28.  * In response to unique identifier listings, <code>number</code> contains the message number, <code>size</code> is undefined, and <code>identifier</code>
  29.  * contains the message's unique identifier.
  30.  */

  31. public final class POP3MessageInfo {
  32.     public int number;
  33.     public int size;
  34.     public String identifier;

  35.     /**
  36.      * Creates a POP3MessageInfo instance with <code>number</code> and <code>size</code> set to 0, and <code>identifier</code> set to null.
  37.      */
  38.     public POP3MessageInfo() {
  39.         this(0, null, 0);
  40.     }

  41.     /**
  42.      * Creates a POP3MessageInfo instance with <code>number</code> set to <code>num</code>, <code>size</code> set to <code>octets</code>, and
  43.      * <code>identifier</code> set to null.
  44.      *
  45.      * @param num    the number
  46.      * @param octets the size
  47.      */
  48.     public POP3MessageInfo(final int num, final int octets) {
  49.         this(num, null, octets);
  50.     }

  51.     /**
  52.      * Creates a POP3MessageInfo instance with <code>number</code> set to <code>num</code>, <code>size</code> undefined, and <code>identifier</code> set to
  53.      * <code>uid</code>.
  54.      *
  55.      * @param num the number
  56.      * @param uid the UID
  57.      */
  58.     public POP3MessageInfo(final int num, final String uid) {
  59.         this(num, uid, -1);
  60.     }

  61.     private POP3MessageInfo(final int num, final String uid, final int size) {
  62.         this.number = num;
  63.         this.size = size;
  64.         this.identifier = uid;
  65.     }

  66.     /**
  67.      * @since 3.6
  68.      */
  69.     @Override
  70.     public String toString() {
  71.         return "Number: " + number + ". Size: " + size + ". Id: " + identifier;
  72.     }
  73. }