MimeTypes { public static String expandFormat(String format) { if (format == null || format.length() == 0) { return null; } for (int i = 0; i < FORMAT_MAPPINGS.length; i++) { if (format.equalsIgnoreCase(FORMAT_MAPPINGS[i][0]) || format.equals(FORMAT_MAPPINGS[i][1])) { return FORMAT_MAPPINGS[i][1]; } } return format.toLowerCase(); } protected  MimeTypes(); static String expandFormat(String format); static boolean isBitmapFormat(String format); static final String MIME_SVG; static final String MIME_EPS; static final String MIME_TIFF; static final String MIME_JPEG; static final String MIME_PNG; static final String MIME_GIF; static final String MIME_BMP; }
@Test public void testExpandFormat() throws Exception { assertEquals(MimeTypes.MIME_SVG, MimeTypes.expandFormat("svg")); assertEquals(MimeTypes.MIME_SVG, MimeTypes.expandFormat("sVG")); assertEquals(MimeTypes.MIME_SVG, MimeTypes.expandFormat(MimeTypes.MIME_SVG)); assertEquals(MimeTypes.MIME_EPS, MimeTypes.expandFormat("EPS")); assertEquals("image/bmp", MimeTypes.expandFormat("image/bmp")); assertEquals("anything", MimeTypes.expandFormat("anything")); assertNull(MimeTypes.expandFormat("")); assertNull(MimeTypes.expandFormat(null)); }