< prev index next >

src/java.httpclient/share/classes/java/net/http/HttpHeadersImpl.java

Print this page




  55             return;
  56 
  57         Set<String> keys = new HashSet<>(headers.keySet());
  58         for (String key : keys) {
  59             List<String> values = headers.remove(key);
  60             if (values != null) {
  61                 headers.put(key, Collections.unmodifiableList(values));
  62             }
  63         }
  64         isUnmodifiable = true;
  65     }
  66 
  67     @Override
  68     public Optional<String> firstValue(String name) {
  69         List<String> l = headers.get(name);
  70         return Optional.ofNullable(l == null ? null : l.get(0));
  71     }
  72 
  73     @Override
  74     public List<String> allValues(String name) {
  75         return headers.get(name);
  76     }
  77 
  78     @Override
  79     public Map<String, List<String>> map() {
  80         return Collections.unmodifiableMap(headers);
  81     }
  82 
  83     Map<String, List<String>> directMap() {
  84         return headers;
  85     }
  86 
  87     // package private mutators
  88 
  89     public HttpHeadersImpl deepCopy() {
  90         HttpHeadersImpl h1 = new HttpHeadersImpl();
  91         HashMap<String,List<String>> headers1 = h1.headers;
  92         Set<String> keys = headers.keySet();
  93         for (String key : keys) {
  94             List<String> vals = headers.get(key);
  95             LinkedList<String> vals1 = new LinkedList<>(vals);




  55             return;
  56 
  57         Set<String> keys = new HashSet<>(headers.keySet());
  58         for (String key : keys) {
  59             List<String> values = headers.remove(key);
  60             if (values != null) {
  61                 headers.put(key, Collections.unmodifiableList(values));
  62             }
  63         }
  64         isUnmodifiable = true;
  65     }
  66 
  67     @Override
  68     public Optional<String> firstValue(String name) {
  69         List<String> l = headers.get(name);
  70         return Optional.ofNullable(l == null ? null : l.get(0));
  71     }
  72 
  73     @Override
  74     public List<String> allValues(String name) {
  75         return Collections.unmodifiableList(headers.get(name));
  76     }
  77 
  78     @Override
  79     public Map<String, List<String>> map() {
  80         return Collections.unmodifiableMap(headers);
  81     }
  82 
  83     Map<String, List<String>> directMap() {
  84         return headers;
  85     }
  86 
  87     // package private mutators
  88 
  89     public HttpHeadersImpl deepCopy() {
  90         HttpHeadersImpl h1 = new HttpHeadersImpl();
  91         HashMap<String,List<String>> headers1 = h1.headers;
  92         Set<String> keys = headers.keySet();
  93         for (String key : keys) {
  94             List<String> vals = headers.get(key);
  95             LinkedList<String> vals1 = new LinkedList<>(vals);


< prev index next >