FileDocCategorySizeDatePackage
Entity.javaAPI DocAndroid 1.5 API5746Wed May 06 22:42:46 BST 2009org.apache.james.mime4j.message

Entity

public abstract class Entity extends Object
MIME entity. An entity has a header and a body (see RFC 2045).
version
$Id: Entity.java,v 1.3 2004/10/02 12:41:11 ntherning Exp $

Fields Summary
private Header
header
private Body
body
private Entity
parent
Constructors Summary
Methods Summary
public BodygetBody()
Gets the body of this entity.

return
the body,

        return body;
    
public java.lang.StringgetCharset()
Determines the MIME character set encoding of this Entity.

return
the MIME character set encoding.

        return ContentTypeField.getCharset( 
            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE));
    
public java.lang.StringgetContentTransferEncoding()
Determines the transfer encoding of this Entity.

return
the transfer encoding.

        ContentTransferEncodingField f = (ContentTransferEncodingField) 
                        getHeader().getField(Field.CONTENT_TRANSFER_ENCODING);
        
        return ContentTransferEncodingField.getEncoding(f);
    
public HeadergetHeader()
Gets the entity header.

return
the header.

        return header;
    
public java.lang.StringgetMimeType()
Determines the MIME type of this Entity. The MIME type is derived by looking at the parent's Content-Type field if no Content-Type field is set for this Entity.

return
the MIME type.

        ContentTypeField child = 
            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE);
        ContentTypeField parent = getParent() != null 
            ? (ContentTypeField) getParent().getHeader().
                                                getField(Field.CONTENT_TYPE)
            : null;
        
        return ContentTypeField.getMimeType(child, parent);
    
public org.apache.james.mime4j.message.EntitygetParent()
Gets the parent entity of this entity. Returns null if this is the root entity.

return
the parent or null.


                              
       
        return parent;
    
public booleanisMimeType(java.lang.String type)
Determines if the MIME type of this Entity matches the given one. MIME types are case-insensitive.

param
type the MIME type to match against.
return
true on match, false otherwise.

        return getMimeType().equalsIgnoreCase(type);
    
public booleanisMultipart()
Determines if the MIME type of this Entity is multipart/*. Since multipart-entities must have a boundary parameter in the Content-Type field this method returns false if no boundary exists.

return
true on match, false otherwise.

        ContentTypeField f = 
            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE);
        return f != null && f.getBoundary() != null 
            && getMimeType().startsWith(ContentTypeField.TYPE_MULTIPART_PREFIX);
    
public voidsetBody(Body body)
Sets the body of this entity.

param
body the body.

        this.body = body;
        body.setParent(this);
    
public voidsetHeader(Header header)
Sets the entity header.

param
header the header.

        this.header = header;
    
public voidsetParent(org.apache.james.mime4j.message.Entity parent)
Sets the parent entity of this entity.

param
parent the parent entity or null if this will be the root entity.

        this.parent = parent;
    
public abstract voidwriteTo(java.io.OutputStream out)
Write the content to the given outputstream

param
out the outputstream to write to
throws
IOException