Returns true if the given extension has a registered MIME type.
@param extension A file extension without the leading '.'
@return True iff there is an extension entry in the map.
342960
public static boolean hasExtension(String extension) {
        if (extension == null || extension.isEmpty()) {
            return false;
        }
        return extensionToMimeTypeMap.containsKey(extension);
    }
743533
public static boolean addStaticExtension(String extension) {
    	if(AssertUtils.isEmpty(extension)) {
    		return false;
    	}
    	
    	if(!extension.startsWith(".")) {
    		extension = "." + extension;
    	}
    	
    	extension = extension.toLowerCase();
    	
    	return STATIC_RESOURCE_EXTENSIONS.add(extension);
    }
1004429
private boolean isRenditionMatchExtension(MediaFormat mediaFormat) {
    for (String extension : mediaFormat.getExtensions()) {
      if (FileExtension.isImage(extension)) {
        return true;
      }
    }
    return false;
  }
637470
private String getMimeTypeFromFileExtension(String srcFile)
  {
    String srcFileLowCase = srcFile.toLowerCase();

    for (FileCompressionType compressionType : FileCompressionType.values())
    {
      if (srcFileLowCase.endsWith(compressionType.fileExtension))
      {
        return compressionType.mimeType + "/" +
               compressionType.mimeSubTypes.get(0);
      }
    }

    return null;
  }
270926
def guess_mime_type(self, path):
		
		_, ext = posixpath.splitext(path)
		if ext in self.extensions_map:
			return self.extensions_map[ext]
		ext = ext.lower()
		return self.extensions_map[ext if ext in self.extensions_map else '']
587982
public static function hasExtension(string $uri, string $extension): bool
    {
        $extension       = '.' . ltrim($extension, '.');
        $uriLength       = mb_strlen($uri);
        $extensionLength = mb_strlen($extension);
        if ($extensionLength > $uriLength) {
            return false;
        }

        return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0;
    }
672365
public final boolean isFileExcludedByExtension(@Nullable final File file) {
    return file == null || !file.isFile() || this.excludeExtensions.contains(PreprocessorUtils.getFileExtension(file));
  }
1294675
public static boolean isImage(String mime) {
		try {
			final MimeType type = new MimeType(mime);
			return IMAGE.equalsIgnoreCase(type.getPrimaryType());
		} catch (MimeTypeParseException e) {
			//
		}
		return false;
	}
5240
private static boolean isTargetValid(File fi, boolean ignoreCase, String... fileExt) {
        if (fi == null || fileExt == null || fileExt.length == 0)
            return true;

        String ext = getExtension(fi);

        for (String str : fileExt) {
            if (ignoreCase ? ext.equalsIgnoreCase(str) : ext.equals(str))
                return true;
        }

        return false;
    }
731079
public static boolean isImage(@Nullable String fileExtension) {
    if (StringUtils.isEmpty(fileExtension)) {
      return false;
    }
    return IMAGE_FILE_EXTENSIONS.contains(fileExtension.toLowerCase());
  }
203660
public static function getTypeForExtension($extension) {
		static::ensureDataLoaded();

		$extension = strtolower($extension);
		foreach (static::$mime_types as $mime_type => $extensions) {
			if (is_array($extensions)) {
				if (in_array($extension, $extensions, true)) {
					return $mime_type;
				}
			} else if ($extension === $extensions) {
				return $mime_type;
			}
		}
	}
153805
public function matchMimetypeExtension($mimetype, $extension)
    {
        $mime_extensions = self::$mimetypes_extensions;
        if (isset($mime_extensions[$extension]) && $mime_extensions[$extension] == $mimetype) {
            return true;
        }

        return false;
    }
10932
def _is_valid_extension(extension):
    
    if not cfg.CONF.valid_extensions:
        return True

    valid = False
    for cext in cfg.CONF.valid_extensions:
        if not cext.startswith('.'):
            cext = '.%s' % cext
        if extension == cext:
            valid = True
            break

    return valid
473325
private static boolean isExtFile(String filePath, String ext) {
        return filePath != null && filePath.endsWith(ext);
    }
621012
public String convertExtensionToMediaType(String extension) {
        ProvFormat format = extensionRevMap.get(extension);
        if (format == null)
            return null;
        return mimeTypeMap.get(format);
    }
1005845
public boolean compareFileExtension(String fileName,
                                        String extension) {
        
        if (fileName == null || extension == null) {
            return false;
        }
        
        fileName = fileName.toLowerCase().trim();
        extension = extension.toLowerCase();
        return (fileName.endsWith(extension));         
    }
516058
function get_extension($type)
    {
        $type = strtolower($type);
        foreach ($this->mime_types as $ext => $m_type) {
            if ($m_type == $type) return $ext;
        }
        return false;
    }