1 package org
.argeo
.app
.api
;
3 import java
.nio
.charset
.Charset
;
4 import java
.nio
.charset
.StandardCharsets
;
6 /** Supported mime types. */
7 public enum EntityMimeType
{
8 XML("text/xml", "xml"), CSV("text/csv", "csv");
10 private final String mimeType
;
11 private final String
[] extensions
;
13 EntityMimeType(String mimeType
, String
... extensions
) {
14 this.mimeType
= mimeType
;
15 this.extensions
= extensions
;
18 public String
getMimeType() {
22 public String
[] getExtensions() {
26 public String
getDefaultExtension() {
27 if (extensions
.length
> 0)
33 public String
toHttpContentType(Charset charset
) {
36 return mimeType
+ "; charset=" + charset
.name();
39 public String
toHttpContentType() {
40 if (mimeType
.startsWith("text/")) {
41 return toHttpContentType(StandardCharsets
.UTF_8
);
47 public static EntityMimeType
find(String mimeType
) {
48 for (EntityMimeType entityMimeType
: values()) {
49 if (entityMimeType
.mimeType
.equals(mimeType
))
50 return entityMimeType
;
56 public String
toString() {