package example10_1_Adapter.pop3extreme; import java.util.*; /** // This class represents a new and improved POP3 mail client API */ public class Pop3Extreme { private List msgs = new ArrayList(); /** * Creates the client * * (This implementation loads an example method.) */ public Pop3Extreme() { msgs.add( new Message("george@theranch.com", "W", "need your help with this BP thingee", "You remember that Terminater fella? Can you put me in touch with him? " + "My freinds at BP need some asistense terminatin' that oil well thingee.", 0) ); msgs.add(null); } /** * Specifies email, e.g. yoder@msoe.edu * @param username The username (e.g. yoder) * @param password The password * @param domain The domain (e.g. msoe.edu) * @return true if success */ public boolean login(String username, String password, String domain ) { return true; } /** * @return true if success */ public boolean logout() { // The new client works better than the old one... return true; } /** * Return the number of new messages. * @return */ public int getNew() { return 1; } /** * @param msgIndex index of desired message. * @return message or null if invalid index */ public Message getMessage(int msgIndex ) { return msgs.get(msgIndex); } /** this inner class represents a message object */ public class Message { private String sender; private String nickname; private String subject; private String body; private int mimetype; /** * Creates a message with all the fields given it. * @param sender * @param nickname * @param subject * @param body * @param mimetype */ public Message( String sender, String nickname, String subject, String body, int mimetype ) { this.sender = sender; this.nickname = nickname; this.subject = subject; this.body = body; this.mimetype = mimetype; } public String getSender() { return sender; } public String getSenderName() { return nickname; } public String getSubject() { return subject; } public String getBody() { return body; } public int getMIMEType() { return mimetype; } } }