public class MboxIterator extends java.lang.Object implements java.lang.Iterable<CharBufferWrapper>, java.io.Closeable
Class that provides an iterator over email messages inside an mbox file. An mbox file is a sequence of email messages separated by From_ lines.
Description ot the file format:
| Modifier and Type | Class and Description |
|---|---|
static class |
MboxIterator.Builder |
private class |
MboxIterator.MessageIterator |
| Modifier and Type | Field and Description |
|---|---|
private java.nio.MappedByteBuffer |
byteBuffer |
private java.nio.charset.CharsetDecoder |
DECODER |
private boolean |
endOfInputFlag
Flag to signal end of input to
CharsetDecoder.decode(java.nio.ByteBuffer) . |
private int |
findEnd |
private int |
findStart |
private boolean |
fromLineFound |
private java.util.regex.Matcher |
fromLineMatcher |
private int |
maxMessageSize |
private java.io.File |
mbox |
private java.nio.CharBuffer |
mboxCharBuffer |
private java.util.regex.Pattern |
MESSAGE_START |
private java.io.FileInputStream |
theFile |
| Modifier | Constructor and Description |
|---|---|
private |
MboxIterator(java.io.File mbox,
java.nio.charset.Charset charset,
java.lang.String regexpPattern,
int regexpFlags,
int MAX_MESSAGE_SIZE) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
bufferDetailsToString(java.nio.Buffer buffer)
Utility method to log important details about buffers.
|
void |
close() |
private void |
decodeNextCharBuffer() |
static MboxIterator.Builder |
fromFile(java.io.File filePath) |
static MboxIterator.Builder |
fromFile(java.lang.String file) |
protected void |
initMboxIterator()
initialize the Mailbox iterator
|
java.util.Iterator<CharBufferWrapper> |
iterator() |
private void |
saveFindPositions(java.util.regex.Matcher lineMatcher) |
private void |
updateEndOfInputFlag() |
private final java.io.FileInputStream theFile
private final java.nio.CharBuffer mboxCharBuffer
private java.util.regex.Matcher fromLineMatcher
private boolean fromLineFound
private final java.nio.MappedByteBuffer byteBuffer
private final java.nio.charset.CharsetDecoder DECODER
private boolean endOfInputFlag
CharsetDecoder.decode(java.nio.ByteBuffer) .private final int maxMessageSize
private final java.util.regex.Pattern MESSAGE_START
private int findStart
private int findEnd
private final java.io.File mbox
private MboxIterator(java.io.File mbox,
java.nio.charset.Charset charset,
java.lang.String regexpPattern,
int regexpFlags,
int MAX_MESSAGE_SIZE)
throws java.io.FileNotFoundException,
java.io.IOException,
java.io.CharConversionException
java.io.FileNotFoundExceptionjava.io.IOExceptionjava.io.CharConversionExceptionprotected void initMboxIterator()
throws java.io.IOException
java.io.IOExceptionjava.io.CharConversionExceptionprivate void decodeNextCharBuffer()
throws java.io.CharConversionException
java.io.CharConversionExceptionprivate void updateEndOfInputFlag()
private void saveFindPositions(java.util.regex.Matcher lineMatcher)
public java.util.Iterator<CharBufferWrapper> iterator()
iterator in interface java.lang.Iterable<CharBufferWrapper>public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic static MboxIterator.Builder fromFile(java.io.File filePath)
public static MboxIterator.Builder fromFile(java.lang.String file)
public static java.lang.String bufferDetailsToString(java.nio.Buffer buffer)
buffer -