private static String getContentType(String format) { final String ctype = ContentTypes.getContentType(format); return ctype != null ? ctype: "image/" + format; } private static String getFormatByName(String name) {
private static String getContentType(String format) { final String ctype = ContentTypes.getContentType(format); return ctype != null ? ctype: "audio/" + format; } private static String getFormatByName(String name) {
private static String getContentType(String format) { final String ctype = ContentTypes.getContentType(format); return ctype != null ? ctype : "video/" + format; }
/** Sets up the format and content type. * It assumes one of them is not null. */ private void setup(String name, String format, String ctype) { if (ctype != null) { int j = ctype.indexOf(';'); if (j >= 0) ctype = ctype.substring(0, j); } if (ctype != null && format == null) { format = ContentTypes.getFormat(ctype); } else if (ctype == null && format != null) { ctype = ContentTypes.getContentType(format); } if (name != null) { if (format == null) { final int j = name.lastIndexOf('.'); if (j >= 0) { format = name.substring(j + 1); if (ctype == null) { ctype = ContentTypes.getContentType(format); } } } } _name = name; _format = format; _ctype = ctype; }
/** Returns the content type by specifying a path, or null * if no content type is available or path is null. * * <p>It determines the content type by looking the extension. * Note: it considers the extension of "a.css.dsp" as "css". */ public static final String getContentType(String path) { if (path == null) return null; int j = path.lastIndexOf('.'); if (j < 0 || path.indexOf('/', j + 1) >= 0) return null; int k = path.indexOf(';', j + 1); //it might contain session-id String ext = (k >= 0 ? path.substring(j + 1, k) : path.substring(j + 1)).toLowerCase(java.util.Locale.ENGLISH); if ("dsp".equals(ext)) { if (j == 0) return null; //unknown k = path.lastIndexOf('.', j - 1); if (k < 0) return null; //unknown ext = path.substring(k + 1, j); if (ext.indexOf('/') >= 0) return null; //unknown } return ContentTypes.getContentType(ext); }
String ctype = ContentTypes.getContentType(ext); if (ctype == null) { ctype = ";charset=UTF-8";
final int j = name.lastIndexOf('.'); if (j >= 0) { String s = ContentTypes.getContentType(name.substring(j + 1)); if (s != null) ctypelc = ctype = s;
final int j = name.lastIndexOf('.'); if (j >= 0) { String s = ContentTypes.getContentType(name.substring(j + 1)); if (s != null) ctypelc = ctype = s;