Package org.apache.james.mime4j.stream
Class MimeEntity
java.lang.Object
org.apache.james.mime4j.stream.MimeEntity
- All Implemented Interfaces:
EntityStateMachine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ThreadLocal
<SoftReference<BufferRecycler>> private BodyDescriptor
private final BodyDescriptorBuilder
private final MimeConfig
private MimeBoundaryInputStream
private LineReaderInputStreamAdaptor
private boolean
private final EntityState
private Field
private final FieldBuilder
private int
private final BufferedLineReaderInputStream
private final ByteArrayBuffer
private int
private final LineNumberSource
private final DecodeMonitor
private RecursionMode
private EntityState
private byte[]
-
Constructor Summary
ConstructorsConstructorDescriptionMimeEntity
(LineNumberSource lineSource, InputStream instream, BodyDescriptorBuilder bodyDescBuilder) MimeEntity
(LineNumberSource lineSource, InputStream instream, FieldBuilder fieldBuilder, BodyDescriptorBuilder bodyDescBuilder) MimeEntity
(LineNumberSource lineSource, InputStream instream, MimeConfig config, BodyDescriptorBuilder bodyDescBuilder) MimeEntity
(LineNumberSource lineSource, InputStream instream, MimeConfig config, EntityState startState, EntityState endState, DecodeMonitor monitor, FieldBuilder fieldBuilder, BodyDescriptorBuilder bodyDescBuilder) -
Method Summary
Modifier and TypeMethodDescriptionadvance()
Advances the state machine to the next state in the process of the MIME stream parsing.private void
private void
private void
private InputStream
decodedStream
(InputStream instream) Gets a descriptor for the current entity.static BufferRecycler
Returns content stream of the entity body.private LineReaderInputStream
Returns the decoded content stream of the entity body.getField()
This method is valid, ifgetState()
returnsEntityState.T_FIELD
.private InputStream
private int
getState()
Return the current state of the entity.protected String
Creates an indicative message suitable for display based on the given event and the current state of the system.protected void
protected boolean
private EntityStateMachine
private EntityStateMachine
private EntityStateMachine
nextMimeEntity
(EntityState startState, EntityState endState, InputStream instream) private void
void
setRecursionMode
(RecursionMode recursionMode) Sets the current recursion mode.static String
stateToString
(EntityState state) Renders a state as a string suitable for logging.void
stop()
void
stopSoft()
toString()
-
Field Details
-
_recyclerRef
-
endState
-
config
-
monitor
-
fieldBuilder
-
bodyDescBuilder
-
linebuf
-
lineSource
-
inbuffer
-
state
-
lineCount
private int lineCount -
endOfHeader
private boolean endOfHeader -
headerCount
private int headerCount -
field
-
body
-
recursionMode
-
currentMimePartStream
-
dataStream
-
tmpbuf
private byte[] tmpbuf
-
-
Constructor Details
-
MimeEntity
MimeEntity(LineNumberSource lineSource, InputStream instream, MimeConfig config, EntityState startState, EntityState endState, DecodeMonitor monitor, FieldBuilder fieldBuilder, BodyDescriptorBuilder bodyDescBuilder) -
MimeEntity
MimeEntity(LineNumberSource lineSource, InputStream instream, MimeConfig config, BodyDescriptorBuilder bodyDescBuilder) -
MimeEntity
MimeEntity(LineNumberSource lineSource, InputStream instream, FieldBuilder fieldBuilder, BodyDescriptorBuilder bodyDescBuilder) -
MimeEntity
MimeEntity(LineNumberSource lineSource, InputStream instream, BodyDescriptorBuilder bodyDescBuilder)
-
-
Method Details
-
getBufferRecycler
-
getState
Description copied from interface:EntityStateMachine
Return the current state of the entity.- Specified by:
getState
in interfaceEntityStateMachine
- Returns:
- current state
- See Also:
-
getRecursionMode
-
setRecursionMode
Description copied from interface:EntityStateMachine
Sets the current recursion mode. The recursion mode specifies the approach taken to parsing parts.RecursionMode.M_RAW
mode does not parse the part at all.RecursionMode.M_RECURSE
mode recursively parses each mail when anmessage/rfc822
part is encounted;RecursionMode.M_NO_RECURSE
does not.- Specified by:
setRecursionMode
in interfaceEntityStateMachine
- Parameters:
recursionMode
-- See Also:
-
stop
public void stop() -
stopSoft
public void stopSoft() -
getLineNumber
private int getLineNumber() -
getDataStream
-
message
Creates an indicative message suitable for display based on the given event and the current state of the system.- Parameters:
event
-Event
, not null- Returns:
- message suitable for use as a message in an exception or for logging
-
monitor
- Throws:
MimeException
IOException
-
readRawField
- Throws:
IOException
MimeException
-
nextField
- Throws:
MimeException
IOException
-
advance
Description copied from interface:EntityStateMachine
Advances the state machine to the next state in the process of the MIME stream parsing. This method may return an new state machine that represents an embedded entity, which must be parsed before the parsing process of the current entity can proceed.- Specified by:
advance
in interfaceEntityStateMachine
- Returns:
- a state machine of an embedded entity, if encountered,
null
otherwise. - Throws:
IOException
- if an I/O error occurs.MimeException
- if the message can not be processed due to the MIME specification violation.
-
createMimePartStream
- Throws:
MimeException
IOException
-
clearMimePartStream
private void clearMimePartStream() -
advanceToBoundary
- Throws:
IOException
-
nextMessage
-
decodedStream
-
nextMimeEntity
-
nextMimeEntity
private EntityStateMachine nextMimeEntity(EntityState startState, EntityState endState, InputStream instream) -
getLimitedContentStream
-
getBodyDescriptor
Gets a descriptor for the current entity. This method is valid if
getState()
returns:- Specified by:
getBodyDescriptor
in interfaceEntityStateMachine
- Returns:
BodyDescriptor
, not nulls
-
getField
This method is valid, ifgetState()
returnsEntityState.T_FIELD
.- Specified by:
getField
in interfaceEntityStateMachine
- Returns:
- String with the fields raw contents.
- Throws:
IllegalStateException
-getState()
returns another value thanEntityState.T_FIELD
.
-
getContentStream
Description copied from interface:EntityStateMachine
Returns content stream of the entity body.- Specified by:
getContentStream
in interfaceEntityStateMachine
- Returns:
- input stream
- See Also:
-
getDecodedContentStream
Description copied from interface:EntityStateMachine
Returns the decoded content stream of the entity body.- Specified by:
getDecodedContentStream
in interfaceEntityStateMachine
- Returns:
- input stream
- Throws:
IllegalStateException
- if the content stream cannot be obtained at the current stage of the parsing process.- See Also:
-
toString
-
stateToString
Renders a state as a string suitable for logging.- Parameters:
state
-- Returns:
- rendered as string, not null
-