Example #1
0
 @Test
 public void URIEncode() {
   assertEquals("", Util.URIEncode(""));
   assertEquals("a+b", Util.URIEncode("a b"));
   assertEquals("a%23b", Util.URIEncode("a#b"));
   assertEquals("a%2Fb", Util.URIEncode("a/b"));
   assertEquals("README.txt", Util.URIEncode("README.txt"));
 }
Example #2
0
 /**
  * Build the {@code queryAsURI} string that holds the query in a form that's suitable for sending
  * it as part of a URI.
  *
  * @param subqueries a map containing the query text for each field
  */
 private void buildQueryAsURI(Map<String, String> subqueries) {
   boolean first = true;
   StringBuilder sb = new StringBuilder();
   for (Map.Entry<String, String> entry : subqueries.entrySet()) {
     String field = entry.getKey();
     String queryText = entry.getValue();
     if (!first) {
       sb.append('&');
     }
     sb.append(field).append("=").append(Util.URIEncode(queryText));
     first = false;
   }
   queryAsURI = sb.toString();
 }