public class MimeTokenStream
extends java.lang.Object
Description:
Title:首亨软件 - TSS/CRM等
构造器和说明 |
---|
MimeTokenStream()
Constructs a standard (lax) stream.
|
MimeTokenStream(MimeConfig config) |
MimeTokenStream(MimeConfig config,
BodyDescriptorBuilder bodyDescBuilder) |
MimeTokenStream(MimeConfig config,
DecodeMonitor monitor,
BodyDescriptorBuilder bodyDescBuilder) |
MimeTokenStream(MimeConfig config,
DecodeMonitor monitor,
FieldBuilder fieldBuilder,
BodyDescriptorBuilder bodyDescBuilder) |
限定符和类型 | 方法和说明 |
---|---|
BodyDescriptor |
getBodyDescriptor()
Gets a descriptor for the current entity.
|
MimeConfig |
getConfig() |
java.io.InputStream |
getDecodedInputStream()
This method returns a transfer decoded stream based on the MIME
fields with the standard defaults.
|
Field |
getField()
This method is valid, if
getState() returns EntityState.T_FIELD . |
java.io.InputStream |
getInputStream() |
java.io.Reader |
getReader()
Gets a reader configured for the current body or body part.
|
RecursionMode |
getRecursionMode()
Gets the current recursion mode.
|
EntityState |
getState()
Returns the current state.
|
boolean |
isRaw()
Determines if this parser is currently in raw mode.
|
EntityState |
next()
This method advances the token stream to the next token.
|
void |
parse(java.io.InputStream stream)
Instructs the
MimeTokenStream to parse the given streams contents. |
Field |
parseHeadless(java.io.InputStream stream,
java.lang.String contentType)
Instructs the
MimeTokenStream to parse the given content with
the content type. |
void |
setRecursionMode(RecursionMode mode)
Sets the current recursion.
|
static java.lang.String |
stateToString(EntityState state)
Renders a state as a string suitable for logging.
|
void |
stop()
Finishes the parsing and stops reading lines.
|
public MimeTokenStream()
MimeConfig.setStrictParsing(boolean)
to turn on strict
parsing mode and pass the config object to
MimeTokenStream(MimeConfig)
to create
a stream that strictly validates the input.public MimeTokenStream(MimeConfig config)
public MimeTokenStream(MimeConfig config, BodyDescriptorBuilder bodyDescBuilder)
public MimeTokenStream(MimeConfig config, DecodeMonitor monitor, BodyDescriptorBuilder bodyDescBuilder)
public MimeTokenStream(MimeConfig config, DecodeMonitor monitor, FieldBuilder fieldBuilder, BodyDescriptorBuilder bodyDescBuilder)
public void parse(java.io.InputStream stream)
MimeTokenStream
to parse the given streams contents.
If the MimeTokenStream
has already been in use, resets the streams
internal state.stream
- InputStreampublic Field parseHeadless(java.io.InputStream stream, java.lang.String contentType)
Instructs the MimeTokenStream
to parse the given content with
the content type. The message stream is assumed to have no message header
and is expected to begin with a message body. This can be the case when
the message content is transmitted using a different transport protocol
such as HTTP.
If the MimeTokenStream
has already been in use, resets the
streams internal state.
stream
- InputStreamcontentType
- Stringpublic boolean isRaw()
true
if in raw mode, false
otherwise.setRecursionMode(RecursionMode)
public RecursionMode getRecursionMode()
RecursionMode.M_RAW
mode does not parse the part at all.
RecursionMode.M_RECURSE
mode recursively parses each mail
when an message/rfc822
part is encountered;
RecursionMode.M_NO_RECURSE
does not.public void setRecursionMode(RecursionMode mode)
RecursionMode.M_RAW
mode does not parse the part at all.
RecursionMode.M_RECURSE
mode recursively parses each mail
when an message/rfc822
part is encountered;
RecursionMode.M_NO_RECURSE
does not.mode
- RecursionMode.M_RECURSE
, RecursionMode.M_RAW
or
RecursionMode.M_NO_RECURSE
public void stop()
public EntityState getState()
public java.io.InputStream getInputStream()
public java.io.InputStream getDecodedInputStream()
getState()
returns either of
EntityState.T_RAW_ENTITY
, EntityState.T_PREAMBLE
, or
EntityState.T_EPILOGUE
.java.lang.IllegalStateException
- getState()
returns an
invalid value.public java.io.Reader getReader()
public BodyDescriptor getBodyDescriptor()
Gets a descriptor for the current entity.
This method is valid if getState()
returns:
BodyDescriptor
, not nullspublic Field getField()
getState()
returns EntityState.T_FIELD
.java.lang.IllegalStateException
- getState()
returns another
value than EntityState.T_FIELD
.public EntityState next() throws java.io.IOException, MimeException
java.lang.IllegalStateException
- The method has been called, although
getState()
was already EntityState.T_END_OF_STREAM
.java.io.IOException
- IOExceptionMimeException
- MimeExceptionpublic static final java.lang.String stateToString(EntityState state)
state
- EntityStatepublic MimeConfig getConfig()