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 *      http://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</code> contains the number of messages in the mailbox, <code>size</code> contains the size of the mailbox
025 * in bytes, and <code>identifier</code> is null.
026 * <p>
027 * 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
028 * <code>identifier</code> is null.
029 * <p>
030 * In response to unique identifier listings, <code>number</code> contains the message number, <code>size</code> is undefined, and <code>identifier</code>
031 * contains the message's unique identifier.
032 */
033
034public final class POP3MessageInfo {
035    public int number;
036    public int size;
037    public String identifier;
038
039    /**
040     * Creates a POP3MessageInfo instance with <code>number</code> and <code>size</code> set to 0, and <code>identifier</code> set to null.
041     */
042    public POP3MessageInfo() {
043        this(0, null, 0);
044    }
045
046    /**
047     * Creates a POP3MessageInfo instance with <code>number</code> set to <code>num</code>, <code>size</code> set to <code>octets</code>, and
048     * <code>identifier</code> set to null.
049     *
050     * @param num    the number
051     * @param octets the size
052     */
053    public POP3MessageInfo(final int num, final int octets) {
054        this(num, null, octets);
055    }
056
057    /**
058     * Creates a POP3MessageInfo instance with <code>number</code> set to <code>num</code>, <code>size</code> undefined, and <code>identifier</code> set to
059     * <code>uid</code>.
060     *
061     * @param num the number
062     * @param uid the UID
063     */
064    public POP3MessageInfo(final int num, final String uid) {
065        this(num, uid, -1);
066    }
067
068    private POP3MessageInfo(final int num, final String uid, final int size) {
069        this.number = num;
070        this.size = size;
071        this.identifier = uid;
072    }
073
074    /**
075     * @since 3.6
076     */
077    @Override
078    public String toString() {
079        return "Number: " + number + ". Size: " + size + ". Id: " + identifier;
080    }
081}