Android Open Source - NewAndroidTwitter Http Params






From Project

Back to project page NewAndroidTwitter.

License

The source code is released under:

Apache License

If you think the Android project NewAndroidTwitter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.londatiga.android.twitter.http;
//ww w .j ava 2  s  .c om
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Iterator;

import net.londatiga.android.twitter.util.URIUtil;

/**
 * Http parameters.
 * 
 * @author Lorensius W. L. T <lorenz@londatiga.net>
 *
 */
public class HttpParams {
  private TreeMap<String, HttpValues> mParams;
  
  public HttpParams() {
    mParams = new TreeMap<String, HttpValues>();
  }
  
  public void put(String key, HttpValues values) {
    if (!mParams.containsKey(key)) {
      mParams.put(key, values);
    }
  }

  public HttpValues get(String key) {
    return (mParams.containsKey(key)) ? mParams.get(key) : null;
  }

  public boolean containsKey(String key) {
    return mParams.containsKey(key);
  }
  
  public String getQueryString() {
    if (mParams.size() == 0) {
      return "";
    }
    
    StringBuffer querySb = new StringBuffer();
    int size = mParams.size();
    int i = 0;
    
    for (String key : mParams.keySet()) {
      HttpValues values = mParams.get(key);
      
      if (values != null) {
        if (!values.isEmpty()) {
          TreeSet<String> vals = values.getAll();
          Iterator<String> iterator = vals.iterator();
          
          while (iterator.hasNext()) { 
            querySb.append(key + "=" + URIUtil.encode((String) iterator.next()));
            
            if (iterator.hasNext()) {
              querySb.append("&");
            }
          }
        } else {
          querySb.append(key + "=");
        }
      } else {
        querySb.append(key + "=");
      }
      
      if (i != size-1) {
        querySb.append("&");
      }
      
      i++;
    }
    
    return querySb.toString();
  }
}




Java Source Code List

net.londatiga.android.example.BaseActivity.java
net.londatiga.android.example.MainActivity.java
net.londatiga.android.example.UserActivity.java
net.londatiga.android.twitter.TwitterDialog.java
net.londatiga.android.twitter.TwitterRequest.java
net.londatiga.android.twitter.TwitterUser.java
net.londatiga.android.twitter.Twitter.java
net.londatiga.android.twitter.http.HttpConn.java
net.londatiga.android.twitter.http.HttpParams.java
net.londatiga.android.twitter.http.HttpValues.java
net.londatiga.android.twitter.oauth.OauthAccessToken.java
net.londatiga.android.twitter.oauth.OauthConsumer.java
net.londatiga.android.twitter.oauth.OauthHeader.java
net.londatiga.android.twitter.oauth.OauthProvider.java
net.londatiga.android.twitter.oauth.OauthSignature.java
net.londatiga.android.twitter.oauth.OauthToken.java
net.londatiga.android.twitter.oauth.OauthUtil.java
net.londatiga.android.twitter.util.Base64.java
net.londatiga.android.twitter.util.Cons.java
net.londatiga.android.twitter.util.Debug.java
net.londatiga.android.twitter.util.StringUtil.java
net.londatiga.android.twitter.util.URIUtil.java