|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fulcrum.mimetype.util.MimeTypeMapper
public class MimeTypeMapper
This class 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.
Field Summary | |
---|---|
protected HashMap |
extensionMimeTypes
|
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 |
getContentType(String ext)
Gets a MIME content type corresponding to a specified file name extension. |
String |
getExtension(String type)
Gets a file name extension corresponding to a specified MIME content type. |
protected void |
parse(BufferedReader reader)
Parses MIME type extensions. |
protected int |
parseMimeTypeExtension(String spec,
Map mimeTypes,
Map extensions)
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 |
Field Detail |
---|
protected HashMap extensionMimeTypes
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 void setContentType(String spec)
spec
- a MIME type extension specification to parse.public String getContentType(String ext)
ext
- The file name extension to resolve.
null
if not found.public String getExtension(String type)
type
- a MIME type as a string.
protected void parse(BufferedReader reader) throws IOException
reader
- a reader to parse.
IOException
- for an incorrect reader.protected int parseMimeTypeExtension(String spec, Map mimeTypes, Map extensions)
spec
- an extension specification to parse.mimeTypes
- a map of MIME types.extensions
- a map of extensions.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |