source: vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/CommonUtils.java @ 1007

Last change on this file since 1007 was 1007, checked in by patdui, 13 years ago
  • added resourceType facet and added a list of resources on the show result page.
  • added i18n properties
  • fixed some olac facets supporting multiple patterns to match a facet
File size: 1.5 KB
Line 
1package eu.clarin.cmdi.vlo;
2
3import java.util.HashSet;
4import java.util.Set;
5
6public final class CommonUtils {
7
8    private final static Set<String> ANNOTATION_MIMETYPES = new HashSet<String>();
9    static {
10        ANNOTATION_MIMETYPES.add("text/x-eaf+xml");
11        ANNOTATION_MIMETYPES.add("text/x-shoebox-text");
12        ANNOTATION_MIMETYPES.add("text/x-toolbox-text");
13        ANNOTATION_MIMETYPES.add("text/x-chat");
14    }
15    private final static Set<String> TEXT_MIMETYPES = new HashSet<String>();
16    static {
17        TEXT_MIMETYPES.add("application/pdf");
18    }
19
20    private CommonUtils() {
21    }
22
23    public static String normalizeMimeType(String mimeType) {
24        String type = mimeType;
25        if (type != null) {
26            type = type.toLowerCase();
27        }
28        String result = type;
29        if (ANNOTATION_MIMETYPES.contains(type)) {
30            result = FacetConstants.RESOURCE_TYPE_ANNOTATION;
31        } else if (type.startsWith("audio")) {
32            result = FacetConstants.RESOURCE_TYPE_AUDIO;
33        } else if (type.startsWith("video")) {
34            result = FacetConstants.RESOURCE_TYPE_VIDEO;
35        } else if (type.startsWith("image")) {
36            result = FacetConstants.RESOURCE_TYPE_IMAGE;
37        } else if (type.startsWith("audio")) {
38            result = FacetConstants.RESOURCE_TYPE_AUDIO;
39        } else if (type.startsWith("text") || TEXT_MIMETYPES.contains(type)) {
40            result = FacetConstants.RESOURCE_TYPE_TEXT;
41        }
42        return result;
43    }
44
45}
Note: See TracBrowser for help on using the repository browser.