From: Andy Scherzinger Date: Fri, 11 Sep 2015 08:57:11 +0000 (+0200) Subject: Add further javadoc descsribing how to maintain further mappings in the future X-Git-Tag: oc-android-1.8~7^2~4 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/ed094a7df6eef17eb7acddbb8296832addf1c714 Add further javadoc descsribing how to maintain further mappings in the future --- diff --git a/src/com/owncloud/android/utils/MimetypeIconUtil.java b/src/com/owncloud/android/utils/MimetypeIconUtil.java index 23ebe1ab..e67479b3 100644 --- a/src/com/owncloud/android/utils/MimetypeIconUtil.java +++ b/src/com/owncloud/android/utils/MimetypeIconUtil.java @@ -12,12 +12,33 @@ import java.util.List; import java.util.Map; /** - * Helper class for detecting the right icon for a file, based on its mimen type and/or file extension. + *

Helper class for detecting the right icon for a file or directory, + * based on its mime type and/or file extension.

+ * + * This class maintains all the necessary mappings fot these detections.
+ * In order to add further mappings, there are up to three look up maps that need further values: + *
    + *
  1. + * {@link MimetypeIconUtil#FILE_EXTENSION_TO_MIMETYPE_MAPPING}
    + * to add a new file extension to mime type mapping + *
  2. + *
  3. + * {@link MimetypeIconUtil#MIMETYPE_TO_ICON_MAPPING}
    + * to add a new mapping of a mime type to an icon mapping + *
  4. + *
  5. + * {@link MimetypeIconUtil#MAINMIMETYPE_TO_ICON_MAPPING}
    + * to add a new mapping for the main part of a mime type. + * This is a list of fallback mappings in case there is no mapping for the complete mime type + *
  6. + *
*/ public class MimetypeIconUtil { - + /** Mapping: icon for mime type */ private static final Map MIMETYPE_TO_ICON_MAPPING = new HashMap(); + /** Mapping: icon for main mime type (first part of a mime type declaration). */ private static final Map MAINMIMETYPE_TO_ICON_MAPPING = new HashMap(); + /** Mapping: mime type for file extension. */ private static final Map> FILE_EXTENSION_TO_MIMETYPE_MAPPING = new HashMap>(); @@ -105,6 +126,12 @@ public class MimetypeIconUtil { } } + /** + * provides the file extension of a given filename. + * + * @param filename the filename + * @return the file extension + */ private static String getExtension(String filename) { String extension = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase(); return extension;