org.basex.io
Class MimeTypes

java.lang.Object
  extended by org.basex.io.MimeTypes

public final class MimeTypes
extends java.lang.Object

This class returns the mime types of a file, which is either dynamically determined by Java, or statically resolved by requesting the mappings in the mime.txt project file.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
static java.lang.String APP_FORM_URLENCODED
          Media type: application/x-www-form-urlencoded.
static java.lang.String APP_HTML_XML
          Media type: application/html+xml.
static java.lang.String APP_JSON
          Media type: application/json.
static java.lang.String APP_JSONML
          Media type: application/jsonml+json.
static java.lang.String APP_OCTET
          Media type: text/plain.
static java.lang.String APP_XML
          Media type: application/xml.
static java.lang.String APP_XML_EXTERNAL
          Media type: application/xml-external-parsed-entity.
static java.lang.String CONTENT_TYPE
          Content-Type.
static java.lang.String MULTIPART
          Multipart type.
static java.lang.String MULTIPART_FORM_DATA
          Media type: multipart/form-data.
static java.lang.String TEXT
          Text type.
static java.lang.String TEXT_CSV
          Media type: text/comma-separated-values.
static java.lang.String TEXT_HTML
          Media type: text/html.
static java.lang.String TEXT_PLAIN
          Media type: text/plain.
static java.lang.String TEXT_XML
          Media type: text/xml.
static java.lang.String TEXT_XML_EXT
          XML media type.
static java.lang.String XML_SUFFIX
          XML media types' suffix.
 
Method Summary
static java.lang.String get(java.lang.String path)
          Returns the mime type for the suffix of the specified file path.
static boolean isMultipart(java.lang.String type)
          Checks if the content type is a multipart content type.
static boolean isText(java.lang.String type)
          Checks if the main part of the content type is "text".
static boolean isXML(java.lang.String type)
          Checks if the content type is an XML content type.
static boolean matches(java.lang.String type, java.lang.String pattern)
          Checks if a content type is accepted by the specified pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
Content-Type.

See Also:
Constant Field Values

TEXT

public static final java.lang.String TEXT
Text type.

See Also:
Constant Field Values

MULTIPART

public static final java.lang.String MULTIPART
Multipart type.

See Also:
Constant Field Values

MULTIPART_FORM_DATA

public static final java.lang.String MULTIPART_FORM_DATA
Media type: multipart/form-data.

See Also:
Constant Field Values

APP_HTML_XML

public static final java.lang.String APP_HTML_XML
Media type: application/html+xml.

See Also:
Constant Field Values

APP_JSON

public static final java.lang.String APP_JSON
Media type: application/json.

See Also:
Constant Field Values

APP_JSONML

public static final java.lang.String APP_JSONML
Media type: application/jsonml+json.

See Also:
Constant Field Values

APP_OCTET

public static final java.lang.String APP_OCTET
Media type: text/plain.

See Also:
Constant Field Values

APP_XML

public static final java.lang.String APP_XML
Media type: application/xml.

See Also:
Constant Field Values

APP_XML_EXTERNAL

public static final java.lang.String APP_XML_EXTERNAL
Media type: application/xml-external-parsed-entity.

See Also:
Constant Field Values

APP_FORM_URLENCODED

public static final java.lang.String APP_FORM_URLENCODED
Media type: application/x-www-form-urlencoded.

See Also:
Constant Field Values

TEXT_CSV

public static final java.lang.String TEXT_CSV
Media type: text/comma-separated-values.

See Also:
Constant Field Values

TEXT_HTML

public static final java.lang.String TEXT_HTML
Media type: text/html.

See Also:
Constant Field Values

TEXT_PLAIN

public static final java.lang.String TEXT_PLAIN
Media type: text/plain.

See Also:
Constant Field Values

TEXT_XML

public static final java.lang.String TEXT_XML
Media type: text/xml.

See Also:
Constant Field Values

TEXT_XML_EXT

public static final java.lang.String TEXT_XML_EXT
XML media type.

See Also:
Constant Field Values

XML_SUFFIX

public static final java.lang.String XML_SUFFIX
XML media types' suffix.

See Also:
Constant Field Values
Method Detail

get

public static java.lang.String get(java.lang.String path)
Returns the mime type for the suffix of the specified file path. application/octet-stream is returned if no type is found.

Parameters:
path - path to be checked
Returns:
mime-type

isXML

public static boolean isXML(java.lang.String type)
Checks if the content type is an XML content type.

Parameters:
type - content type
Returns:
result of check

isText

public static boolean isText(java.lang.String type)
Checks if the main part of the content type is "text".

Parameters:
type - content type
Returns:
result of check

isMultipart

public static boolean isMultipart(java.lang.String type)
Checks if the content type is a multipart content type.

Parameters:
type - content type
Returns:
result of check

matches

public static boolean matches(java.lang.String type,
                              java.lang.String pattern)
Checks if a content type is accepted by the specified pattern.

Parameters:
type - content type
pattern - pattern
Returns:
result of check