|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.mime.MimeTypeMapper
public class MimeTypeMapper
MimeTypeMapper defines mappings between MIME types and the corresponding file name extensions. The mappings are defined as lines formed by a MIME type name followed by a list of extensions separated by a whitespace.
Constructor Summary | |
---|---|
MimeTypeMapper()
Constructs an empty MIME type mapper. |
|
MimeTypeMapper(File file)
Constructs a mapper reading from a file. |
|
MimeTypeMapper(InputStream input)
Constructs a mapper reading from a stream. |
|
MimeTypeMapper(String path)
Constructs a mapper reading from a file path. |
Method Summary | |
---|---|
String |
getExtension(String type)
Gets a file name extension corresponding to a specified MIME type. |
protected String[] |
getExtensions(String type)
Gets all file name extensions corresponding to a specified MIME type. |
MimeType |
getMimeType(String ext)
Gets a MIME type corresponding to a specified file name extension. |
protected MimeType[] |
getMimeTypes(String ext)
Gets all MIME types corresponding to a specified file name extension. |
protected void |
parse(BufferedReader reader,
boolean replace)
Parses MIME type extensions. |
protected int |
parseMimeTypeExtension(String spec,
Map<String,MimeType[]> mimeTypes,
Map<String,String[]> extensions,
boolean replace)
Parses a MIME type extension. |
void |
setContentType(String spec)
Sets a MIME content type mapping to extensions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MimeTypeMapper()
public MimeTypeMapper(InputStream input) throws IOException
input
- an input stream.
IOException
- for an incorrect stream.public MimeTypeMapper(File file) throws IOException
file
- an input file.
IOException
- for an incorrect file.public MimeTypeMapper(String path) throws IOException
path
- an input file path.
IOException
- for an incorrect file.Method Detail |
---|
public MimeType getMimeType(String ext)
ext
- a file name extension.
public String getExtension(String type)
type
- the MIME type.
public void setContentType(String spec)
spec
- a MIME type extension specification to parse.protected MimeType[] getMimeTypes(String ext)
Note that the internal array of the mapper is returned.
ext
- a file name extension.
protected String[] getExtensions(String type)
Note that the internal array of the mapper is returned.
type
- a MIME type string.
protected void parse(BufferedReader reader, boolean replace) throws IOException
reader
- a reader to parse.replace
- a flag to replace.
IOException
- for an incorrect reader.protected int parseMimeTypeExtension(String spec, Map<String,MimeType[]> mimeTypes, Map<String,String[]> extensions, boolean replace)
spec
- an extension specification to parse.mimeTypes
- a map of MIME types.extensions
- a map of extensions.replace
- a flag to replace.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |