public static List<ContentType> parseQueryResultFormatList(Collection<? extends QueryResultFormat> types) { List<ContentType> contentTypes = new ArrayList<ContentType>(); for(QueryResultFormat c : types) { // We cannot handle formats that do not have a charset, ie, they are binary formats if(c.hasCharset()) { for(String nextMimeType : c.getMIMETypes()) { if(nextMimeType.equals("application/xml")) { // HACK: Remove application/xml so that application/sparql-results+xml // and application/rdf+xml, for tuple/boolean and graph results, respectively, // will be preferred continue; } ContentType type = new ContentType(parseContentType(nextMimeType).getType(), parseContentType(nextMimeType).getSubtype(), c.getCharset()); if(c.getDefaultMIMEType().equals(nextMimeType)) { type.setParameter("q", "1.0"); } else { type.setParameter("q", "0.5"); } contentTypes.add(type); } } } return contentTypes; }
@Override public QueryResultFormat getQueryResultFormat() { return new QueryResultFormat("QueryResultFormat", format.getDefaultMIMEType(), Charset.defaultCharset(), format.getDefaultFileExtension()); }
private HttpResponse sendBooleanQueryViaHttp(HttpUriRequest method, Set<QueryResultFormat> booleanFormats) throws IOException, OpenRDFException { for (QueryResultFormat format : booleanFormats) { // Determine a q-value that reflects the user specified preference int qValue = 10; if (preferredBQRFormat != null && !preferredBQRFormat.equals(format)) { // Prefer specified format over other formats qValue -= 2; } for (String mimeType : format.getMIMETypes()) { String acceptParam = mimeType; if (qValue < 10) { acceptParam += ";q=0." + qValue; } method.addHeader(ACCEPT_PARAM_NAME, acceptParam); } } return executeOK(method); }
for (String mimeType : format.getMIMETypes()) { String acceptParam = mimeType;
public static List<ContentType> parseQueryResultFormatList(Collection<? extends QueryResultFormat> types) { List<ContentType> contentTypes = new ArrayList<ContentType>(); for(QueryResultFormat c : types) { // We cannot handle formats that do not have a charset, ie, they are binary formats if(c.hasCharset()) { for(String nextMimeType : c.getMIMETypes()) { if(nextMimeType.equals("application/xml")) { // HACK: Remove application/xml so that application/sparql-results+xml // and application/rdf+xml, for tuple/boolean and graph results, respectively, // will be preferred continue; } ContentType type = new ContentType(parseContentType(nextMimeType).getType(), parseContentType(nextMimeType).getSubtype(), c.getCharset()); if(c.getDefaultMIMEType().equals(nextMimeType)) { type.setParameter("q", "1.0"); } else { type.setParameter("q", "0.5"); } contentTypes.add(type); } } } return contentTypes; }
@Override public QueryResultFormat getQueryResultFormat() { return new QueryResultFormat("QueryResultFormat", format.getDefaultMIMEType(), Charset.defaultCharset(), format.getDefaultFileExtension()); }