Example usage for org.apache.commons.rdf.api RDFSyntax byMediaType

List of usage examples for org.apache.commons.rdf.api RDFSyntax byMediaType

Introduction

In this page you can find the example usage for org.apache.commons.rdf.api RDFSyntax byMediaType.

Prototype

public static Optional<RDFSyntax> byMediaType(String mediaType) 

Source Link

Document

Return the RDFSyntax with the specified media type.

Usage

From source file:org.trellisldp.http.impl.HttpUtils.java

/**
 * Given a list of acceptable media types and an RDF syntax, get the relevant profile data, if
 * relevant.//from w ww  .  jav a2s. c o  m
 *
 * @param acceptableTypes the types from HTTP headers
 * @param syntax an RDF syntax
 * @return a profile IRI if relevant
 */
public static IRI getProfile(final List<MediaType> acceptableTypes, final RDFSyntax syntax) {
    for (final MediaType type : acceptableTypes) {
        if (RDFSyntax.byMediaType(type.toString()).filter(isEqual(syntax)).isPresent()
                && type.getParameters().containsKey("profile")) {
            return rdf.createIRI(type.getParameters().get("profile").split(" ")[0].trim());
        }
    }
    return null;
}

From source file:org.trellisldp.http.impl.RdfUtils.java

/**
 * Given a list of acceptable media types and an RDF syntax, get the relevant profile data, if
 * relevant//from  w  w  w  .  j a  v a2 s  . co  m
 * @param acceptableTypes the types from HTTP headers
 * @param syntax an RDF syntax
 * @return a profile IRI if relevant
 */
public static IRI getProfile(final List<MediaType> acceptableTypes, final RDFSyntax syntax) {
    for (final MediaType type : acceptableTypes) {
        if (RDFSyntax.byMediaType(type.toString()).filter(syntax::equals).isPresent()
                && type.getParameters().containsKey("profile")) {
            return rdf.createIRI(type.getParameters().get("profile").split(" ")[0].trim());
        }
    }
    return null;
}