indicates if the MIME type belongs to the APPLICATION XML family
544176
private static boolean isAppXml(final String mime) {
        return mime != null
                && (mime.equals("application/xml") || mime.equals("application/xml-dtd") || mime.equals("application/xml-external-parsed-entity") || mime
                        .startsWith("application/") && mime.endsWith("+xml"));
    }
1101000
private static MimeType getParentMimeType(Resource resource) {
        MimeType result = null;
        if (resource != null && (resource = resource.getParent()) != null) {
            ResourceHandle handle = ResourceHandle.use(resource);
            result = getMimeType(handle.getProperty(ResourceUtil.PROP_MIME_TYPE, ""));
            if (result == null) {
                String filename = getResourceName(resource);
                result = getMimeType(filename);
            }
        }
        return result;
    }
1264883
def _detect_content_type(self, filename):
        '''
        '''
        name, ext = os.path.splitext(filename)
        if not ext:
            raise MessageError('File requires an extension.')
        ext = ext.lower()
        if ext.lstrip('.') in self._banned_extensions:
            err = 'Extension "{0}" is not allowed.'
            raise MessageError(err.format(ext))
        if not mimetypes.inited:
            mimetypes.init()
        return mimetypes.types_map.get(ext, self._default_content_type)
1271943
public static void checkPersistenceXMLValidity ()
  {
    // Check if all persistence.xml files contain valid classes!
    try
    {
      int nCount = 0;
      final Enumeration <URL> aEnum = ClassLoaderHelper.getResources (ClassLoaderHelper.getDefaultClassLoader (),
                                                                      PATH_PERSISTENCE_XML);
      while (aEnum.hasMoreElements ())
      {
        nCount++;
        final URL aURL = aEnum.nextElement ();
        final IMicroDocument aDoc = MicroReader.readMicroXML (new URLResource (aURL));
        if (aDoc == null || aDoc.getDocumentElement () == null)
          throw new IllegalStateException ("No XML file: " + aURL);
        for (final IMicroElement ePU : aDoc.getDocumentElement ().getAllChildElements (PERSISTENCE_NAMESPACE_URI,
                                                                                       "persistence-unit"))
          for (final IMicroElement eClass : ePU.getAllChildElements (PERSISTENCE_NAMESPACE_URI, "class"))
          {
            final String sClass = eClass.getTextContent ();
            if (StringHelper.hasNoTextAfterTrim (sClass))
              throw new IllegalStateException ("Persistence file " + aURL + ": class name is missing!");
            GenericReflection.getClassFromName (sClass.trim ());
          }
      }
      LOGGER.info ("All " + PATH_PERSISTENCE_XML + " files are valid (count=" + nCount + ")");
    }
    catch (final IOException ex)
    {
      // From getResources
      throw new IllegalStateException ("Failed to read " + PATH_PERSISTENCE_XML + " file", ex);
    }
    catch (final ClassNotFoundException ex)
    {
      // If forName fails
      throw new IllegalStateException ("Failed to resolve class", ex);
    }
  }
205168
protected boolean shouldDetectMimeType(String mimeType) {
		for (String prefix : untrustfulMimeTypes) {
			if (mimeType.startsWith(prefix)) return true;
		}
		return false;
	}
139905
def content_type(path, filename)
      type = (filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
      case type
      when %r"jp(e|g|eg)"            then "image/jpeg"
      when %r"tiff?"                 then "image/tiff"
      when %r"png", "gif", "bmp"     then "image/#{type}"
      when "txt"                     then "text/plain"
      when %r"html?"                 then "text/html"
      when "js"                      then "application/js"
      when "csv", "xml", "css"       then "text/#{type}"
      else
        # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
        content_type = (`file -b --mime-type #{path}`.split(':').last.strip rescue "application/x-#{type}")
        content_type = "application/x-#{type}" if content_type.match(/\(.*?\)/)
        content_type
      end
    end
1147855
private boolean isMavenVersionTag(GraphContext context, FileLocationModel model)
    {
        if (isMavenFile(context, model))
        {
            Document doc = ((XmlFileModel) model.getFile()).asDocument();
            for (Element elm : $(doc).find("version"))
            {
                String text = StringUtils.trim($(elm).text());
                if (StringUtils.equals(text, model.getSourceSnippit()))
                {
                    return true;
                }
            }
        }
        return false;
    }
1202976
private boolean isMimeTypeMatch(MediaType mediaType, MediaType rangePattern) {
    String WILDCARD = "*";
    String rangePatternType = rangePattern.getType();
    String rangePatternSubtype = rangePattern.getSubtype();
    return (rangePatternType.equals(WILDCARD) || rangePatternType.equals(mediaType.getType()))
        && (rangePatternSubtype.equals(WILDCARD) || rangePatternSubtype.equals(mediaType.getSubtype()));
  }
349251
def determine_file_type(self, z):
        """"""

        mimetype = z.read('mimetype').decode('utf-8').strip()
        self.type = MIMEMAP[mimetype]
8403
def is_xml(origin, filepath, fileobj, *args, **kwargs):
    
    # pylint: disable=unused-argument
    if fileobj is not None:
        loc = fileobj.tell()
        fileobj.seek(0)
        try:
            sig = fileobj.read(5).lower()
            return sig == XML_SIGNATURE
        finally:
            fileobj.seek(loc)
    elif filepath is not None:
        return filepath.endswith(('.xml', '.xml.gz'))
1051622
@SuppressWarnings("WeakerAccess")
	public static boolean isMimeType(@Nonnull final MimePart part, @Nonnull final String mimeType) {
		// Do not use part.isMimeType(String) as it is broken for MimeBodyPart
		// and does not really check the actual content type.

		try {
			final ContentType contentType = new ContentType(retrieveDataHandler(part).getContentType());
			return contentType.match(mimeType);
		} catch (final ParseException ex) {
			return retrieveContentType(part).equalsIgnoreCase(mimeType);
		}
	}
105802
public static function determineContentType($ext = '', $content = '', $local_file = '', $default = '')
    {
        self::initMimeTypes();

        $defaultMime = 'application/octet-stream';

        if ( ! empty($default))
        {
            $defaultMime = $default;
        }

        $mime = '';

        if (class_exists('finfo'))
        {
            $fileInfo = new finfo(FILEINFO_MIME_TYPE);
            if ( ! empty($content))
            {
                $mime = $fileInfo->buffer($content);
            }
            elseif ( ! empty($local_file))
            {
                $mime = $fileInfo->file($local_file);
            }
        }

        if (empty($mime) ||
            (0 === strcasecmp($mime, $defaultMime)) ||
            (0 === strcasecmp('text/plain', $mime)) ||
            (0 === strcasecmp('text/x-asm', $mime)) ||
            (0 === strcasecmp('text/x-c', $mime)) ||
            (0 === strcasecmp('text/x-c++', $mime)) ||
            (0 === strcasecmp('text/x-java', $mime))
        )
        {
            if (0 === strcasecmp('dfpkg', $ext))
            {
                $mime = 'application/zip';
            }
            else
            {
                $mime = Arr::get(self::$mimeTypes, $ext);
            }
        }
        if (empty($mime))
        {
            return $defaultMime;
        }

        return $mime;
    }
1120276
def mime_type(self):
        
        mime_type, encoding = mimetypes.guess_type(self.path)
        if not mime_type:
            mime_type = 'application/octet-stream'
        return mime_type
652484
def json_mime_type(self):
        
        mime_type = "application/json"
        if (self.api_version >= '1.1' and 'Accept' in request.headers):
            mime_type = do_conneg(request.headers['Accept'], [
                                  'application/ld+json']) or mime_type
        return mime_type
1059150
private static void checkMediaType(Multimap<MediaType, SerializationFormat> simplifiedMediaTypeToFormats,
                                       MediaType mediaType) {
        final MediaType simplifiedMediaType = mediaType.withoutParameters();
        for (SerializationFormat format : simplifiedMediaTypeToFormats.get(simplifiedMediaType)) {
            for (MediaType registeredMediaType : format.mediaTypes()) {
                checkState(!registeredMediaType.is(mediaType) && !mediaType.is(registeredMediaType),
                           "media type registered already: ", mediaType);
            }
        }
    }
44200
def get_content_type(*names):
    """"""
    for name in names:
        if name is not None:
            mimetype, encoding = mimetypes.guess_type(name)
            if mimetype is not None:
                if isinstance(mimetype, bytes):
                    return mimetype.decode("ascii")
                else:
                    return mimetype
    else:
        return "application/octet-stream"
153805
public function matchMimetypeExtension($mimetype, $extension)
    {
        $mime_extensions = self::$mimetypes_extensions;
        if (isset($mime_extensions[$extension]) && $mime_extensions[$extension] == $mimetype) {
            return true;
        }

        return false;
    }