Package org.apache.commons.codec.net

Examples of org.apache.commons.codec.net.URLCodec


     private static String doFormUrlEncode(NameValuePair[] pairs, String charset)
        throws UnsupportedEncodingException
     {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < pairs.length; i++) {
            URLCodec codec = new URLCodec();
            NameValuePair pair = pairs[i];
            if (pair.getName() != null) {
                if (i > 0) {
                    buf.append("&");
                }
                buf.append(codec.encode(pair.getName(), charset));
                buf.append("=");
                if (pair.getValue() != null) {
                    buf.append(codec.encode(pair.getValue(), charset));
                }
            }
        }
        return buf.toString();
    }
View Full Code Here


    streamDownloader.download(request, response, testDoc, null);
  }

  public void ecode() throws Exception {
    String value = "汉字-english and .;";
    String ecodedValue = new URLCodec().encode(value, "utf-8");
    String orginValue = URLDecoder.decode(ecodedValue, "utf-8");
    Assert.assertEquals(orginValue, value);
  }
View Full Code Here

        }
        if (user.avatar == null && user.email != null) {
            user.avatar = "https://www.gravatar.com/avatar/" + DigestUtils.md5Hex(user.email.getBytes());
            if (socialUser.avatarUrl().isDefined()) {
                try {
                    user.avatar += "?d=" + new URLCodec().encode(socialUser.avatarUrl().get());
                } catch (EncoderException e) {
                    // ??
                }
            }
        }
View Full Code Here

     private static String doFormUrlEncode(NameValuePair[] pairs, String charset)
        throws UnsupportedEncodingException
     {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < pairs.length; i++) {
            URLCodec codec = new URLCodec();
            NameValuePair pair = pairs[i];
            if (pair.getName() != null) {
                if (i > 0) {
                    buf.append("&");
                }
                buf.append(codec.encode(pair.getName(), charset));
                buf.append("=");
                if (pair.getValue() != null) {
                    buf.append(codec.encode(pair.getValue(), charset));
                }
            }
        }
        return buf.toString();
    }
View Full Code Here

     private static String doFormUrlEncode(NameValuePair[] pairs, String charset)
        throws UnsupportedEncodingException
     {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < pairs.length; i++) {
            URLCodec codec = new URLCodec();
            NameValuePair pair = pairs[i];
            if (pair.getName() != null) {
                if (i > 0) {
                    buf.append("&");
                }
                buf.append(codec.encode(pair.getName(), charset));
                buf.append("=");
                if (pair.getValue() != null) {
                    buf.append(codec.encode(pair.getValue(), charset));
                }
            }
        }
        return buf.toString();
    }
View Full Code Here

        super();
    }

    public void init() throws ServletException {
        super.init();
        urlCodec = new URLCodec();
        repoMgr = LookupUtil.getRepoManagerLocal();
        contentMgr = LookupUtil.getContentManager();
        contentSourceMgr = LookupUtil.getContentSourceManager();
        distroMgr = LookupUtil.getDistributionManagerLocal();
    }
View Full Code Here

        txtENC.setText("");
        String decData = txtDEC.getText();
          String charName = cboCharset.getText();
          String encData = "";

          URLCodec uc = new URLCodec();
          try {
            encData = uc.encode(decData, charName);
        } catch (UnsupportedEncodingException e1) {
          e1.printStackTrace();
        }

          txtENC.append(encData);
        }
     
      @Override
      public void widgetDefaultSelected(SelectionEvent e) {
      }
    });
   
    btnDEC.addSelectionListener(new SelectionListener() {
     
      @Override
      public void widgetSelected(SelectionEvent e) {
        txtDEC.setText("");
        String encData = txtENC.getText();
          String charName = cboCharset.getText();
          String decData = "";
         
          URLCodec uc = new URLCodec();
          try {
          decData = uc.decode(encData, charName);
        } catch (UnsupportedEncodingException e1) {
          e1.printStackTrace();
        } catch (DecoderException e1) {
          e1.printStackTrace();
        }
View Full Code Here

    protected String invokeHTTPRequest(String url, String[] jsonArgs) throws IOException, EncoderException {
       
         HttpClient httpclient = new DefaultHttpClient();
        
        
         URLCodec uc = new URLCodec();
         for (int i=0 ; i<jsonArgs.length; i++) {
             if (i == 0) {
                 url += '?';
             } else {
                 url += '&';
             }
             url += "arg" + i + "=";
             url += uc.encode(jsonArgs[i]);
         }

         HttpGet httpget = new HttpGet(url);

         HttpResponse response = httpclient.execute(httpget);
View Full Code Here

        for (String pair : pairs)
        {
            String[] nameValue = pair.split("=");
            if (nameValue.length == 2)
            {
                URLCodec codec = new URLCodec(outputEncoding);
                String key = codec.decode(nameValue[0]);
                String value = codec.decode(nameValue[1]);
                addToParameterMap(paramMap, key, value);
            }
        }
    }
View Full Code Here

    protected String invokeHTTPRequest(String url, String[] jsonArgs) throws IOException, EncoderException {
       
         HttpClient httpclient = new DefaultHttpClient();
        
        
         URLCodec uc = new URLCodec();
         for (int i=0 ; i<jsonArgs.length; i++) {
             if (i == 0) {
                 url += '?';
             } else {
                 url += '&';
             }
             url += "arg" + i + "=";
             url += uc.encode(jsonArgs[i]);
         }

         HttpGet httpget = new HttpGet(url);

         HttpResponse response = httpclient.execute(httpget);
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.net.URLCodec

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.