FileDocCategorySizeDatePackage
MailItems.javaAPI DocExample15120Mon Aug 27 20:12:46 BST 2007com.google.gwt.sample.mail.client

MailItems

public class MailItems extends Object
A simple client-side generator of fake email messages.

Fields Summary
private static final int
NUM_ITEMS
private static final int
FRAGMENTS_PER_EMAIL
private static final String[]
senders
private static final String[]
emails
private static final String[]
subjects
private static final String[]
fragments
private static int
senderIdx
private static int
emailIdx
private static int
subjectIdx
private static int
fragmentIdx
private static ArrayList
items
Constructors Summary
Methods Summary
private static MailItemcreateFakeMail()

    String sender = senders[senderIdx++];
    if (senderIdx == senders.length) {
      senderIdx = 0;
    }

    String email = emails[emailIdx++];
    if (emailIdx == emails.length) {
      emailIdx = 0;
    }

    String subject = subjects[subjectIdx++];
    if (subjectIdx == subjects.length) {
      subjectIdx = 0;
    }

    String body = "";
    for (int i = 0; i < FRAGMENTS_PER_EMAIL; ++i) {
      body += fragments[fragmentIdx++];
      if (fragmentIdx == fragments.length) {
        fragmentIdx = 0;
      }
    }

    return new MailItem(sender, email, subject, body);
  
public static MailItemgetMailItem(int index)


   
    for (int i = 0; i < NUM_ITEMS; ++i) {
      items.add(createFakeMail());
    }
  
    if (index >= items.size()) {
      return null;
    }
    return (MailItem) items.get(index);
  
public static intgetMailItemCount()

    return items.size();