Package org.restlet.engine.header
Class ContentType
- java.lang.Object
-
- org.restlet.engine.header.ContentType
-
public class ContentType extends java.lang.ObjectAssociation of a media type, a character set and modifiers.
-
-
Field Summary
Fields Modifier and Type Field Description private CharacterSetcharacterSetThe content character set.private MediaTypemediaTypeThe content media type.
-
Constructor Summary
Constructors Constructor Description ContentType(java.lang.String headerValue)Constructor.ContentType(MediaType mediaType, CharacterSet characterSet)Constructor.ContentType(Representation representation)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CharacterSetgetCharacterSet()Returns the character set.MediaTypegetMediaType()Returns the media type.static CharacterSetreadCharacterSet(java.lang.String contentType)Parses the given content type header and returns the character set.static MediaTypereadMediaType(java.lang.String contentType)Parses the given content type header and returns the media type.java.lang.StringtoString()static java.lang.StringwriteHeader(MediaType mediaType, CharacterSet characterSet)Writes the HTTP "Content-Type" header.static java.lang.StringwriteHeader(Representation representation)Writes the HTTP "Content-Type" header.
-
-
-
Field Detail
-
characterSet
private volatile CharacterSet characterSet
The content character set.
-
mediaType
private volatile MediaType mediaType
The content media type.
-
-
Constructor Detail
-
ContentType
public ContentType(MediaType mediaType, CharacterSet characterSet)
Constructor.- Parameters:
mediaType- The media type.characterSet- The character set.
-
ContentType
public ContentType(Representation representation)
Constructor.- Parameters:
representation- The representation.
-
ContentType
public ContentType(java.lang.String headerValue)
Constructor.- Parameters:
headerValue- The "Content-type" header to parse.
-
-
Method Detail
-
readCharacterSet
public static CharacterSet readCharacterSet(java.lang.String contentType)
Parses the given content type header and returns the character set.- Parameters:
contentType- The content type header to parse.- Returns:
- The character set.
-
readMediaType
public static MediaType readMediaType(java.lang.String contentType)
Parses the given content type header and returns the media type.- Parameters:
contentType- The content type header to parse.- Returns:
- The media type.
-
writeHeader
public static java.lang.String writeHeader(MediaType mediaType, CharacterSet characterSet)
Writes the HTTP "Content-Type" header.- Parameters:
mediaType- The representation media type.characterSet- The representation character set.- Returns:
- The HTTP "Content-Type" header.
-
writeHeader
public static java.lang.String writeHeader(Representation representation)
Writes the HTTP "Content-Type" header.- Parameters:
representation- The related representation.- Returns:
- The HTTP "Content-Type" header.
-
getCharacterSet
public CharacterSet getCharacterSet()
Returns the character set.- Returns:
- The character set.
-
getMediaType
public MediaType getMediaType()
Returns the media type.- Returns:
- The media type.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-