Ejemplo n.º 1
0
 /**
  * Get the extension for the specified mimetype
  *
  * @param mimetype a valid mimetype
  * @return Returns the default extension for the mimetype, or null if the mimetype is unknown
  */
 public String getExtension(String mimetype) {
   Mimetype mt = getMimetypes().get(mimetype);
   if (mt != null) {
     return mt.getDefaultExtension();
   }
   return null;
 }
Ejemplo n.º 2
0
  /**
   * Get all human readable mimetype descriptions, indexed by mimetype
   *
   * @return the map of displays indexed by mimetype
   */
  public Map<String, String> getDisplaysByMimetype() {
    Map<String, String> descriptions = new HashMap<String, String>();
    Map<String, Mimetype> mimetypes = getMimetypes();

    for (Mimetype mimetype : mimetypes.values()) {
      descriptions.put(mimetype.getMimetype(), mimetype.getDescription());
    }

    return descriptions;
  }
Ejemplo n.º 3
0
  /** Gets all the human readable mimetype descriptions, sorted, along with their mimetypes. */
  public Map<String, String> getMimetypesByDisplay() {
    // Sorted by key, case insensitive
    Map<String, String> types =
        new TreeMap<String, String>(
            new Comparator<String>() {
              @Override
              public int compare(String o1, String o2) {
                return o1.toLowerCase().compareTo(o2.toLowerCase());
              }
            });

    Map<String, Mimetype> mimetypes = getMimetypes();
    for (Mimetype mimetype : mimetypes.values()) {
      types.put(mimetype.getDescription(), mimetype.getMimetype());
    }

    return types;
  }