MimeType.java :  » GWT » gwt-s3 » com » nubotech » gwt » oss » client » util » Java Open Source

Java Open Source » GWT » gwt s3 
gwt s3 » com » nubotech » gwt » oss » client » util » MimeType.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nubotech.gwt.oss.client.util;

/**
 *
 * @author jonnakkerud
 */
public enum MimeType {
    application_oda("application/oda","oda"),    
    application_pdf("application/pdf","pdf"),
    application_postscript("application/postscript","eps,ai,ps"),    
    application_x_dvi("application/x-dvi","dvi"),
    application_zip("application/zip","zip"),
    application_x_tar("application/x-tar","tar"),
    text_html("text/html", "htm,html"),
    text_plain("text/plain", "text,c,cc,c++,h,pl,txt,java,el"),
    text_tab_separated_values("text/tab-separated-values", "tsv"),
    application_xml("application/xml", "xml");
       
    private final String type;
    private final String fileExtensions;
    MimeType(String type, String fileExtensions) {
        this.type = type;
        this.fileExtensions = fileExtensions;
    }
    
    private String type() {
        return this.type;
    }
    
    private String extensions() {
        return this.fileExtensions;
    }
    
    public static String lookup(String extension) {
        String result = null;
        for (MimeType m : MimeType.values()) {
            String ext = m.extensions();
            if (ext.indexOf(extension) > -1) {
                result = m.type();
                break;
            }
        }
        
        return result;
    }
    
    
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.