@Test public void testGuessMimeType() { String expectedMimeType = "image/jpeg"; String actual = TransformUtil.guessMimeType("http: assertNotNull("01",actual); assertEquals("02",expectedMimeType, actual); }
public static String guessMimeType(String imageUrl) { String ext = StringUtil.substr(imageUrl, -4).toLowerCase(); String mimetype; if (ext.equals(".jpg")) mimetype = jpeg; else if (ext.equals(".png")) mimetype = "image/png"; else if (ext.equals(".gif")) mimetype = "image/gif"; else if (ext.equals(".tif")) mimetype = "image/tiff"; else if (ext.equals(".bmp")) mimetype = "image/bmp"; else if (ext.equals(".mp3")) mimetype = "audio/mpeg"; else if (ext.equals(".mp4")) mimetype = "video/mp4"; else if (ext.equals(".pdf")) mimetype = "application/pdf"; else { ext = StringUtil.substr(imageUrl, -5).toLowerCase(); if (ext.equals("jpeg")) mimetype = jpeg; else if (ext.equals(".tiff")) mimetype = "image/tiff"; else mimetype = jpeg; } if (logger.isDebugEnabled()) { logger.debug("Mime type guessed for " + imageUrl + ": " + mimetype); } return mimetype; }
TransformUtil { public static String guessMimeType(String imageUrl) { String ext = StringUtil.substr(imageUrl, -4).toLowerCase(); String mimetype; if (ext.equals(".jpg")) mimetype = jpeg; else if (ext.equals(".png")) mimetype = "image/png"; else if (ext.equals(".gif")) mimetype = "image/gif"; else if (ext.equals(".tif")) mimetype = "image/tiff"; else if (ext.equals(".bmp")) mimetype = "image/bmp"; else if (ext.equals(".mp3")) mimetype = "audio/mpeg"; else if (ext.equals(".mp4")) mimetype = "video/mp4"; else if (ext.equals(".pdf")) mimetype = "application/pdf"; else { ext = StringUtil.substr(imageUrl, -5).toLowerCase(); if (ext.equals("jpeg")) mimetype = jpeg; else if (ext.equals(".tiff")) mimetype = "image/tiff"; else mimetype = jpeg; } if (logger.isDebugEnabled()) { logger.debug("Mime type guessed for " + imageUrl + ": " + mimetype); } return mimetype; } }
TransformUtil { public static String guessMimeType(String imageUrl) { String ext = StringUtil.substr(imageUrl, -4).toLowerCase(); String mimetype; if (ext.equals(".jpg")) mimetype = jpeg; else if (ext.equals(".png")) mimetype = "image/png"; else if (ext.equals(".gif")) mimetype = "image/gif"; else if (ext.equals(".tif")) mimetype = "image/tiff"; else if (ext.equals(".bmp")) mimetype = "image/bmp"; else if (ext.equals(".mp3")) mimetype = "audio/mpeg"; else if (ext.equals(".mp4")) mimetype = "video/mp4"; else if (ext.equals(".pdf")) mimetype = "application/pdf"; else { ext = StringUtil.substr(imageUrl, -5).toLowerCase(); if (ext.equals("jpeg")) mimetype = jpeg; else if (ext.equals(".tiff")) mimetype = "image/tiff"; else mimetype = jpeg; } if (logger.isDebugEnabled()) { logger.debug("Mime type guessed for " + imageUrl + ": " + mimetype); } return mimetype; }  }
TransformUtil { public static String guessMimeType(String imageUrl) { String ext = StringUtil.substr(imageUrl, -4).toLowerCase(); String mimetype; if (ext.equals(".jpg")) mimetype = jpeg; else if (ext.equals(".png")) mimetype = "image/png"; else if (ext.equals(".gif")) mimetype = "image/gif"; else if (ext.equals(".tif")) mimetype = "image/tiff"; else if (ext.equals(".bmp")) mimetype = "image/bmp"; else if (ext.equals(".mp3")) mimetype = "audio/mpeg"; else if (ext.equals(".mp4")) mimetype = "video/mp4"; else if (ext.equals(".pdf")) mimetype = "application/pdf"; else { ext = StringUtil.substr(imageUrl, -5).toLowerCase(); if (ext.equals("jpeg")) mimetype = jpeg; else if (ext.equals(".tiff")) mimetype = "image/tiff"; else mimetype = jpeg; } if (logger.isDebugEnabled()) { logger.debug("Mime type guessed for " + imageUrl + ": " + mimetype); } return mimetype; }  static void setScientificNameGroup(ScientificName sn); static DefaultClassification extractClassificiationFromName(ScientificName sn); static List<Monomial> getMonomialsInName(ScientificName sn); static ScientificName extractNameFromClassification(DefaultClassification dc); static void equalizeNameComponents(Taxon taxon); static void equalizeNameComponents(Specimen specimen); static void equalizeNameComponents(MultiMediaObject mmo); static void sortIdentificationsPreferredFirst(Specimen specimen); static List<Monomial> getSystemClassification(Element elem, ScientificName sn); static String guessMimeType(String imageUrl); }
TransformUtil { public static String guessMimeType(String imageUrl) { String ext = StringUtil.substr(imageUrl, -4).toLowerCase(); String mimetype; if (ext.equals(".jpg")) mimetype = jpeg; else if (ext.equals(".png")) mimetype = "image/png"; else if (ext.equals(".gif")) mimetype = "image/gif"; else if (ext.equals(".tif")) mimetype = "image/tiff"; else if (ext.equals(".bmp")) mimetype = "image/bmp"; else if (ext.equals(".mp3")) mimetype = "audio/mpeg"; else if (ext.equals(".mp4")) mimetype = "video/mp4"; else if (ext.equals(".pdf")) mimetype = "application/pdf"; else { ext = StringUtil.substr(imageUrl, -5).toLowerCase(); if (ext.equals("jpeg")) mimetype = jpeg; else if (ext.equals(".tiff")) mimetype = "image/tiff"; else mimetype = jpeg; } if (logger.isDebugEnabled()) { logger.debug("Mime type guessed for " + imageUrl + ": " + mimetype); } return mimetype; }  static void setScientificNameGroup(ScientificName sn); static DefaultClassification extractClassificiationFromName(ScientificName sn); static List<Monomial> getMonomialsInName(ScientificName sn); static ScientificName extractNameFromClassification(DefaultClassification dc); static void equalizeNameComponents(Taxon taxon); static void equalizeNameComponents(Specimen specimen); static void equalizeNameComponents(MultiMediaObject mmo); static void sortIdentificationsPreferredFirst(Specimen specimen); static List<Monomial> getSystemClassification(Element elem, ScientificName sn); static String guessMimeType(String imageUrl);  }