Overview | Package | Class | Tree | Deprecated | Index | Help
| Vordel SDK
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vordel.mime
Class Body

    java.lang.Object
      com.vordel.mime.Body

All Implemented Interfaces:
  com.vordel.system.Disposable

Direct Known Subclasses:
  CompoundBody, FormURLEncodedBody, RawBody, XMLBody

    public abstract class Body

extends java.lang.Object
implements com.vordel.system.Disposable

Represents a MIME body. Bodies are generally constructed from a `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)`)

Field Summary
`static int` | `CAN_INVALIDATE` Flags for write:
`protected ContentType` | `contentType`
`static ContentType` | `CT_APP_OCTET_STREAM`
`static ContentType` | `CT_DEFAULT`
`static ContentType` | `CT_MULTIPART_RELATED`
`static ContentType` | `CT_TEXT_PLAIN`
`static ContentType` | `CT_TEXT_XML_UTF8`
`static ContentType` | `CT_XOP_APPLICATION_XML`
`protected HeaderSet` | `headers`
`static int` | `PUSH_WRITE`
`static int` | `REMOVE_XFER_ENCODING_ON_WRITE`
`static int` | `RETAIN_XFER_ENCODING_ON_READ`

Constructor Summary
`protected` | `Body(HeaderSet headers, ContentType contentType)` Base constructor for body.

Method Summary
`void` | `bufferInput()`
`abstract boolean` | `contentAvailable()`
`static Body` | `create(HeaderSet headers, 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.
`ContentType` | `getContentType()` Get the ContentType for this body.
`HeaderSet` | `getHeaders()` Get the MIME headers for this body.
`java.io.InputStream` | `getInputStream(int flags)`
`CompoundBody` | `getParent()` Get the parent Body.
`com.vordel.dwe.ContentSource` | `getSource()` Get a ContentSource that can be used as a factory for InputStream's 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` | `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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CT_DEFAULT

    public static final ContentType CT_DEFAULT

### CT_TEXT_PLAIN

    public static final ContentType CT_TEXT_PLAIN

### CT_APP_OCTET_STREAM

    public static final ContentType CT_APP_OCTET_STREAM

### CT_MULTIPART_RELATED

    public static final ContentType CT_MULTIPART_RELATED

### CT_XOP_APPLICATION_XML

    public static final ContentType CT_XOP_APPLICATION_XML

### CT_TEXT_XML_UTF8

    public static final ContentType CT_TEXT_XML_UTF8

### contentType

    protected final ContentType contentType

### headers

    protected final HeaderSet headers

### CAN_INVALIDATE

    public static final int CAN_INVALIDATE

  Flags for write:

  See Also:
    Constant Field Values

### PUSH_WRITE

    public static final int PUSH_WRITE

See Also:
  Constant Field Values

### REMOVE_XFER_ENCODING_ON_WRITE

    public static final int REMOVE_XFER_ENCODING_ON_WRITE

See Also:
  Constant Field Values

### RETAIN_XFER_ENCODING_ON_READ

    public static final int RETAIN_XFER_ENCODING_ON_READ

See Also:
  Constant Field Values

Constructor Detail

### Body

    protected Body(HeaderSet headers,
                   ContentType contentType)

  Base constructor for body.

  Parameters:
    `headers` - the headers for the content of this body.
    `contentType` - The MIME content type for this body.

Method Detail

### contentAvailable

    public abstract boolean contentAvailable()

### bufferInput

    public void bufferInput()
                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### getSource

    public com.vordel.dwe.ContentSource getSource()

  Get a ContentSource that can be used as a factory for InputStream's from which to read the original message content.

### getInputStream

    public java.io.InputStream getInputStream(int flags)
                                       throws java.io.IOException

  Throws:
    `java.io.IOException`

### getParent

    public CompoundBody getParent()

  Get the parent Body.

  Returns:
    The parent CompoundBody if this Body is nested in one, or null.

### getHeaders

    public HeaderSet getHeaders()

  Get the MIME headers for this body.

  Returns:
    the set of headers.

### getContentType

    public ContentType getContentType()

  Get the ContentType for this body.

  Returns:
    the ContentType

### getContentId

    public java.lang.String getContentId()

  Get the Content Id for this body.

  Returns:
    the ContentType

### getContentLength

    public long getContentLength(int flags)
                          throws java.io.IOException

  Return the Content length of the body. Note that this may be expensive: unless the subclass specifically implements it, it is implemented by serialising the body.

  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.

  Throws:
    `java.io.IOException`

### setParent

    protected void setParent(CompoundBody parent)

### registerFactory

    public static void registerFactory(java.lang.String pattern,
                                       BodyFactory factory)

  Register a handler for a set of content types. The pattern may contain "*" wildcard characters. The handler that matches the longest substring of a body is used in preference to shorter matches.

### fini

    public static void fini()

### create

    public static Body create(HeaderSet headers,
                              ContentType ct,
                              com.vordel.dwe.ContentSource source)

  Construct a subclass of body from a set of headers, a content type, and an InputStream.

  Note that the InputStream will not be read until the body is `parse()`d

### parse

    protected abstract void parse(java.io.InputStream is)
                           throws java.io.IOException

  Parse a body from a specific InputStream.

  This should be considered "private" to callers: it must be invoked via `parse()`

  Throws:
    `java.io.IOException`
  See Also:
    `parse()`

### parse

    public final void parse()
                     throws java.io.IOException

  If necessary, read the InputStream source for a body to "parse" it.

  Throws:
    `java.io.IOException`

### initSource

    public void initSource(com.vordel.dwe.ContentSource source,
                           java.lang.String encoding)

### getContentEncoding

    public java.lang.String getContentEncoding()

  Return content encoding.

### write

    public final void write(java.io.OutputStream os,
                            int flags)
                     throws java.io.IOException

  Write the content of this Body (not including its headers) to an OutputStream.

  Parameters:
    `os` - The OutputStream to write to
    `flags` - A bitwise OR of the following flags.
    CAN_INVALIDATE
      If this method will be the last operation carried out on the Body, passing this flag can vastly optimise the write operation. In particular an unparsed body can be written to its destination without any parsing overhead, purely by relaying from the original input stream to the destination output stream.
    PUSH_WRITE
    Don't delay/cache the writing of data chunks during the relaying.
  Throws:
    `java.io.IOException`

### writeContent

    public abstract void writeContent(java.io.OutputStream os,
                                      int flags)
                               throws java.io.IOException

  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.

  Throws:
    `java.io.IOException`
  See Also:
    `#wrote`

### purgeContent

    protected abstract void purgeContent()

  Bodies are purged() when they are no longer in use. This provides similar functionality to the "finalize()" method, but may be called by any caller, or in any thread, when it is known that a body is no longer in use.

### dispose

    public final void dispose()

  Specified by:
    `dispose` in interface `com.vordel.system.Disposable`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Vordel SDK
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

This documentation and all its contents and graphics, copyright © 1999 - 2011 Vordel