public abstract class MboxStorageReader extends Object implements IDisposable, Closeable
Example:
// Create an instance of the MboxStorageReader using the factory method 'createReader'.
MboxStorageReader mbox = MboxStorageReader.createReader("storage.mbox", new MboxLoadOptions());
// Iterate through each message info object in the mbox storage.
for (MboxMessageInfo mboxMessageInfo : mbox.enumerateMessageInfo()) {
System.out.println("Subject: " + mboxMessageInfo.getSubject());
System.out.println("From: " + mboxMessageInfo.getFrom());
System.out.println("To: " + mboxMessageInfo.getTo());
// Extract the full MIME message object from the MBOX storage using the message's unique entry ID.
MailMessage eml = mbox.extractMessage(mboxMessageInfo.getEntryId(), new EmlLoadOptions());
// Save the extracted MIME message as an .eml file.
eml.save(eml.getSubject() + ".eml");
}
| Modifier and Type | Field and Description |
|---|---|
protected static byte[] |
EmptyFromMarkerCR |
protected static byte[] |
EmptyFromMarkerCRLF |
protected static byte[] |
EmptyFromMarkerLF |
protected static byte[] |
FromMarker
"From " signature, indicates a start of the message.
|
protected static byte[] |
MboxoMarker
The mbox format uses a single blank line followed by the string 'From ' (with a space) to delimit messages.
|
protected Encoding |
preferredTextEncoding |
| Modifier | Constructor and Description |
|---|---|
protected |
MboxStorageReader(InputStream stream,
MboxLoadOptions options)
Initializes a new instance of the
MboxStorageReader class. |
protected |
MboxStorageReader(Stream stream,
MboxLoadOptions options)
Initializes a new instance of the
MboxStorageReader class. |
protected |
MboxStorageReader(String fileName,
MboxLoadOptions options)
Initializes a new instance of the
MboxStorageReader class. |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
byteArrayStartsFromMarker(byte[] array,
byte[] marker)
Checks whether the array starts from given marker.
|
void |
cancel()
This method is used to interrupt a split operation if splitInto is running asynchronously.
|
void |
close() |
protected static boolean |
containsAsctime(byte[] currentLine)
Determines whether the specified line contains asctime string.
|
static MboxStorageReader |
createReader(InputStream stream,
MboxLoadOptions options)
Creates the instance of reader.
|
static MboxStorageReader |
createReader(Stream stream,
MboxLoadOptions options)
Creates the instance of reader.
|
static MboxStorageReader |
createReader(String fileName,
MboxLoadOptions options)
Creates the instance of reader.
|
void |
dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
protected void |
dispose(boolean disposing)
Releases unmanaged and - optionally - managed resources
|
IGenericEnumerable<MboxMessageInfo> |
enumerateMessageInfo()
Exposes the enumerator, which supports an iteration of messages in storage.
|
IGenericEnumerable<MailMessage> |
enumerateMessages()
Exposes the enumerator, which supports an iteration of messages in storage.
|
IGenericEnumerable<MailMessage> |
enumerateMessages(EmlLoadOptions options)
Exposes the enumerator, which supports an iteration of messages in storage.
|
MailMessage |
extractMessage(String id,
EmlLoadOptions options)
Get the message from MBOX.
|
long |
getCurrentDataSize()
Gets the number of bytes that is read by ReadNextMessage method.
|
MimeItemCopyEventHandler |
getEmlCopiedEventHandler()
Event that occurs after successful copy of a
MailMessage object
within the splitInto(long,String) method. |
MimeItemCopyEventHandler |
getEmlCopyingEventHandler()
Event that occurs before the
MailMessage object copy process,
within the splitInto(long,String) method. |
NewStorageEventHandler |
getMboxFileCreatedEventHandler()
Event that occurs when a new MBOX file is created
during the
splitInto(long,String) method. |
NewStorageEventHandler |
getMboxFileFilledEventHandler()
Event that occurs after filling an MBOX file with data
within the
splitInto(long,String) method. |
abstract int |
getTotalItemsCount()
Returns the number of messages in a storage.
|
abstract MboxMessageInfo |
nextMessage()
Gets the next message info.
|
protected static byte[] |
readLine(Stream stream)
Reads the line from stream.
|
abstract MailMessage |
readNextMessage()
Reads the next message from underlying storage stream.
|
abstract MailMessage |
readNextMessage(EmlLoadOptions options)
Reads the next message from underlying storage stream.
|
abstract MailMessage |
readNextMessage(String[] fromMarker)
Reads the next message from underlying storage stream.
|
abstract MailMessage |
readNextMessage(String[] fromMarker,
EmlLoadOptions options)
Reads the next message from underlying storage stream.
|
protected void |
setCurrentDataSize(long value)
Gets the number of bytes that is read by ReadNextMessage method.
|
void |
setEmlCopiedEventHandler(MimeItemCopyEventHandler value)
Event that occurs after successful copy of a
MailMessage object
within the splitInto(long,String) method. |
void |
setEmlCopyingEventHandler(MimeItemCopyEventHandler value)
Event that occurs before the
MailMessage object copy process,
within the splitInto(long,String) method. |
void |
setMboxFileCreatedEventHandler(NewStorageEventHandler value)
Event that occurs when a new MBOX file is created
during the
splitInto(long,String) method. |
void |
setMboxFileFilledEventHandler(NewStorageEventHandler value)
Event that occurs after filling an MBOX file with data
within the
splitInto(long,String) method. |
void |
splitInto(long chunkSize,
String outputPath)
Splits the mbox storage into less sized parts.
|
void |
splitInto(long chunkSize,
String outputPath,
String partFileNamePrefix)
Splits the mbox storage into less sized parts.
|
protected final Encoding preferredTextEncoding
protected static final byte[] FromMarker
"From " signature, indicates a start of the message.
protected static final byte[] EmptyFromMarkerCRLF
protected static final byte[] EmptyFromMarkerCR
protected static final byte[] EmptyFromMarkerLF
protected static final byte[] MboxoMarker
The mbox format uses a single blank line followed by the string 'From ' (with a space) to delimit messages. In mboxo format sender's email address in message delimiter is replaced by the constant string '???@???', i.e. 'From ???@???'
protected MboxStorageReader(InputStream stream, MboxLoadOptions options)
Initializes a new instance of the MboxStorageReader class.
stream - The stream.options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullException - If given stream is null.protected MboxStorageReader(Stream stream,
MboxLoadOptions options)
Initializes a new instance of the MboxStorageReader class.
stream - The stream.options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullException - If given stream is null.protected MboxStorageReader(String fileName, MboxLoadOptions options)
Initializes a new instance of the MboxStorageReader class.
fileName - Name of the file.options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullException - If filename is null or empty.public final MimeItemCopyEventHandler getEmlCopyingEventHandler()
Event that occurs before the MailMessage object copy process,
within the splitInto(long,String) method.
public final void setEmlCopyingEventHandler(MimeItemCopyEventHandler value)
Event that occurs before the MailMessage object copy process,
within the splitInto(long,String) method.
public final MimeItemCopyEventHandler getEmlCopiedEventHandler()
Event that occurs after successful copy of a MailMessage object
within the splitInto(long,String) method.
public final void setEmlCopiedEventHandler(MimeItemCopyEventHandler value)
Event that occurs after successful copy of a MailMessage object
within the splitInto(long,String) method.
public final NewStorageEventHandler getMboxFileCreatedEventHandler()
Event that occurs when a new MBOX file is created
during the splitInto(long,String) method.
public final void setMboxFileCreatedEventHandler(NewStorageEventHandler value)
Event that occurs when a new MBOX file is created
during the splitInto(long,String) method.
public final NewStorageEventHandler getMboxFileFilledEventHandler()
Event that occurs after filling an MBOX file with data
within the splitInto(long,String) method.
public final void setMboxFileFilledEventHandler(NewStorageEventHandler value)
Event that occurs after filling an MBOX file with data
within the splitInto(long,String) method.
public final long getCurrentDataSize()
Gets the number of bytes that is read by ReadNextMessage method.
protected final void setCurrentDataSize(long value)
Gets the number of bytes that is read by ReadNextMessage method.
public static MboxStorageReader createReader(InputStream stream, MboxLoadOptions options)
Creates the instance of reader.
stream - The stream.options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullExceptionpublic static MboxStorageReader createReader(Stream stream, MboxLoadOptions options)
Creates the instance of reader.
stream - The stream.options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullExceptionpublic static MboxStorageReader createReader(String fileName, MboxLoadOptions options)
Creates the instance of reader.
fileName - options - additional options when loading a Mbox storageMboxLoadOptions.ArgumentNullExceptionpublic final IGenericEnumerable<MailMessage> enumerateMessages()
Exposes the enumerator, which supports an iteration of messages in storage.
System.Collections.Generic.IEnumerableltTgt,
that represents an enumerator that iterates through a messages in storage.public final IGenericEnumerable<MboxMessageInfo> enumerateMessageInfo()
Exposes the enumerator, which supports an iteration of messages in storage.
System.Collections.Generic.IEnumerableltTgt,
that represents an enumerator that iterates through a messages in storage.public final MailMessage extractMessage(String id, EmlLoadOptions options)
Get the message from MBOX.
id - String representation of EntryId.options - Specifies EmlLoadOptions when reading message from Mbox storage.MailMessage object.public final IGenericEnumerable<MailMessage> enumerateMessages(EmlLoadOptions options)
Exposes the enumerator, which supports an iteration of messages in storage.
options - Specifies EmlLoadOptions when reading message from Mbox storage.System.Collections.Generic.IEnumerableltTgt,
that represents an enumerator that iterates through a messages in storage.public final void splitInto(long chunkSize,
String outputPath)
Splits the mbox storage into less sized parts.
chunkSize - The approximate size of a chunk in bytes.outputPath - The folder path where chunks will be created.ArgumentException - Throws when the path parameter is null or empty.public final void splitInto(long chunkSize,
String outputPath,
String partFileNamePrefix)
Splits the mbox storage into less sized parts.
chunkSize - The approximate size of a chunk in bytes.outputPath - The folder path where chunks will be created.public final void cancel()
This method is used to interrupt a split operation if splitInto is running asynchronously.
public abstract MailMessage readNextMessage()
Reads the next message from underlying storage stream.
MailMessage object if it can be read or <b>null</b> if no more messages are available.public abstract MailMessage readNextMessage(String[] fromMarker)
Reads the next message from underlying storage stream.
fromMarker - Gets the From Marker while parsing the MBox Storage file.MailMessage object if it can be read or <b>null</b> if no more messages are available.public abstract MailMessage readNextMessage(EmlLoadOptions options)
Reads the next message from underlying storage stream.
options - Specifies EmlLoadOptions when reading message from Mbox storage.MailMessage object if it can be read or <b>null</b> if no more messages are available.public abstract MailMessage readNextMessage(String[] fromMarker, EmlLoadOptions options)
Reads the next message from underlying storage stream.
fromMarker - Gets the From Marker while parsing the MBox Storage file.options - Specifies EmlLoadOptions when reading message from Mbox storage.MailMessage object if it can be read or <b>null</b> if no more messages are available.public abstract MboxMessageInfo nextMessage()
Gets the next message info.
MboxMessageInfo object if it can be read or <b>null</b> if no more messages are available.public abstract int getTotalItemsCount()
Returns the number of messages in a storage.
public final void dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
dispose in interface IDisposablepublic void close()
close in interface Closeableclose in interface AutoCloseableprotected void dispose(boolean disposing)
Releases unmanaged and - optionally - managed resources
disposing - true to release both managed and unmanaged resources; false to release only unmanaged resources.protected static boolean byteArrayStartsFromMarker(byte[] array,
byte[] marker)
Checks whether the array starts from given marker.
array - The array, can be null.marker - The marker, can't be null.protected static boolean containsAsctime(byte[] currentLine)
Determines whether the specified line contains asctime string.
currentLine - The current line.true if the specified current line contains asctime; otherwise, false.protected static byte[] readLine(Stream stream)
Reads the line from stream.
stream - The stream.Copyright (c) 2008-2024 Aspose Pty Ltd. All Rights Reserved.