Package net.sf.sahi.util

Examples of net.sf.sahi.util.CaseInsensitiveString


* limitations under the License.
*/
public class HttpHeaders {
  LinkedHashMap<CaseInsensitiveString, List<String>> headers = new LinkedHashMap<CaseInsensitiveString, List<String>>(15);
  public void addHeader(String key, String value){
    CaseInsensitiveString keyIgnoreCase = new CaseInsensitiveString(key);
        List<String> entry = (List<String>) headers.get(keyIgnoreCase);
        if (entry == null) {
            entry = new ArrayList<String>();
            headers.put(keyIgnoreCase, entry);
        }
View Full Code Here


            headers.put(keyIgnoreCase, entry);
        }
        entry.add(value);
  }
  public void setHeader(String key, String value){
    CaseInsensitiveString keyIgnoreCase = new CaseInsensitiveString(key);
        List<String> entry = new ArrayList<String>();
        entry.add(value);
        headers.put(keyIgnoreCase, entry);
  }
View Full Code Here

        entry.add(value);
        headers.put(keyIgnoreCase, entry);
  }
 
  public boolean hasHeader(String key){
    return headers.containsKey(new CaseInsensitiveString(key));
  }
View Full Code Here

  public boolean hasHeader(String key){
    return headers.containsKey(new CaseInsensitiveString(key));
  }
 
  public String getHeader(String key){
    CaseInsensitiveString keyIgnoreCase = new CaseInsensitiveString(key);
        List<String> values = headers.get(keyIgnoreCase);
        if (values == null) return null;
        StringBuffer sb = new StringBuffer();
        int size = values.size();
        for (int i = 0; i < size; i++) {
View Full Code Here

        }
        return sb.toString();
  }
 
  public List<String> getHeaders(String key){
    CaseInsensitiveString keyIgnoreCase = new CaseInsensitiveString(key);
        return headers.get(keyIgnoreCase);
  }
View Full Code Here

        return headers.get(keyIgnoreCase);
  }
 
  public void addHeaders(String key, List<String> newHeaders){
    if (newHeaders == null) return;
    CaseInsensitiveString keyIgnoreCase = new CaseInsensitiveString(key);
        List<String> entry = headers.get(keyIgnoreCase);
        if (entry == null) {
            entry = new ArrayList<String>();
            headers.put(keyIgnoreCase, entry);
        }
View Full Code Here

        }
        entry.addAll(newHeaders);
  }
 
  public String getLastHeader(String key){
        List<String> entry = headers.get(new CaseInsensitiveString(key));
        if (entry == null)
            return null;
        return (String) entry.get(entry.size() - 1);
  }
View Full Code Here

 
    public String toString() {
        StringBuffer sb = new StringBuffer();
        Iterator<CaseInsensitiveString> keys = headers.keySet().iterator();
        while (keys.hasNext()) {
            CaseInsensitiveString key = (CaseInsensitiveString) keys.next();
            if (key.isNull()) continue;
            List<String> values = headers.get(key);
            int size = values.size();
            for (int i = 0; i < size; i++) {
                String value = (String) values.get(i);
                sb.append(key).append(": ").append(value).append("\r\n");
View Full Code Here

            }
        }
        return sb.toString();
    }
  public void removeHeader(String key) {
    headers.remove(new CaseInsensitiveString(key));
  }
View Full Code Here

TOP

Related Classes of net.sf.sahi.util.CaseInsensitiveString

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.