public abstract class Body
extends java.lang.Object
implements com.vordel.dispose.Disposable
ContentType
and an InputStream
, via create(com.vordel.mime.HeaderSet, com.vordel.mime.ContentType, com.vordel.dwe.ContentSource)
Specific subclasses may be constructed directly.
BodyFactory objects can register their interest in subclassing specific
content types (see registerFactory(java.lang.String, com.vordel.mime.BodyFactory)
)
Modifier and Type | Field and Description |
---|---|
static int |
CAN_INVALIDATE
Flags for write:
|
protected com.vordel.mime.ContentType |
contentType |
static com.vordel.mime.ContentType |
CT_APP_OCTET_STREAM |
static com.vordel.mime.ContentType |
CT_DEFAULT |
static com.vordel.mime.ContentType |
CT_MULTIPART_FORM_DATA |
static com.vordel.mime.ContentType |
CT_MULTIPART_RELATED |
static com.vordel.mime.ContentType |
CT_TEXT_PLAIN |
static com.vordel.mime.ContentType |
CT_TEXT_XML_UTF8 |
static com.vordel.mime.ContentType |
CT_XOP_APPLICATION_XML |
static int |
PUSH_WRITE |
static int |
REMOVE_XFER_ENCODING_ON_WRITE_DEPRECATED |
static int |
RETAIN_XFER_ENCODING_ON_READ |
static int |
WRITE_NO_CTE |
Modifier | Constructor and Description |
---|---|
protected |
Body(com.vordel.mime.HeaderSet headers,
com.vordel.mime.ContentType contentType)
Base constructor for body.
|
Modifier and Type | Method and Description |
---|---|
void |
bufferInput() |
abstract boolean |
contentAvailable() |
static Body |
create(com.vordel.mime.HeaderSet headers,
com.vordel.mime.ContentType ct,
com.vordel.dwe.ContentSource source)
Construct a subclass of body from a set of headers, a content type, and an InputStream.
|
void |
dispose() |
static void |
fini() |
java.lang.String |
getContentEncoding()
Return content encoding.
|
java.lang.String |
getContentId()
Get the Content Id for this body.
|
long |
getContentLength(int flags)
Return the Content length of the body.
|
com.vordel.mime.ContentType |
getContentType()
Get the ContentType for this body.
|
com.vordel.mime.HeaderSet |
getHeaders()
Get the MIME headers for this body.
|
java.io.InputStream |
getInputStream(int flags)
Get the input stream associated with the content.
|
CompoundBody |
getParent()
Get the parent Body.
|
com.vordel.dwe.ContentSource |
getSource()
Get a ContentSource that can be used as a factory for InputStreams
from which to read the original message content.
|
void |
initSource(com.vordel.dwe.ContentSource source,
java.lang.String encoding) |
void |
parse()
If necessary, read the InputStream source for a body to "parse" it.
|
protected abstract void |
parse(java.io.InputStream is)
Parse a body from a specific InputStream.
|
protected abstract void |
purgeContent()
Bodies are purged() when they are no longer in use.
|
static void |
registerFactory(java.lang.String pattern,
BodyFactory factory)
Register a handler for a set of content types.
|
protected void |
setParent(CompoundBody parent) |
void |
sevenbit() |
void |
willwrite(java.io.OutputStream os,
int flags) |
void |
write(java.io.OutputStream os,
int flags)
Write the content of this Body (not including its headers)
to an OutputStream.
|
abstract void |
writeContent(java.io.OutputStream os,
int flags)
Write the content of the body to the specified OutputStream
This is similar to
write(java.io.OutputStream, int) , but does not include the
headers for the body. |
public static final com.vordel.mime.ContentType CT_DEFAULT
public static final com.vordel.mime.ContentType CT_TEXT_PLAIN
public static final com.vordel.mime.ContentType CT_APP_OCTET_STREAM
public static final com.vordel.mime.ContentType CT_MULTIPART_RELATED
public static final com.vordel.mime.ContentType CT_MULTIPART_FORM_DATA
public static final com.vordel.mime.ContentType CT_XOP_APPLICATION_XML
public static final com.vordel.mime.ContentType CT_TEXT_XML_UTF8
protected final com.vordel.mime.ContentType contentType
public static final int CAN_INVALIDATE
public static final int PUSH_WRITE
public static final int REMOVE_XFER_ENCODING_ON_WRITE_DEPRECATED
public static final int RETAIN_XFER_ENCODING_ON_READ
public static final int WRITE_NO_CTE
protected Body(com.vordel.mime.HeaderSet headers, com.vordel.mime.ContentType contentType)
headers
- the headers for the content of this body.contentType
- The MIME content type for this body.public abstract boolean contentAvailable()
public void bufferInput() throws java.io.IOException
java.io.IOException
public com.vordel.dwe.ContentSource getSource()
public java.io.InputStream getInputStream(int flags) throws java.io.IOException
flags
- Modify the behaviour of the provided InputStream.java.io.IOException
- If there's a problem wiring up an InputStream.public CompoundBody getParent()
public com.vordel.mime.HeaderSet getHeaders()
public com.vordel.mime.ContentType getContentType()
public java.lang.String getContentId()
public long getContentLength(int flags) throws java.io.IOException
Note that as the flags sent to the write(java.io.OutputStream, int)
method may
affect the output, this method must be passed the same flags.
flags
- The same flags that are used to modify the output from the write method.java.io.IOException
- If there's a problem determining the length of the content.protected void setParent(CompoundBody parent)
public static void registerFactory(java.lang.String pattern, BodyFactory factory)
pattern
- The content type name to match.factory
- The factory to create a Body when the type matches.public static void fini()
public static Body create(com.vordel.mime.HeaderSet headers, com.vordel.mime.ContentType ct, com.vordel.dwe.ContentSource source)
Note that the InputStream will not be read until the body is parse()
d
headers
- The Message Headers.ct
- The ContentType for the Body.source
- The source of the InputStream which will create the Body, via the registered BodyFactory.protected abstract void parse(java.io.InputStream is) throws java.io.IOException
This should be considered "private" to callers:
it must be invoked via
parse()
is
- The InputStream from which to parse the body.java.io.IOException
- if there are problems reading from the InputStream.parse()
public final void parse() throws java.io.IOException
java.io.IOException
- if there are problems reading from the InputStream.public void initSource(com.vordel.dwe.ContentSource source, java.lang.String encoding)
public java.lang.String getContentEncoding()
public void sevenbit() throws java.io.IOException
java.io.IOException
public final void willwrite(java.io.OutputStream os, int flags) throws java.io.IOException
java.io.IOException
public final void write(java.io.OutputStream os, int flags) throws java.io.IOException
os
- The OutputStream to write toflags
- A bitwise OR of the following flags.
java.io.IOException
- If there are problems writing to the OutputStream.public abstract void writeContent(java.io.OutputStream os, int flags) throws java.io.IOException
write(java.io.OutputStream, int)
, but does not include the
headers for the body.os
- OutputStream The OutputStream destination for the Body.flags
- Customize what gets written.java.io.IOException
- If there are problems writing to the OutputStream.protected abstract void purgeContent()
public final void dispose()
dispose
in interface com.vordel.dispose.Disposable
This documentation and all its contents and graphics, copyright © 1999 - 2011 Vordel