major simplifications to Iterator api
[org.ibex.mail.git] / src / org / ibex / mail / MessageArrayMailbox.java
1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
4
5 package org.ibex.mail;
6 import org.ibex.util.*;
7 import org.ibex.mail.*;
8 import java.io.*;
9 import java.net.*;
10 import java.util.*;
11 import java.text.*;
12
13 public class MessageArrayMailbox extends Mailbox.Default {
14
15     private final Message[] messages;
16
17     public MessageArrayMailbox(Message[] messages) { this.messages = messages; }
18
19     public void             insert(Message message, int flags) { return; }
20     public int              uidNext() { return messages.length+1; }
21     public Mailbox.Iterator iterator() { return new MessageArrayMailbox.Iterator(); }
22
23     public class Iterator extends Mailbox.Default.Iterator {
24         private int position = -1;
25
26         public Message cur()  { return messages[position]; }
27         public Headers head() { return messages[position].headers; }
28         public boolean next() { return ++position < messages.length; }
29         public int     uid()  { return position+1; }
30         public int     imapNumber()  { return position+1; }
31         public void    delete() { return; }
32
33     }
34 }