public void acceptBoolean()
throws NoCompatibleMediaType
{
if (pool.isPreferredBooleanQueryResultFormatUsed()) {
FileFormat format = pool.getPreferredBooleanQueryResultFormat();
method.addRequestHeader(ACCEPT, format.getDefaultMIMEType());
return;
}
// Specify which formats we support using Accept headers
Set<BooleanQueryResultFormat> booleanFormats = BooleanQueryResultParserRegistry.getInstance().getKeys();
if (booleanFormats.isEmpty()) {
throw new NoCompatibleMediaType("No boolean query result parsers have been registered");
}
for (BooleanQueryResultFormat format : booleanFormats) {
// Determine a q-value that reflects the user specified preference
int qValue = 10;
TupleQueryResultFormat preferredBQRFormat = pool.getPreferredTupleQueryResultFormat();
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;
}