@Test void testGetMimeByExtension_NoExtension() { MimeTypes mimetypes = new MimeTypes(); String contentType = mimetypes.getMimeByExtension("README"); assertNull(contentType); }
public String getMimeByExtension(String filename) { String type = null; if (filename != null) { int i = -1; while (type == null) { i = filename.indexOf(".", i + 1); if (i < 0 || i >= filename.length()) break; String ext = StringUtils.asciiToLowerCase(filename.substring(i + 1)); type = _mimeMap.get(ext); if (type == null) type = DFT_MIME_MAP.get(ext); } } if (type == null) { type = _mimeMap.get("*"); if (type == null) { type = DFT_MIME_MAP.get("*"); } } return type; }
MimeTypes { public String getMimeByExtension(String filename) { String type = null; if (filename != null) { int i = -1; while (type == null) { i = filename.indexOf(".", i + 1); if (i < 0 || i >= filename.length()) break; String ext = StringUtils.asciiToLowerCase(filename.substring(i + 1)); type = _mimeMap.get(ext); if (type == null) type = DFT_MIME_MAP.get(ext); } } if (type == null) { type = _mimeMap.get("*"); if (type == null) { type = DFT_MIME_MAP.get("*"); } } return type; } }
MimeTypes { public String getMimeByExtension(String filename) { String type = null; if (filename != null) { int i = -1; while (type == null) { i = filename.indexOf(".", i + 1); if (i < 0 || i >= filename.length()) break; String ext = StringUtils.asciiToLowerCase(filename.substring(i + 1)); type = _mimeMap.get(ext); if (type == null) type = DFT_MIME_MAP.get(ext); } } if (type == null) { type = _mimeMap.get("*"); if (type == null) { type = DFT_MIME_MAP.get("*"); } } return type; } MimeTypes(); }
MimeTypes { public String getMimeByExtension(String filename) { String type = null; if (filename != null) { int i = -1; while (type == null) { i = filename.indexOf(".", i + 1); if (i < 0 || i >= filename.length()) break; String ext = StringUtils.asciiToLowerCase(filename.substring(i + 1)); type = _mimeMap.get(ext); if (type == null) type = DFT_MIME_MAP.get(ext); } } if (type == null) { type = _mimeMap.get("*"); if (type == null) { type = DFT_MIME_MAP.get("*"); } } return type; } MimeTypes(); static String getDefaultMimeByExtension(String filename); static Set<String> getKnownMimeTypes(); static String getCharsetFromContentType(String value); static Map<String, String> getInferredEncodings(); static Map<String, String> getAssumedEncodings(); @Deprecated static String inferCharsetFromContentType(String contentType); static String getCharsetInferredFromContentType(String contentType); static String getCharsetAssumedFromContentType(String contentType); static String getContentTypeWithoutCharset(String value); static String getContentTypeMIMEType(String contentType); static List<String> getAcceptMIMETypes(String accept); static List<AcceptMIMEType> parseAcceptMIMETypes(String accept); synchronized Map<String, String> getMimeMap(); void setMimeMap(Map<String, String> mimeMap); String getMimeByExtension(String filename); void addMimeMapping(String extension, String type); }
MimeTypes { public String getMimeByExtension(String filename) { String type = null; if (filename != null) { int i = -1; while (type == null) { i = filename.indexOf(".", i + 1); if (i < 0 || i >= filename.length()) break; String ext = StringUtils.asciiToLowerCase(filename.substring(i + 1)); type = _mimeMap.get(ext); if (type == null) type = DFT_MIME_MAP.get(ext); } } if (type == null) { type = _mimeMap.get("*"); if (type == null) { type = DFT_MIME_MAP.get("*"); } } return type; } MimeTypes(); static String getDefaultMimeByExtension(String filename); static Set<String> getKnownMimeTypes(); static String getCharsetFromContentType(String value); static Map<String, String> getInferredEncodings(); static Map<String, String> getAssumedEncodings(); @Deprecated static String inferCharsetFromContentType(String contentType); static String getCharsetInferredFromContentType(String contentType); static String getCharsetAssumedFromContentType(String contentType); static String getContentTypeWithoutCharset(String value); static String getContentTypeMIMEType(String contentType); static List<String> getAcceptMIMETypes(String accept); static List<AcceptMIMEType> parseAcceptMIMETypes(String accept); synchronized Map<String, String> getMimeMap(); void setMimeMap(Map<String, String> mimeMap); String getMimeByExtension(String filename); void addMimeMapping(String extension, String type);  }