![]() |
Quadcap Embeddable Server |
00001 package com.quadcap.pop3.client; 00002 00003 /* Copyright 1997 - 2003 Quadcap Software. All rights reserved. 00004 * 00005 * This software is distributed under the Quadcap Free Software License. 00006 * This software may be used or modified for any purpose, personal or 00007 * commercial. Open Source redistributions are permitted. Commercial 00008 * redistribution of larger works derived from, or works which bundle 00009 * this software requires a "Commercial Redistribution License"; see 00010 * http://www.quadcap.com/purchase. 00011 * 00012 * Redistributions qualify as "Open Source" under one of the following terms: 00013 * 00014 * Redistributions are made at no charge beyond the reasonable cost of 00015 * materials and delivery. 00016 * 00017 * Redistributions are accompanied by a copy of the Source Code or by an 00018 * irrevocable offer to provide a copy of the Source Code for up to three 00019 * years at the cost of materials and delivery. Such redistributions 00020 * must allow further use, modification, and redistribution of the Source 00021 * Code under substantially the same terms as this license. 00022 * 00023 * Redistributions of source code must retain the copyright notices as they 00024 * appear in each source code file, these license terms, and the 00025 * disclaimer/limitation of liability set forth as paragraph 6 below. 00026 * 00027 * Redistributions in binary form must reproduce this Copyright Notice, 00028 * these license terms, and the disclaimer/limitation of liability set 00029 * forth as paragraph 6 below, in the documentation and/or other materials 00030 * provided with the distribution. 00031 * 00032 * The Software is provided on an "AS IS" basis. No warranty is 00033 * provided that the Software is free of defects, or fit for a 00034 * particular purpose. 00035 * 00036 * Limitation of Liability. Quadcap Software shall not be liable 00037 * for any damages suffered by the Licensee or any third party resulting 00038 * from use of the Software. 00039 */ 00040 00041 import java.util.Date; 00042 00043 /** 00044 * This class holds a single UIDL entry in the Pop3 agent's UIDL map. 00045 * Each entry corresponds to a message on the server -- we'll rememember 00046 * the date we first saw the message, so we can know when to delete it. 00047 * 00048 * @author Stan Bailes 00049 */ 00051 String uidl; 00052 int messageNumber; 00053 Date firstSeen; 00054 00055 transient public boolean markedForDeletion = false; 00056 00057 /** 00058 * Construct a new UidlEntry from the specified parameters. 00059 * 00060 * @param uidl the POP3 <b>UIDL</b> string returned from the server. 00061 * @param messageNumber the POP# message number returned from the server. 00062 * @param firstSeen the date when this message was first seen, usually the 00063 * date when the UidlEntry object for that message is first 00064 * constructed, i.e. 'now'. 00065 */ 00066 public UidlEntry(String uidl, int messageNumber, Date firstSeen) { 00067 this.uidl = uidl; 00068 this.messageNumber = messageNumber; 00069 this.firstSeen = firstSeen; 00070 } 00071 00072 public UidlEntry(String s) { 00073 int idx = s.indexOf(' '); 00074 if (idx < 0) { 00075 throw new RuntimeException("Bad UidlEntry string: " + s); 00076 } 00077 this.uidl = s.substring(0, idx); 00078 this.firstSeen = new Date(Long.parseLong(s.substring(idx+1))); 00079 this.messageNumber = -1; 00080 } 00081 00082 /** 00083 * Get the uidl string. 00084 * 00085 * @return the uidl string for this message. 00086 */ 00087 public String getUidl() { return uidl; } 00088 00089 00090 /** 00091 * Get the POP3 message number 00092 * 00093 * @return the POP3 message number, returned e.g. by the LIST command. 00094 */ 00095 public int getMessageNumber() { return messageNumber; } 00096 00097 /** 00098 * Set the POP3 message number. 00099 * 00100 * @param num the new POP3 message number. This is set in subsequent 00101 * sessions, where a message has the same UIDL, but due to 00102 * intervening deletions has a new message number. 00103 */ 00104 public void setMessageNumber(int num) { messageNumber = num; } 00105 00106 /** 00107 * Get the date this message was first seen. 00108 * 00109 * @return the first seen date. 00110 */ 00111 public Date getFirstSeen() { return firstSeen; } 00112 00113 /** 00114 * Return a human-readable version of this UidlEntry object. 00115 * 00116 * @return a string representing this UidlEntry 00117 */ 00118 public String toString() { 00119 return "" + uidl + " " + firstSeen.getTime(); 00120 } 00121 }