Package ch.raffael.meldioc.library.codec
Class ContentTypes
- java.lang.Object
-
- ch.raffael.meldioc.library.codec.ContentTypes
-
public final class ContentTypes extends java.lang.ObjectUtilities for dealing with content types.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCHARSET_ATTRstatic ch.raffael.meldioc.library.codec.ContentTypeHTMLstatic io.vavr.collection.Set<java.nio.charset.Charset>IMPLIED_UNICODE_CHARSETSstatic ch.raffael.meldioc.library.codec.ContentTypeJSONstatic ch.raffael.meldioc.library.codec.ContentTypePLAIN_TEXTstatic java.lang.StringQ_ATTRstatic ch.raffael.meldioc.library.codec.ContentTypeXHTMLstatic ch.raffael.meldioc.library.codec.ContentTypeXML
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.nio.charset.CharsetdetectUnicodeCharset(byte[] bytes)static java.nio.charset.CharsetdetectUnicodeCharset(int b0, int b1)static booleanisImpliedUnicodeCharset(java.nio.charset.Charset charset)static booleanisJson(ch.raffael.meldioc.library.codec.ContentType contentType)static booleanisUnicodeType(ch.raffael.meldioc.library.codec.ContentType contentType)static booleanisXml(ch.raffael.meldioc.library.codec.ContentType contentType)static io.vavr.control.Option<ch.raffael.meldioc.library.codec.ContentType>parseContentType(java.lang.String contentTypeString)Parses a content type as of RFC 2045.static io.vavr.collection.Seq<ch.raffael.meldioc.library.codec.ContentType>parseContentTypeList(java.lang.String contentTypeString)Parses a list of content types separated with ',' (HTTP Accept header) disregarding 'q=';static io.vavr.collection.Seq<ch.raffael.meldioc.library.codec.ContentType>parseContentTypeListQ(java.lang.String contentTypeString)Parses a list of content types separated with ',' (HTTP Accept header) and sorts the result by 'q='.
-
-
-
Field Detail
-
CHARSET_ATTR
public static final java.lang.String CHARSET_ATTR
- See Also:
- Constant Field Values
-
Q_ATTR
public static final java.lang.String Q_ATTR
- See Also:
- Constant Field Values
-
XML
public static final ch.raffael.meldioc.library.codec.ContentType XML
-
JSON
public static final ch.raffael.meldioc.library.codec.ContentType JSON
-
HTML
public static final ch.raffael.meldioc.library.codec.ContentType HTML
-
XHTML
public static final ch.raffael.meldioc.library.codec.ContentType XHTML
-
PLAIN_TEXT
public static final ch.raffael.meldioc.library.codec.ContentType PLAIN_TEXT
-
IMPLIED_UNICODE_CHARSETS
public static final io.vavr.collection.Set<java.nio.charset.Charset> IMPLIED_UNICODE_CHARSETS
-
-
Method Detail
-
isUnicodeType
public static boolean isUnicodeType(ch.raffael.meldioc.library.codec.ContentType contentType)
-
isXml
public static boolean isXml(ch.raffael.meldioc.library.codec.ContentType contentType)
-
isJson
public static boolean isJson(ch.raffael.meldioc.library.codec.ContentType contentType)
-
detectUnicodeCharset
public static java.nio.charset.Charset detectUnicodeCharset(byte[] bytes)
-
detectUnicodeCharset
public static java.nio.charset.Charset detectUnicodeCharset(int b0, int b1)
-
isImpliedUnicodeCharset
public static boolean isImpliedUnicodeCharset(java.nio.charset.Charset charset)
-
parseContentType
public static io.vavr.control.Option<ch.raffael.meldioc.library.codec.ContentType> parseContentType(java.lang.String contentTypeString)
Parses a content type as of RFC 2045. The parser is lenient, i.e. it tries to parse as much as possible and returns what could be parsed. It doesn't throw any exceptions on errors.
-
parseContentTypeList
public static io.vavr.collection.Seq<ch.raffael.meldioc.library.codec.ContentType> parseContentTypeList(java.lang.String contentTypeString)
Parses a list of content types separated with ',' (HTTP Accept header) disregarding 'q=';
-
parseContentTypeListQ
public static io.vavr.collection.Seq<ch.raffael.meldioc.library.codec.ContentType> parseContentTypeListQ(java.lang.String contentTypeString)
Parses a list of content types separated with ',' (HTTP Accept header) and sorts the result by 'q='.
-
-