org.apache.james.mime4j.field
Class ContentTypeField

java.lang.Object
  extended by org.apache.james.mime4j.field.Field
      extended by org.apache.james.mime4j.field.ContentTypeField

public class ContentTypeField
extends Field

Represents a Content-Type field.

Version:
$Id: ContentTypeField.java,v 1.6 2005/01/27 14:16:31 ntherning Exp $

Nested Class Summary
static class ContentTypeField.Parser
           
 
Field Summary
static java.lang.String PARAM_BOUNDARY
          The name of the boundary parameter.
static java.lang.String PARAM_CHARSET
          The name of the charset parameter.
static java.lang.String TYPE_MESSAGE_RFC822
          The message/rfc822 MIME type.
static java.lang.String TYPE_MULTIPART_DIGEST
          The multipart/digest MIME type.
static java.lang.String TYPE_MULTIPART_PREFIX
          The prefix of all multipart MIME types.
static java.lang.String TYPE_TEXT_PLAIN
          The text/plain MIME type.
 
Fields inherited from class org.apache.james.mime4j.field.Field
BCC, CC, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, DATE, FROM, REPLY_TO, RESENT_BCC, RESENT_CC, RESENT_DATE, RESENT_FROM, RESENT_SENDER, RESENT_TO, SENDER, SUBJECT, TO
 
Constructor Summary
protected ContentTypeField(java.lang.String name, java.lang.String body, java.lang.String raw, java.lang.String mimeType, java.util.Map parameters, ParseException parseException)
           
 
Method Summary
 java.lang.String getBoundary()
          Gets the value of the boundary parameter if set.
 java.lang.String getCharset()
          Gets the value of the charset parameter if set.
static java.lang.String getCharset(ContentTypeField f)
          Gets the value of the charset parameter if set for the given field.
 java.lang.String getMimeType()
          Gets the MIME type defined in this Content-Type field.
static java.lang.String getMimeType(ContentTypeField child, ContentTypeField parent)
          Gets the MIME type defined in the child's Content-Type field or derives a MIME type from the parent if child is null or hasn't got a MIME type value set.
 java.lang.String getParameter(java.lang.String name)
          Gets the value of a parameter.
 java.util.Map getParameters()
          Gets all parameters.
 ParseException getParseException()
          Gets the exception that was raised during parsing of the field value, if any; otherwise, null.
 boolean isMimeType(java.lang.String mimeType)
          Determines if the MIME type of this field matches the given one.
 boolean isMultipart()
          Determines if the MIME type of this field is multipart/*.
 
Methods inherited from class org.apache.james.mime4j.field.Field
getBody, getName, getParser, getRaw, isContentType, isFrom, isSubject, isTo, parse, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_MULTIPART_PREFIX

public static final java.lang.String TYPE_MULTIPART_PREFIX
The prefix of all multipart MIME types.

See Also:
Constant Field Values

TYPE_MULTIPART_DIGEST

public static final java.lang.String TYPE_MULTIPART_DIGEST
The multipart/digest MIME type.

See Also:
Constant Field Values

TYPE_TEXT_PLAIN

public static final java.lang.String TYPE_TEXT_PLAIN
The text/plain MIME type.

See Also:
Constant Field Values

TYPE_MESSAGE_RFC822

public static final java.lang.String TYPE_MESSAGE_RFC822
The message/rfc822 MIME type.

See Also:
Constant Field Values

PARAM_BOUNDARY

public static final java.lang.String PARAM_BOUNDARY
The name of the boundary parameter.

See Also:
Constant Field Values

PARAM_CHARSET

public static final java.lang.String PARAM_CHARSET
The name of the charset parameter.

See Also:
Constant Field Values
Constructor Detail

ContentTypeField

protected ContentTypeField(java.lang.String name,
                           java.lang.String body,
                           java.lang.String raw,
                           java.lang.String mimeType,
                           java.util.Map parameters,
                           ParseException parseException)
Method Detail

getParseException

public ParseException getParseException()
Gets the exception that was raised during parsing of the field value, if any; otherwise, null.


getMimeType

public java.lang.String getMimeType()
Gets the MIME type defined in this Content-Type field.

Returns:
the MIME type or an empty string if not set.

getMimeType

public static java.lang.String getMimeType(ContentTypeField child,
                                           ContentTypeField parent)
Gets the MIME type defined in the child's Content-Type field or derives a MIME type from the parent if child is null or hasn't got a MIME type value set. If child's MIME type is multipart but no boundary has been set the MIME type of child will be derived from the parent.

Parameters:
child - the child.
parent - the parent.
Returns:
the MIME type.

getParameter

public java.lang.String getParameter(java.lang.String name)
Gets the value of a parameter. Parameter names are case-insensitive.

Parameters:
name - the name of the parameter to get.
Returns:
the parameter value or null if not set.

getParameters

public java.util.Map getParameters()
Gets all parameters.

Returns:
the parameters.

getBoundary

public java.lang.String getBoundary()
Gets the value of the boundary parameter if set.

Returns:
the boundary parameter value or null if not set.

getCharset

public java.lang.String getCharset()
Gets the value of the charset parameter if set.

Returns:
the charset parameter value or null if not set.

getCharset

public static java.lang.String getCharset(ContentTypeField f)
Gets the value of the charset parameter if set for the given field. Returns the default us-ascii if not set or if f is null.

Returns:
the charset parameter value.

isMimeType

public boolean isMimeType(java.lang.String mimeType)
Determines if the MIME type of this field matches the given one.

Parameters:
mimeType - the MIME type to match against.
Returns:
true if the MIME type of this field matches, false otherwise.

isMultipart

public boolean isMultipart()
Determines if the MIME type of this field is multipart/*.

Returns:
true if this field is has a multipart/* MIME type, false otherwise.


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.