Given a list of acceptable media types, get an RDF syntax.
@param acceptableTypes the types from HTTP headers
@param mimeType an additional "default" mimeType to match
@return an RDFSyntax
175368
public static Optional<RDFSyntax> getSyntax(final List<MediaType> acceptableTypes,
            final Optional<String> mimeType) {
        if (acceptableTypes.isEmpty()) {
            // TODO -- JDK9 refactor with Optional::or
            if (mimeType.isPresent()) {
                return empty();
            }
            return of(TURTLE);
        }
        final Optional<MediaType> mt = mimeType.map(MediaType::valueOf);
        for (final MediaType type : acceptableTypes) {
            if (mt.filter(type::isCompatible).isPresent()) {
                return empty();
            }
            final Optional<RDFSyntax> syntax = MEDIA_TYPES.stream().filter(type::isCompatible)
                .findFirst().map(MediaType::toString).flatMap(RDFSyntax::byMediaType);
            if (syntax.isPresent()) {
                return syntax;
            }
        }
        LOGGER.debug("Valid syntax not found among {} or {}", acceptableTypes, mimeType);
        throw new NotAcceptableException();
    }
1219696
public static Collection<String> sanitiseSemanticTypes(final Collection<String> semanticTypes) {
        if (semanticTypes == null) return ImmutableList.of();

        // check that each of the given types are in the map we have, otherwise throw it away
        final Set<String> s = new LinkedHashSet<>(semanticTypes);
        return s.retainAll(SEMANTIC_TYPES_CODE_TO_DESCRIPTION.keySet()) ? s : semanticTypes;
    }
225317
@Nonnull
  public EChange registerMimeTypeContent (@Nonnull final MimeTypeContent aMimeTypeContent)
  {
    ValueEnforcer.notNull (aMimeTypeContent, "MimeTypeContent");

    return m_aRWLock.writeLocked ( () -> m_aMimeTypeContents.addObject (aMimeTypeContent));
  }
1297165
def known_formats(use: Union[Serializer, Parser]=Serializer, include_mime_types: bool = False) -> List[str]:
    
    return sorted([name for name, kind in plugin._plugins.keys()
                   if kind == use and (include_mime_types or '/' not in name)])
418810
public Route produces(String... types) {
        Preconditions.checkNotNull(types);
        final ImmutableSet.Builder<MediaType> builder = new ImmutableSet.Builder<>();
        builder.addAll(this.producedMediaTypes);
        for (String s : types) {
            final MediaType mt = MediaType.parse(s);
            if (mt.hasWildcard()) {
                throw new RoutingException("A route cannot `produce` a mime type with a wildcard: " + mt);
            }
            builder.add(mt);
        }
        this.producedMediaTypes = builder.build();
        return this;
    }
1338665
public static ContentType create(final String mimeType, final Charset charset) {
        if (mimeType == null) {
            throw new IllegalArgumentException("MIME type may not be null");
        }
        String type = mimeType.trim().toLowerCase(Locale.US);
        if (type.length() == 0) {
            throw new IllegalArgumentException("MIME type may not be empty");
        }
        if (!valid(type)) {
            throw new IllegalArgumentException("MIME type may not contain reserved characters");
        }
        return new ContentType(type, charset);
    }
20373
def mimetype(self):
        
        if ';' in self.headers.get('Content-Type', ''):
            return self.headers['Content-Type'].split(';')[0]
        return self.headers.get('Content-Type', self.static_format)
89717
public EndpointInfoBuilder availableMimeTypes(Iterable<MediaType> availableMimeTypes) {
        requireNonNull(availableMimeTypes, "availableMimeTypes");
        checkArgument(!Iterables.isEmpty(availableMimeTypes), "Should at least have an available media type.");
        if (defaultMimeType != null && !Iterables.contains(availableMimeTypes, defaultMimeType)) {
            this.availableMimeTypes = addDefaultMimeType(defaultMimeType, availableMimeTypes);
        } else {
            this.availableMimeTypes = ImmutableSet.copyOf(availableMimeTypes);
        }
        return this;
    }
1206592
def mimetype(self):
        """"""
        ct = self.headers.get("content-type")
        if ct:
            return ct.split(";")[0].strip()
315794
def mediatypes(self):
        """"""
        return [h for h, q in sorted(request.accept_mimetypes,
                                     key=operator.itemgetter(1), reverse=True)]
72362
def _getSyntaxByMimeType(self, mimeType):
        
        xmlFileName = self._mimeTypeToXmlFileName[mimeType]
        return self._getSyntaxByXmlFileName(xmlFileName)
980465
private static List<MediaType> getResourceMethodProducibleTypes(final ExtendedUriInfo extendedUriInfo) {
        if (extendedUriInfo.getMatchedResourceMethod() != null
                && !extendedUriInfo.getMatchedResourceMethod().getProducedTypes().isEmpty()) {
            return extendedUriInfo.getMatchedResourceMethod().getProducedTypes();
        }
        return Collections.singletonList(MediaType.WILDCARD_TYPE);
    }
1200926
public MediaType getContentType() {
		String value = getFirst(CONTENT_TYPE);
		return (StringUtils.hasLength(value) ? MediaType.parseMediaType(value) : null);
	}
821914
public static ContentInfo findMimeTypeMatch(String mimeType) {
		ContentType type = ContentType.fromMimeType(mimeType.toLowerCase());
		if (type == ContentType.OTHER) {
			return null;
		} else {
			return new ContentInfo(type);
		}
	}
1267653
public MediaType getContentType() {
        if (isNull(this.contentType)) {
            contentType = getHeader(HeaderName.CONTENT_TYPE)
                .map(MediaType::of)
                .orElse(WILDCARD);
        }

        return contentType;
    }
986732
private LinkedMapWritable getMimetypesMap() throws IOException {
        if (mimetypeMap != null)
            return mimetypeMap;
        String mtmap = conf.get(ConfigConstants.CONF_MIMETYPES);
        if (mtmap != null) {
            mimetypeMap = DefaultStringifier.load(conf,
                ConfigConstants.CONF_MIMETYPES, LinkedMapWritable.class);
            return mimetypeMap;
        }
        String[] hosts = conf.getStrings(OUTPUT_HOST);
        Session session = null;
        ResultSequence result = null;

        for (int i = 0; i < hosts.length; i++) {
            try {
                String host = hosts[i];
                ContentSource cs = InternalUtilities.getOutputContentSource(conf,
                    host);
                session = cs.newSession();
                AdhocQuery query = session.newAdhocQuery(MIMETYPES_QUERY);
                RequestOptions options = new RequestOptions();
                options.setDefaultXQueryVersion("1.0-ml");
                query.setOptions(options);
                result = session.submitRequest(query);
                if (!result.hasNext())
                    throw new IOException(
                        "Server-side transform requires MarkLogic 7 or later");
                mimetypeMap = new LinkedMapWritable();
                while (result.hasNext()) {
                    String suffs = result.next().asString();
                    Text format = new Text(result.next().asString());
                    // some extensions are in a space separated string
                    for (String s : suffs.split(" ")) {
                        Text suff = new Text(s);
                        mimetypeMap.put(suff, format);
                    }
                }
                return mimetypeMap;
            } catch (Exception e) {
                if (e.getCause() instanceof ServerConnectionException) {
                    LOG.warn("Unable to connect to " + hosts[i]
                            + " to query destination information");
                    continue;
                }
                LOG.error(e.getMessage(), e);
                throw new IOException(e);
            } finally {
                if (result != null) {
                    result.close();
                }
                if (session != null) {
                    session.close();
                }
            }
        }
        return null;
    }
720100
public String getMimeType()
   {
      if (mediaType == null || untrustedAgent)
      {
         return mimeTypeResolver.getMimeType(fileName);
      }

      return mediaType.getType() + "/" + mediaType.getSubtype();
   }