Package org.openrdf.http.client

Source Code of org.openrdf.http.client.BooleanQueryClient

/*
* Copyright Aduna (http://www.aduna-software.com/) (c) 2008-2010.
*
* Licensed under the Aduna BSD-style license.
*/
package org.openrdf.http.client;

import java.io.IOException;

import org.openrdf.http.client.connections.HTTPRequest;
import org.openrdf.http.client.connections.HTTPConnectionPool;
import org.openrdf.http.protocol.exceptions.NoCompatibleMediaType;
import org.openrdf.query.resultio.QueryResultParseException;
import org.openrdf.rio.UnsupportedRDFormatException;
import org.openrdf.store.StoreException;

/**
* @author James Leigh
*/
public class BooleanQueryClient extends QueryClient {

  public BooleanQueryClient(HTTPConnectionPool pool) {
    super(pool);
  }

  public boolean get()
    throws StoreException
  {
    HTTPRequest request = createRequest();

    try {
      request.acceptBoolean();
      execute(request);
      return request.readBoolean();
    }
    catch (NoCompatibleMediaType e) {
      throw new UnsupportedRDFormatException(e);
    }
    catch (IOException e) {
      throw new StoreException(e);
    }
    catch (QueryResultParseException e) {
      throw new StoreException(e);
    }
    finally {
      request.release();
    }
  }
}
TOP

Related Classes of org.openrdf.http.client.BooleanQueryClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.