Package org.apache.james.mime4j.field
Class ContentTypeFieldImpl
- java.lang.Object
-
- org.apache.james.mime4j.field.AbstractField
-
- org.apache.james.mime4j.field.ContentTypeFieldImpl
-
- All Implemented Interfaces:
ContentTypeField,ParsedField,Field
public class ContentTypeFieldImpl extends AbstractField implements ContentTypeField
Represents aContent-Typefield.
-
-
Field Summary
Fields Modifier and Type Field Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetBoundary()Gets the value of theboundaryparameter if set.StringgetCharset()Gets the value of thecharsetparameter if set.static StringgetCharset(ContentTypeField f)Gets the value of thecharsetparameter if set for the given field.StringgetMediaType()Gets the media type defined in this Content-Type field.StringgetMimeType()Gets the MIME type defined in this Content-Type field.static StringgetMimeType(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 isnullor hasn't got a MIME type value set.StringgetParameter(String name)Gets the value of a parameter.Map<String,String>getParameters()Gets all parameters.ParseExceptiongetParseException()Returns the exception that was thrown by the field parser while parsing the field value.StringgetSubType()Gets the subtype defined in this Content-Type field.booleanisMimeType(String mimeType)Determines if the MIME type of this field matches the given one.booleanisMultipart()Determines if the MIME type of this field ismultipart/*.-
Methods inherited from class org.apache.james.mime4j.field.AbstractField
getBody, getName, getNameLowerCase, 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.stream.Field
getBody, getName, getNameLowerCase, getRaw
-
Methods inherited from interface org.apache.james.mime4j.dom.field.ParsedField
isValidField
-
-
-
-
Field Detail
-
PARSER
public static final FieldParser<ContentTypeField> PARSER
-
-
Method Detail
-
getParseException
public ParseException getParseException()
Description copied from interface:ParsedFieldReturns the exception that was thrown by the field parser while parsing the field value. The result isnullif the field is valid and no errors were encountered.- Specified by:
getParseExceptionin interfaceParsedField- Overrides:
getParseExceptionin classAbstractField- Returns:
- the exception that was thrown by the field parser or
nullif the field is valid. - See Also:
ParsedField.getParseException()
-
getMimeType
public String getMimeType()
Description copied from interface:ContentTypeFieldGets the MIME type defined in this Content-Type field.- Specified by:
getMimeTypein interfaceContentTypeField- Returns:
- the MIME type or an empty string if not set.
- See Also:
ContentTypeField.getMimeType()
-
getMediaType
public String getMediaType()
Description copied from interface:ContentTypeFieldGets the media type defined in this Content-Type field.- Specified by:
getMediaTypein interfaceContentTypeField- See Also:
ContentTypeField.getMediaType()
-
getSubType
public String getSubType()
Description copied from interface:ContentTypeFieldGets the subtype defined in this Content-Type field.- Specified by:
getSubTypein interfaceContentTypeField- See Also:
ContentTypeField.getSubType()
-
getParameter
public String getParameter(String name)
Description copied from interface:ContentTypeFieldGets the value of a parameter. Parameter names are case-insensitive.- Specified by:
getParameterin interfaceContentTypeField- Parameters:
name- the name of the parameter to get.- Returns:
- the parameter value or
nullif not set. - See Also:
ContentTypeField.getParameter(java.lang.String)
-
getParameters
public Map<String,String> getParameters()
Description copied from interface:ContentTypeFieldGets all parameters.- Specified by:
getParametersin interfaceContentTypeField- Returns:
- the parameters.
- See Also:
ContentTypeField.getParameters()
-
isMimeType
public boolean isMimeType(String mimeType)
Description copied from interface:ContentTypeFieldDetermines if the MIME type of this field matches the given one.- Specified by:
isMimeTypein interfaceContentTypeField- Parameters:
mimeType- the MIME type to match against.- Returns:
trueif the MIME type of this field matches,falseotherwise.- See Also:
ContentTypeField.isMimeType(java.lang.String)
-
isMultipart
public boolean isMultipart()
Description copied from interface:ContentTypeFieldDetermines if the MIME type of this field ismultipart/*.- Specified by:
isMultipartin interfaceContentTypeField- Returns:
trueif this field is has amultipart/*MIME type,falseotherwise.- See Also:
ContentTypeField.isMultipart()
-
getBoundary
public String getBoundary()
Description copied from interface:ContentTypeFieldGets the value of theboundaryparameter if set.- Specified by:
getBoundaryin interfaceContentTypeField- Returns:
- the
boundaryparameter value ornullif not set. - See Also:
ContentTypeField.getBoundary()
-
getCharset
public String getCharset()
Description copied from interface:ContentTypeFieldGets the value of thecharsetparameter if set.- Specified by:
getCharsetin interfaceContentTypeField- Returns:
- the
charsetparameter value ornullif not set. - See Also:
ContentTypeField.getCharset()
-
getMimeType
public static 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 isnullor 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 String getCharset(ContentTypeField f)
Gets the value of thecharsetparameter if set for the given field. Returns the defaultus-asciiif not set or iffisnull.- Returns:
- the
charsetparameter value.
-
-