org.apache.james.mime4j.field
Class ContentTypeFieldImpl

java.lang.Object
  extended by org.apache.james.mime4j.field.AbstractField
      extended by org.apache.james.mime4j.field.ContentTypeFieldImpl
All Implemented Interfaces:
ContentTypeField, ParsedField, Field

public class ContentTypeFieldImpl
extends AbstractField
implements ContentTypeField

Represents a Content-Type field.


Field Summary
static FieldParser<ContentTypeField> PARSER
           
 
Fields inherited from class org.apache.james.mime4j.field.AbstractField
monitor, rawField
 
Fields inherited from interface org.apache.james.mime4j.dom.field.ContentTypeField
PARAM_BOUNDARY, PARAM_CHARSET, TYPE_MESSAGE_RFC822, TYPE_MULTIPART_DIGEST, TYPE_MULTIPART_PREFIX, TYPE_TEXT_PLAIN
 
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 getMediaType()
          Gets the media type defined in this Content-Type 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<java.lang.String,java.lang.String> getParameters()
          Gets all parameters.
 org.apache.james.mime4j.field.contenttype.parser.ParseException getParseException()
          Returns the exception that was thrown by the field parser while parsing the field value.
 java.lang.String getSubType()
          Gets the subtype defined in this Content-Type field.
 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.AbstractField
getBody, getName, getRaw, getRawField, isValidField, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.james.mime4j.dom.field.ParsedField
isValidField
 
Methods inherited from interface org.apache.james.mime4j.stream.Field
getBody, getName, getRaw
 

Field Detail

PARSER

public static final FieldParser<ContentTypeField> PARSER
Method Detail

getParseException

public org.apache.james.mime4j.field.contenttype.parser.ParseException getParseException()
Description copied from interface: ParsedField
Returns the exception that was thrown by the field parser while parsing the field value. The result is null if the field is valid and no errors were encountered.

Specified by:
getParseException in interface ParsedField
Overrides:
getParseException in class AbstractField
Returns:
the exception that was thrown by the field parser or null if the field is valid.
See Also:
ParsedField.getParseException()

getMimeType

public java.lang.String getMimeType()
Description copied from interface: ContentTypeField
Gets the MIME type defined in this Content-Type field.

Specified by:
getMimeType in interface ContentTypeField
Returns:
the MIME type or an empty string if not set.
See Also:
ContentTypeField.getMimeType()

getMediaType

public java.lang.String getMediaType()
Description copied from interface: ContentTypeField
Gets the media type defined in this Content-Type field.

Specified by:
getMediaType in interface ContentTypeField
See Also:
ContentTypeField.getMediaType()

getSubType

public java.lang.String getSubType()
Description copied from interface: ContentTypeField
Gets the subtype defined in this Content-Type field.

Specified by:
getSubType in interface ContentTypeField
See Also:
ContentTypeField.getSubType()

getParameter

public java.lang.String getParameter(java.lang.String name)
Description copied from interface: ContentTypeField
Gets the value of a parameter. Parameter names are case-insensitive.

Specified by:
getParameter in interface ContentTypeField
Parameters:
name - the name of the parameter to get.
Returns:
the parameter value or null if not set.
See Also:
ContentTypeField.getParameter(java.lang.String)

getParameters

public java.util.Map<java.lang.String,java.lang.String> getParameters()
Description copied from interface: ContentTypeField
Gets all parameters.

Specified by:
getParameters in interface ContentTypeField
Returns:
the parameters.
See Also:
ContentTypeField.getParameters()

isMimeType

public boolean isMimeType(java.lang.String mimeType)
Description copied from interface: ContentTypeField
Determines if the MIME type of this field matches the given one.

Specified by:
isMimeType in interface ContentTypeField
Parameters:
mimeType - the MIME type to match against.
Returns:
true if the MIME type of this field matches, false otherwise.
See Also:
ContentTypeField.isMimeType(java.lang.String)

isMultipart

public boolean isMultipart()
Description copied from interface: ContentTypeField
Determines if the MIME type of this field is multipart/*.

Specified by:
isMultipart in interface ContentTypeField
Returns:
true if this field is has a multipart/* MIME type, false otherwise.
See Also:
ContentTypeField.isMultipart()

getBoundary

public java.lang.String getBoundary()
Description copied from interface: ContentTypeField
Gets the value of the boundary parameter if set.

Specified by:
getBoundary in interface ContentTypeField
Returns:
the boundary parameter value or null if not set.
See Also:
ContentTypeField.getBoundary()

getCharset

public java.lang.String getCharset()
Description copied from interface: ContentTypeField
Gets the value of the charset parameter if set.

Specified by:
getCharset in interface ContentTypeField
Returns:
the charset parameter value or null if not set.
See Also:
ContentTypeField.getCharset()

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.

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.


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