    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      https://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.net.pop3;
    019
    020/**
    021 * 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
    022 * information being returned.
    023 * <p>
    024 * In response to a status command, {@code number} contains the number of messages in the mailbox, {@code size} contains the size of the mailbox
    025 * in bytes, and {@code identifier} is null.
    026 * </p>
    027 * <p>
    028 * In response to a message listings, {@code number} contains the message number, {@code size} contains the size of the message in bytes, and
    029 * {@code identifier} is null.
    030 * </p>
    031 * <p>
    032 * In response to unique identifier listings, {@code number} contains the message number, {@code size} is undefined, and {@code identifier}
    033 * contains the message's unique identifier.
    034 * </p>
    035 */
    036public final class POP3MessageInfo {
    037
    038    /** Number. */
    039    public int number;
    040
    041    /** Size. */
    042    public int size;
    043
    044    /** Identifier. */
    045    public String identifier;
    046
    047    /**
    048     * Constructs a new instance with {@code number} and {@code size} set to 0, and {@code identifier} set to null.
    049     */
    050    public POP3MessageInfo() {
    051        this(0, null, 0);
    052    }
    053
    054    /**
    055     * Constructs a new instance with {@code number} set to {@code num}, {@code size} set to {@code octets}, and
    056     * {@code identifier} set to null.
    057     *
    058     * @param num    the number
    059     * @param octets the size
    060     */
    061    public POP3MessageInfo(final int num, final int octets) {
    062        this(num, null, octets);
    063    }
    064
    065    /**
    066     * Constructs a new instance with {@code number} set to {@code num}, {@code size} undefined, and {@code identifier} set to
    067     * {@code uid}.
    068     *
    069     * @param num the number
    070     * @param uid the UID
    071     */
    072    public POP3MessageInfo(final int num, final String uid) {
    073        this(num, uid, -1);
    074    }
    075
    076    /**
    077     * Constructs a new instance.
    078     *
    079     * @param num    the number.
    080     * @param uid    the UID.
    081     * @param octets the size.
    082     */
    083    private POP3MessageInfo(final int num, final String uid, final int size) {
    084        this.number = num;
    085        this.size = size;
    086        this.identifier = uid;
    087    }
    088
    089    /**
    090     * @since 3.6
    091     */
    092    @Override
    093    public String toString() {
    094        return "Number: " + number + ". Size: " + size + ". Id: " + identifier;
    095    }
    096}