Package org.apache.tapestry5.http
Class ContentType
- java.lang.Object
- 
- org.apache.tapestry5.http.ContentType
 
- 
 public final class ContentType extends Object Represents an HTTP content type. Allows to set various elements like the MIME type, the character set, and other parameters. This is similar to a number of other implementations of the same concept in JAF, etc. We have created this simple implementation to avoid including the whole libraries. As of Tapestry 5.4, this is now an immutable data type.
- 
- 
Constructor SummaryConstructors Constructor Description ContentType(String contentType)Creates a new content type from the argument.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Returns true only if the other object is another instance of ContentType, and has the same baseType, subType and set of parameters.StringgetBaseType()StringgetCharset()StringgetMimeType()StringgetParameter(String key)List<String>getParameterNames()StringgetSubType()booleanhasParameters()StringtoString()ContentTypewithCharset(String charset)ContentTypewithParameter(String key, String value)Returns a new content type with the indicated parameter.
 
- 
- 
- 
Constructor Detail- 
ContentTypepublic ContentType(String contentType) Creates a new content type from the argument. The format of the argument has to be basetype/subtype(;key=value)*- Parameters:
- contentType- the content type that needs to be represented
 
 
- 
 - 
Method Detail- 
equalspublic boolean equals(Object o) Returns true only if the other object is another instance of ContentType, and has the same baseType, subType and set of parameters.
 - 
getBaseTypepublic String getBaseType() - Returns:
- the base type of the content type
 
 - 
getSubTypepublic String getSubType() - Returns:
- the sub-type of the content type
 
 - 
getMimeTypepublic String getMimeType() - Returns:
- the MIME type of the content type (the base type and the subtype, seperated with a '/').
 
 - 
getParameterNamespublic List<String> getParameterNames() - Returns:
- the list of names of parameters in this content type, in alphabetical order.
 
 - 
getCharsetpublic String getCharset() - Returns:
- the character set (the "charset" parameter) or null.
 
 - 
getParameterpublic String getParameter(String key) - Parameters:
- key- the name of the content type parameter
- Returns:
- the value of the content type parameter
 
 - 
withParameterpublic ContentType withParameter(String key, String value) Returns a new content type with the indicated parameter.- Since:
- 5.4
 
 - 
withCharsetpublic ContentType withCharset(String charset) 
 - 
hasParameterspublic boolean hasParameters() - Returns:
- true if the content type includes parameters (such as 'charset').
- Since:
- 5.4
 
 
- 
 
-