/*
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package javax.ws.rs.core;
import java.util.Collections;
import java.util.Map;
import com.gwtplatform.dispatch.rest.shared.ContentType;
public class MediaType extends ContentType {
public static final String MEDIA_TYPE_WILDCARD = "*";
public static final String WILDCARD = "*/*";
public static final MediaType WILDCARD_TYPE = new MediaType();
public static final String APPLICATION_XML = "application/xml";
public static final MediaType APPLICATION_XML_TYPE = new MediaType("application", "xml");
public static final String APPLICATION_ATOM_XML = "application/atom+xml";
public static final MediaType APPLICATION_ATOM_XML_TYPE = new MediaType("application", "atom+xml");
public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
public static final MediaType APPLICATION_XHTML_XML_TYPE = new MediaType("application", "xhtml+xml");
public static final String APPLICATION_SVG_XML = "application/svg+xml";
public static final MediaType APPLICATION_SVG_XML_TYPE = new MediaType("application", "svg+xml");
public static final String APPLICATION_JSON = "application/json";
public static final MediaType APPLICATION_JSON_TYPE = new MediaType("application", "json");
public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
public static final MediaType APPLICATION_FORM_URLENCODED_TYPE =
new MediaType("application", "x-www-form-urlencoded");
public static final String MULTIPART_FORM_DATA = "multipart/form-data";
public static final MediaType MULTIPART_FORM_DATA_TYPE = new MediaType("multipart", "form-data");
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
public static final MediaType APPLICATION_OCTET_STREAM_TYPE = new MediaType("application", "octet-stream");
public static final String TEXT_PLAIN = "text/plain";
public static final MediaType TEXT_PLAIN_TYPE = new MediaType("text", "plain");
public static final String TEXT_XML = "text/xml";
public static final MediaType TEXT_XML_TYPE = new MediaType("text", "xml");
public static final String TEXT_HTML = "text/html";
public static final MediaType TEXT_HTML_TYPE = new MediaType("text", "html");
private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
public MediaType() {
this(MEDIA_TYPE_WILDCARD, MEDIA_TYPE_WILDCARD);
}
public MediaType(String type, String subtype) {
this(type, subtype, EMPTY_MAP);
}
public MediaType(String type, String subtype, Map<String, String> parameters) {
super(type, subtype, parameters);
}
public static MediaType valueOf(String type) throws IllegalArgumentException {
ContentType contentType = ContentType.valueOf(type);
return new MediaType(contentType.getType(), contentType.getSubType(), contentType.getParameters());
}
public String getSubtype() {
return getSubType();
}
public boolean isWildcardSubtype() {
return isWildcardSubType();
}
public boolean isCompatible(MediaType other) {
return super.isCompatible(other);
}
}