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
022 * a POP3 server.  Its fields are used to mean slightly different things
023 * depending on the information being returned.
024 * <p>
025 * In response to a status command, <code> number </code>
026 * contains the number of messages in the mailbox, <code> size </code>
027 * contains the size of the mailbox in bytes, and <code> identifier </code>
028 * is null.
029 * <p>
030 * In response to a message listings, <code> number </code>
031 * contains the message number, <code> size </code> contains the
032 * size of the message in bytes, and <code> identifier </code> is null.
033 * <p>
034 * In response to unique identifier listings, <code> number </code> contains
035 * the message number, <code> size </code> is undefined, and
036 * <code> identifier </code> contains the message's unique identifier.
037 *
038 *
039 */
040
041public final class POP3MessageInfo
042{
043    public int number;
044    public int size;
045    public String identifier;
046
047    /**
048     * Creates a POP3MessageInfo instance with <code>number</code> and
049     * <code> size </code> set to 0, and <code>identifier</code> set to
050     * null.
051     */
052    public POP3MessageInfo()
053    {
054        this(0, null, 0);
055    }
056
057    /**
058     * Creates a POP3MessageInfo instance with <code>number</code> set
059     * to <code> num </code>, <code> size </code> set to <code> octets </code>,
060     * and <code>identifier</code> set to null.
061     * @param num the number
062     * @param octets the size
063     */
064    public POP3MessageInfo(final int num, final int octets)
065    {
066        this(num, null, octets);
067    }
068
069    /**
070     * Creates a POP3MessageInfo instance with <code>number</code> set
071     * to <code> num </code>, <code> size </code> undefined,
072     * and <code>identifier</code> set to <code>uid</code>.
073     * @param num the number
074     * @param uid the UID
075     */
076    public POP3MessageInfo(final int num, final String uid)
077    {
078        this(num, uid, -1);
079    }
080
081    private POP3MessageInfo(final int num, final String uid, final int size) {
082        this.number = num;
083        this.size = size;
084        this.identifier = uid;
085    }
086
087    /**
088     * @since 3.6
089     */
090    @Override
091    public String toString() {
092        return "Number: " + number + ". Size: " + size + ". Id: " + identifier;
093    }
094}