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 BodyDescriptorprivate final BodyDescriptorBuilderprivate final MimeConfigprivate MimeBoundaryInputStreamprivate LineReaderInputStreamAdaptorprivate booleanprivate final EntityStateprivate Fieldprivate final FieldBuilderprivate intprivate final BufferedLineReaderInputStreamprivate final ByteArrayBufferprivate intprivate final LineNumberSourceprivate final DecodeMonitorprivate RecursionModeprivate EntityStateprivate 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 voidprivate voidprivate voidprivate InputStreamdecodedStream(InputStream instream) Gets a descriptor for the current entity.static BufferRecyclerReturns content stream of the entity body.private LineReaderInputStreamReturns the decoded content stream of the entity body.getField()This method is valid, ifgetState()returnsEntityState.T_FIELD.private InputStreamprivate intgetState()Return the current state of the entity.protected StringCreates an indicative message suitable for display based on the given event and the current state of the system.protected voidprotected booleanprivate EntityStateMachineprivate EntityStateMachineprivate EntityStateMachinenextMimeEntity(EntityState startState, EntityState endState, InputStream instream) private voidvoidsetRecursionMode(RecursionMode recursionMode) Sets the current recursion mode.static StringstateToString(EntityState state) Renders a state as a string suitable for logging.voidstop()voidstopSoft()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:EntityStateMachineReturn the current state of the entity.- Specified by:
getStatein interfaceEntityStateMachine- Returns:
- current state
- See Also:
-
getRecursionMode
-
setRecursionMode
Description copied from interface:EntityStateMachineSets the current recursion mode. The recursion mode specifies the approach taken to parsing parts.RecursionMode.M_RAWmode does not parse the part at all.RecursionMode.M_RECURSEmode recursively parses each mail when anmessage/rfc822part is encounted;RecursionMode.M_NO_RECURSEdoes not.- Specified by:
setRecursionModein interfaceEntityStateMachine- Parameters:
recursionMode-- See Also:
-
stop
public void stop() -
stopSoft
public void stopSoft() -
getLineNumber
private int getLineNumber() -
getDataStream
-
message
-
monitor
- Throws:
MimeExceptionIOException
-
readRawField
- Throws:
IOExceptionMimeException
-
nextField
- Throws:
MimeExceptionIOException
-
advance
Description copied from interface:EntityStateMachineAdvances 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:
advancein interfaceEntityStateMachine- Returns:
- a state machine of an embedded entity, if encountered,
nullotherwise. - Throws:
IOException- if an I/O error occurs.MimeException- if the message can not be processed due to the MIME specification violation.
-
createMimePartStream
- Throws:
MimeExceptionIOException
-
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:
getBodyDescriptorin interfaceEntityStateMachine- Returns:
BodyDescriptor, not nulls
-
getField
This method is valid, ifgetState()returnsEntityState.T_FIELD.- Specified by:
getFieldin interfaceEntityStateMachine- Returns:
- String with the fields raw contents.
- Throws:
IllegalStateException-getState()returns another value thanEntityState.T_FIELD.
-
getContentStream
Description copied from interface:EntityStateMachineReturns content stream of the entity body.- Specified by:
getContentStreamin interfaceEntityStateMachine- Returns:
- input stream
- See Also:
-
getDecodedContentStream
Description copied from interface:EntityStateMachineReturns the decoded content stream of the entity body.- Specified by:
getDecodedContentStreamin 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
-