Package org.jvnet.mock_javamail
Class Mailbox
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<jakarta.mail.Message>
-
- org.jvnet.mock_javamail.Mailbox
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<jakarta.mail.Message>
,Collection<jakarta.mail.Message>
,List<jakarta.mail.Message>
,RandomAccess
public class Mailbox extends ArrayList<jakarta.mail.Message>
In-memory mailbox that hosts messages.This class also maintains the 'unread' flag for messages that are newly added. This flag is automatically removed when the message is retrieved, much like how MUA behaves. This flag affects
MockFolder.getNewMessageCount()
.- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description Mailbox(jakarta.mail.Address address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(jakarta.mail.Message message)
boolean
addAll(Collection<? extends jakarta.mail.Message> messages)
static void
clearAll()
Discards all the mailboxes and its data.void
clearNewStatus()
Removes the 'new' status from all the e-mails.boolean
equals(Object o)
jakarta.mail.Message
get(int msgnum)
static Mailbox
get(jakarta.mail.Address a)
Get the inbox for the given address.static Mailbox
get(String address)
jakarta.mail.Address
getAddress()
Gets the e-mail address of this mailbox.int
getNewMessageCount()
int
hashCode()
boolean
isError()
Returns true if this mailbox is flagged as 'error'.void
setError(boolean error)
Sets if this mailbox should be flagged as 'error'.-
Methods inherited from class java.util.ArrayList
add, addAll, clear, clone, contains, ensureCapacity, forEach, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Method Detail
-
getAddress
public jakarta.mail.Address getAddress()
Gets the e-mail address of this mailbox.
-
isError
public boolean isError()
Returns true if this mailbox is flagged as 'error'.- See Also:
setError(boolean)
-
setError
public void setError(boolean error)
Sets if this mailbox should be flagged as 'error'. Any sending/receiving operation with an error mailbox will fail. This behavior can be used to test the error handling behavior of the application.
-
get
public static Mailbox get(jakarta.mail.Address a)
Get the inbox for the given address.
-
get
public static Mailbox get(String address) throws jakarta.mail.internet.AddressException
- Throws:
jakarta.mail.internet.AddressException
-
getNewMessageCount
public int getNewMessageCount()
-
get
public jakarta.mail.Message get(int msgnum)
-
addAll
public boolean addAll(Collection<? extends jakarta.mail.Message> messages)
-
add
public boolean add(jakarta.mail.Message message)
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
clearNewStatus
public void clearNewStatus()
Removes the 'new' status from all the e-mails. Akin to "mark all e-mails as read" in the MUA.
-
clearAll
public static void clearAll()
Discards all the mailboxes and its data.
-
-