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 * 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} contains the number of messages in the mailbox, {@code size} contains the size of the mailbox 25 * in bytes, and {@code identifier} is null. 26 * </p> 27 * <p> 28 * In response to a message listings, {@code number} contains the message number, {@code size} contains the size of the message in bytes, and 29 * {@code identifier} is null. 30 * </p> 31 * <p> 32 * In response to unique identifier listings, {@code number} contains the message number, {@code size} is undefined, and {@code identifier} 33 * contains the message's unique identifier. 34 * </p> 35 */ 36 public final class POP3MessageInfo { 37 38 /** Number. */ 39 public int number; 40 41 /** Size. */ 42 public int size; 43 44 /** Identifier. */ 45 public String identifier; 46 47 /** 48 * Constructs a new instance with {@code number} and {@code size} set to 0, and {@code identifier} set to null. 49 */ 50 public POP3MessageInfo() { 51 this(0, null, 0); 52 } 53 54 /** 55 * Constructs a new instance with {@code number} set to {@code num}, {@code size} set to {@code octets}, and 56 * {@code identifier} set to null. 57 * 58 * @param num the number 59 * @param octets the size 60 */ 61 public POP3MessageInfo(final int num, final int octets) { 62 this(num, null, octets); 63 } 64 65 /** 66 * Constructs a new instance with {@code number} set to {@code num}, {@code size} undefined, and {@code identifier} set to 67 * {@code uid}. 68 * 69 * @param num the number 70 * @param uid the UID 71 */ 72 public POP3MessageInfo(final int num, final String uid) { 73 this(num, uid, -1); 74 } 75 76 /** 77 * Constructs a new instance. 78 * 79 * @param num the number. 80 * @param uid the UID. 81 * @param octets the size. 82 */ 83 private POP3MessageInfo(final int num, final String uid, final int size) { 84 this.number = num; 85 this.size = size; 86 this.identifier = uid; 87 } 88 89 /** 90 * @since 3.6 91 */ 92 @Override 93 public String toString() { 94 return "Number: " + number + ". Size: " + size + ". Id: " + identifier; 95 } 96 }