public class DefaultMIMETypes
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_MIME_TYPE
Default MIME type - what to set it to if we don't know any better
|
Constructor and Description |
---|
DefaultMIMETypes() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addMIMEType(short number,
java.lang.String type)
Add a MIME type, without any extensions.
|
protected static void |
addMIMEType(short number,
java.lang.String type,
java.lang.String extensions)
Add a MIME type, with extensions separated by spaces.
|
protected static void |
addMIMEType(short number,
java.lang.String type,
java.lang.String[] extensions,
java.lang.String outExtension)
Add a MIME type.
|
protected static void |
addMIMEType(short number,
java.lang.String type,
java.lang.String extensions,
java.lang.String outExtension)
Add a MIME type, with extensions separated by spaces.
|
static short |
byName(java.lang.String s)
Get the number of a MIME type, or -1 if it is not in the table of known MIME
types, in which case it will have to be sent uncompressed.
|
static java.lang.String |
byNumber(short x)
Get a known MIME type by number.
|
static java.lang.String |
forceExtension(java.lang.String s,
java.lang.String expectedMimeType)
Make sure the filename has the correct extension for the MIME type
|
static java.lang.String |
getExtension(java.lang.String type) |
static java.lang.String |
guessMIMEType(java.lang.String arg,
boolean noDefault)
Guess a MIME type from a filename.
|
static boolean |
isPlausibleMIMEType(java.lang.String mimeType) |
static boolean |
isValidExt(MediaType parsedType,
java.lang.String forceCompatibleExtension) |
static boolean |
isValidExt(java.lang.String expectedMimeType,
java.lang.String oldExt) |
public static final java.lang.String DEFAULT_MIME_TYPE
protected static void addMIMEType(short number, java.lang.String type)
number
- The number of the MIME type for compression. This *must not change*
for a given type, or the metadata format will be affected.type
- The actual MIME type string. Do not include ;charset= etc; these are
parameters and there is a separate mechanism for them.protected static void addMIMEType(short number, java.lang.String type, java.lang.String[] extensions, java.lang.String outExtension)
number
- The number of the MIME type for compression. This *must not change*
for a given type, or the metadata format will be affected.type
- The actual MIME type string. Do not include ;charset= etc; these are
parameters and there is a separate mechanism for them.extensions
- An array of common extensions for files of this type. Must be
unique for the type.protected static void addMIMEType(short number, java.lang.String type, java.lang.String extensions)
protected static void addMIMEType(short number, java.lang.String type, java.lang.String extensions, java.lang.String outExtension)
public static java.lang.String byNumber(short x)
public static short byName(java.lang.String s)
public static java.lang.String guessMIMEType(java.lang.String arg, boolean noDefault)
noDefault
- If true, no default MIME type; return null if not recognized.
Otherwise if we don't recognize the extension we return DEFAULT_MIME_TYPE.public static java.lang.String getExtension(java.lang.String type)
public static boolean isValidExt(java.lang.String expectedMimeType, java.lang.String oldExt)
public static boolean isValidExt(MediaType parsedType, java.lang.String forceCompatibleExtension)
public static boolean isPlausibleMIMEType(java.lang.String mimeType)
public static java.lang.String forceExtension(java.lang.String s, java.lang.String expectedMimeType)