Class MboxIterator
java.lang.Object
org.apache.james.mime4j.mboxiterator.MboxIterator
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<CharBufferWrapper>
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:
- http://tools.ietf.org/html/rfc4155
- http://qmail.org/man/man5/mbox.html
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBuffer
private final CharsetDecoder
private boolean
Flag to signal end of input toCharsetDecoder.decode(java.nio.ByteBuffer)
.private int
private int
private boolean
private Matcher
private final int
private final Path
private final CharBuffer
private final Pattern
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
MboxIterator
(Path mbox, Charset charset, String regexpPattern, int regexpFlags, int MAX_MESSAGE_SIZE) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
bufferDetailsToString
(Buffer buffer) Utility method to log important details about buffers.void
close()
private void
static MboxIterator.Builder
static MboxIterator.Builder
static MboxIterator.Builder
protected void
initialize the Mailbox iteratoriterator()
private void
saveFindPositions
(Matcher lineMatcher) private void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
mboxCharBuffer
-
fromLineMatcher
-
fromLineFound
private boolean fromLineFound -
byteBuffer
-
DECODER
-
endOfInputFlag
private boolean endOfInputFlagFlag to signal end of input toCharsetDecoder.decode(java.nio.ByteBuffer)
. -
maxMessageSize
private final int maxMessageSize -
MESSAGE_START
-
findStart
private int findStart -
findEnd
private int findEnd -
mbox
-
-
Constructor Details
-
MboxIterator
private MboxIterator(Path mbox, Charset charset, String regexpPattern, int regexpFlags, int MAX_MESSAGE_SIZE) throws FileNotFoundException, IOException, CharConversionException
-
-
Method Details
-
initMboxIterator
initialize the Mailbox iterator- Throws:
IOException
CharConversionException
-
decodeNextCharBuffer
- Throws:
CharConversionException
-
updateEndOfInputFlag
private void updateEndOfInputFlag() -
saveFindPositions
-
iterator
- Specified by:
iterator
in interfaceIterable<CharBufferWrapper>
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
fromFile
-
fromFile
-
fromFile
-
bufferDetailsToString
Utility method to log important details about buffers.- Parameters:
buffer
-
-