Package org.simpleframework.http

Examples of org.simpleframework.http.Query


    * query and the form post are merge together in a single query.
    *
    * @return the query associated with the HTTP target URI
    */  
   public Query build() {;
      Query query = header.getQuery();
     
      if(!isFormPost()) {
         return query;
      }
      return getQuery(query);
View Full Code Here


      MockBody body = new MockBody();
      MockHeader header = new MockHeader("/path?a=query_A&b=query_B&c=query_C&d=query_D");
      MockEntity entity = new MockEntity(body, header);
      QueryBuilder builder = new QueryBuilder(request, entity);

      Query form = builder.build();
     
      assertEquals(form.getAll("a").size(), 2);
      assertEquals(form.getAll("b").size(), 1);
      assertEquals(form.getAll("c").size(), 2);
      assertEquals(form.getAll("e").size(), 1)
     
      assertEquals(form.get("a"), "query_A");
      assertEquals(form.get("b"), "query_B");
      assertEquals(form.get("c"), "query_C");
      assertEquals(form.get("e"), "post_E");  
   }
View Full Code Here

    *
    * @return this returns the form created from the request
    */
   public Form getInstance() throws IOException {     
      PartList list = getParts();
      Query form = getQuery();
     
      for(Part part : list) {
         String name = part.getName();
         String value = part.getContent();
        
         form.put(name, value);      
      }     
      return new PartForm(body, form);     
   }
View Full Code Here

    * query and the form post are merge together in a single query.
    *
    * @return the query associated with the HTTP target URI
    */  
   private Query getQuery() throws IOException {
      Query query = request.getQuery();
     
      if(!isFormPost()) {
         return query;
      }
      return getQuery(query); // only get if form
View Full Code Here

   public void testEmptyPath() {
      assertEquals("/", link.getPath().toString());
   }

   public void testEmptyQuery() {
      Query query = link.getQuery();
      assertEquals(0, query.size());
   }
View Full Code Here

   }

   public void testQuery() {
      link.parse("/?name=value&attribute=string");
  
      Query query = link.getQuery();              
                   
      assertEquals(2, query.size());     
      assertEquals("value", query.get("name"));
      assertTrue(query.containsKey("attribute"));

      query.clear();
      query.put("name", "change");

      assertEquals("change", query.get("name"));
   }
View Full Code Here

    @Override
    public ImmutableMap<String, ImmutableList<String>> getQueryParams() {
        if (queryParams == null) {
            ImmutableMap.Builder<String, ImmutableList<String>> paramsBuilder = ImmutableMap.builder();
            Query query = request.getQuery();
            for (String param : query.keySet()) {
                paramsBuilder.put(param, ImmutableList.copyOf(query.getAll(param)));
            }
            queryParams = paramsBuilder.build();
        }
        return queryParams;
    }
View Full Code Here

TOP

Related Classes of org.simpleframework.http.Query

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.