/** * File: EmailClient.java * Project: CMSC 202 Project #, Fall 2010 * Author: John Park * Date: Oct 4, 2010 * Section: 14 * E-mail: park@umbc.edu * Class Invariants: * None. */ package proj2; import proj2MailUtil.*; /** * @author park * */ public class EmailClient { MailRepository mailRepo; public EmailClient(String folderName) { mailRepo = new MailRepository(folderName); } /** * Name: execute * * Dummy version of execute() to show how to create MailRepository * instances and get mail from them. * Note that for Project 2, you have to implement something MUCH * more sophisticated, including a text-based user interface to * query for commands, plus implementations for all of the required * commands. * * PreCondition: * PostCondition: * @return */ public boolean execute() { int numMessages; numMessages = mailRepo.getNumMessages(); for (int i = 0; i < numMessages; i++) { MailHeader header = mailRepo.getMessageHeader(i); String body = mailRepo.getMessageBody(i); System.out.print("Message #" + (i + 1) + "\nHeader:" + "\nFrom: " + header.getFromAddr() + "\nTo: " + header.getToAddr() + "\nDate: " + header.getSentDate() + "\nSubj: " + header.getSubject() + "\nBody:\n" + body); } return false; } /** * Name: main * PreCondition: * PostCondition: * @param args */ public static void main(String[] args) { boolean retval; EmailClient client = new EmailClient("P2TestFolder.in"); retval = client.execute(); System.out.println("execute() done, returned " + retval); } }