接口/枚举列出标准哑剧类型常量

2022-08-31 07:26:54

我正在标准库(如apache commons,jax,jboss,javax)中寻找列出所有标准mime类型(又名内容类型)值的接口或枚举。

这个接口不应该被其他类所束缚得太深,这将使整个类难以包含整个gwt源代码。

例如

interface ContentType{
  String JSON = "Application/JSON";
  blah ... blah ...
}

enum ContentType{
  JSON("Application/JSON"),
  blah ... blah ...
}

答案 1

https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/MediaType.html

staticjava.lang.String APPLICATION_ATOM_XML             "application/atom+xml"
staticMediaType        APPLICATION_ATOM_XML_TYPE        "application/atom+xml"
staticjava.lang.String APPLICATION_FORM_URLENCODED      "application/x-www-form-urlencoded"
staticMediaType        APPLICATION_FORM_URLENCODED_TYPE "application/x-www-form-urlencoded"
staticjava.lang.String APPLICATION_JSON                 "application/json"
staticMediaType        APPLICATION_JSON_TYPE            "application/json"
staticjava.lang.String APPLICATION_OCTET_STREAM         "application/octet-stream"
staticMediaType        APPLICATION_OCTET_STREAM_TYPE    "application/octet-stream"
staticjava.lang.String APPLICATION_SVG_XML              "application/svg+xml"
staticMediaType        APPLICATION_SVG_XML_TYPE         "application/svg+xml"
staticjava.lang.String APPLICATION_XHTML_XML            "application/xhtml+xml"
staticMediaType        APPLICATION_XHTML_XML_TYPE       "application/xhtml+xml"
staticjava.lang.String APPLICATION_XML                  "application/xml"
staticMediaType        APPLICATION_XML_TYPE             "application/xml"
staticjava.lang.String MEDIA_TYPE_WILDCARD              The value of a type or subtype wildcard: "*"
staticjava.lang.String MULTIPART_FORM_DATA              "multipart/form-data"
staticMediaType        MULTIPART_FORM_DATA_TYPE         "multipart/form-data"
staticjava.lang.String TEXT_HTML                        "text/html"
staticMediaType        TEXT_HTML_TYPE                   "text/html"
staticjava.lang.String TEXT_PLAIN                       "text/plain"
staticMediaType        TEXT_PLAIN_TYPE                  "text/plain"
staticjava.lang.String TEXT_XML                         "text/xml"
staticMediaType        TEXT_XML_TYPE                    "text/xml"
staticjava.lang.String WILDCARD                         "*/*"
staticMediaType        WILDCARD_TYPE                    "*/*"

答案 2

如果您使用的是Spring Framework,那么有一个用于常见内容类型的MediaType类:

MediaType.TEXT_HTML 
MediaType.TEXT_PLAIN 
MediaType.TEXT_XML 
MediaType.APPLICATION_JSON 
MediaType.IMAGE_JPEG 
...

推荐