|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.faunos.util.io.file.ExtensionMimeMap
public class ExtensionMimeMap
A MimeMap implementation based solely on a file's extension. The actual contents of the file is not examined by this class.
Field Summary | |
---|---|
static String |
DEFAULT_PROP_FILENAME
|
Constructor Summary | |
---|---|
ExtensionMimeMap()
|
Method Summary | |
---|---|
String |
getMimeType(File file)
Returns the MIME type for the specified file, or null, if one cannot be determined. |
ExtensionMimeMap |
load(InputStream input)
Leniently loads the extension mappings from the specified property stream. |
ExtensionMimeMap |
load(InputStream input,
boolean strict)
Loads the extension mappings from the specified property stream. |
String |
mapExtension(String ext,
String mimetype)
Maps the specified extension to the given MIME type and returns the previous mapped MIME type, if any. |
static ExtensionMimeMap |
newDefaultInstance()
Returns the a new default instance. |
String |
toString()
Returns a string representation of this instance for debugging purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_PROP_FILENAME
Constructor Detail |
---|
public ExtensionMimeMap()
Method Detail |
---|
public static ExtensionMimeMap newDefaultInstance()
public String getMimeType(File file)
MimeMap
getMimeType
in interface MimeMap
public String mapExtension(String ext, String mimetype)
ext
- the filename extension. Must be 2 characters or more,
and must start with '.'mimetype
- the MIME type to be associated with the given
extension. Must not be empty.public ExtensionMimeMap load(InputStream input) throws IOException
IOException
public ExtensionMimeMap load(InputStream input, boolean strict) throws IOException
myMimeType : .ext1,.ext2,.anotherExt
This is an inverted format. The load method inverts
the mapping and generates many-to-one mappings from file
extension to MIME type.
The actual map is updated in one step after all I/O is completed.
strict
- if true, the properties file is checked for
internal consistency (no extension defined in more than
one place) and form (see mapExtension(ext, mimetype)
for specifics). Additionally,
existing mappings in this instance may not be overwritten;
o.w. (if false), existing mapping may be overwritten,
and malformed settings are skipped.
IOException
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |