Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.NameValuePair


  private List<NameValuePair> getParams(Resource subj, URI pred, Value obj, boolean includeInferred,
      Resource... contexts)
  {
    List<NameValuePair> params = new ArrayList<NameValuePair>(5);
    if (subj != null) {
      params.add(new NameValuePair(Protocol.SUBJECT_PARAM_NAME, Protocol.encodeValue(subj)));
    }
    if (pred != null) {
      params.add(new NameValuePair(Protocol.PREDICATE_PARAM_NAME, Protocol.encodeValue(pred)));
    }
    if (obj != null) {
      params.add(new NameValuePair(Protocol.OBJECT_PARAM_NAME, Protocol.encodeValue(obj)));
    }
    for (String encodedContext : Protocol.encodeContexts(contexts)) {
      params.add(new NameValuePair(Protocol.CONTEXT_PARAM_NAME, encodedContext));
    }
    params.add(new NameValuePair(Protocol.INCLUDE_INFERRED_PARAM_NAME, Boolean.toString(includeInferred)));
    if (limit != null) {
      params.add(new NameValuePair(Protocol.LIMIT, String.valueOf(limit)));
    }
    return params;
  }
View Full Code Here


  private List<NameValuePair> getParams(Resource subj, URI pred, Value obj, boolean includeInferred,
      Resource... contexts)
  {
    List<NameValuePair> params = new ArrayList<NameValuePair>(5);
    if (subj != null) {
      params.add(new NameValuePair(Protocol.SUBJECT_PARAM_NAME, Protocol.encodeValue(subj)));
    }
    if (pred != null) {
      params.add(new NameValuePair(Protocol.PREDICATE_PARAM_NAME, Protocol.encodeValue(pred)));
    }
    if (obj != null) {
      params.add(new NameValuePair(Protocol.OBJECT_PARAM_NAME, Protocol.encodeValue(obj)));
    }
    for (String encodedContext : Protocol.encodeContexts(contexts)) {
      params.add(new NameValuePair(Protocol.CONTEXT_PARAM_NAME, encodedContext));
    }
    params.add(new NameValuePair(Protocol.INCLUDE_INFERRED_PARAM_NAME, Boolean.toString(includeInferred)));
    return params;
  }
View Full Code Here

  public TupleResult post(int amount)
    throws StoreException, QueryResultParseException, NoCompatibleMediaType
  {
    HTTPRequest request = pool.post();

    NameValuePair pair = new NameValuePair(AMOUNT, valueOf(amount));
    request.sendQueryString(Arrays.asList(pair));

    try {
      request.acceptTupleQueryResult();
      execute(request);
View Full Code Here

  public BNode post(String nodeID)
    throws StoreException, QueryResultParseException, NoCompatibleMediaType
  {
    HTTPRequest request = pool.post();

    NameValuePair pair = new NameValuePair(NODE_ID, nodeID);
    request.sendQueryString(Arrays.asList(pair));

    try {
      request.acceptTupleQueryResult();
      execute(request);
View Full Code Here

  private List<NameValuePair> getQueryParams(QueryLanguage ql, String query, Dataset dataset,
      boolean includeInferred, Binding... bindings)
  {
    List<NameValuePair> queryParams = new ArrayList<NameValuePair>(bindings.length + 10);

    queryParams.add(new NameValuePair(Protocol.QUERY_LANGUAGE_PARAM_NAME, ql.getName()));
    queryParams.add(new NameValuePair(Protocol.QUERY_PARAM_NAME, query));
    queryParams.add(new NameValuePair(Protocol.INCLUDE_INFERRED_PARAM_NAME,
        Boolean.toString(includeInferred)));

    if (dataset != null) {
      for (URI defaultGraphURI : dataset.getDefaultGraphs()) {
        queryParams.add(new NameValuePair(Protocol.DEFAULT_GRAPH_PARAM_NAME, defaultGraphURI.toString()));
      }
      for (URI namedGraphURI : dataset.getNamedGraphs()) {
        queryParams.add(new NameValuePair(Protocol.NAMED_GRAPH_PARAM_NAME, namedGraphURI.toString()));
      }
    }

    for (int i = 0; i < bindings.length; i++) {
      String paramName = Protocol.BINDING_PREFIX + bindings[i].getName();
      String paramValue = Protocol.encodeValue(bindings[i].getValue());
      queryParams.add(new NameValuePair(paramName, paramValue));
    }

    return queryParams;
  }
View Full Code Here

  }

  private InputStream retreiveXMLReply(String partOfSpeech, String word) {
    HttpClient client = HttpClientFactory.getHttpClientInstance();
    HttpMethod method = new GetMethod(MORPHOLOGICAL_SERVICE_ADRESS);
    NameValuePair posValues = new NameValuePair(PART_OF_SPEECH_PARAM, partOfSpeech);
    NameValuePair wordValues = new NameValuePair(GLOSS_TERM_PARAM, word);
    if (log.isDebug()) {
      String url = MORPHOLOGICAL_SERVICE_ADRESS + "?" + PART_OF_SPEECH_PARAM + "=" + partOfSpeech + "&" + GLOSS_TERM_PARAM + "=" + word;
      log.debug("Send GET request to morph-service with URL: " + url);
    }
    method.setQueryString(new NameValuePair[] { posValues, wordValues });
View Full Code Here

         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/spring-integration-test/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
View Full Code Here

         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/spring-integration-test/locating/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
View Full Code Here

         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
View Full Code Here

         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/locating/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.NameValuePair

Copyright © 2018 www.massapicom. 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.