227 228 /** 229 * return an Iterator that returns all values of a particular 230 * key in sequence 231 */ 232 public Iterator<String> multiValueIterator (String k) { 233 return new HeaderIterator (k, this); 234 } 235 236 public synchronized Map<String, List<String>> getHeaders() { 237 return getHeaders(null); 238 } 239 240 public synchronized Map<String, List<String>> getHeaders(String[] excludeList) { 241 return filterAndAddHeaders(excludeList, null); 242 } 243 244 public synchronized Map<String, List<String>> filterAndAddHeaders( 245 String[] excludeList, Map<String, List<String>> include) { 246 boolean skipIt = false; 247 Map<String, List<String>> m = new HashMap<String, List<String>>(); 248 for (int i = nkeys; --i >= 0;) { 249 if (excludeList != null) { 250 // check if the key is in the excludeList. 251 // if so, don't include it in the Map. 252 for (int j = 0; j < excludeList.length; j++) { 253 if ((excludeList[j] != null) && 254 (excludeList[j].equalsIgnoreCase(keys[i]))) { 255 skipIt = true; 256 break; 257 } 258 } 259 } 260 if (!skipIt) { 261 List<String> l = m.get(keys[i]); 262 if (l == null) { 263 l = new ArrayList<String>(); 264 m.put(keys[i], l); 265 } 266 l.add(values[i]); 267 } else { 268 // reset the flag 269 skipIt = false; 270 } 271 } 272 273 if (include != null) { 274 for (Map.Entry<String,List<String>> entry: include.entrySet()) { 275 List<String> l = m.get(entry.getKey()); 276 if (l == null) { 277 l = new ArrayList<String>(); 278 m.put(entry.getKey(), l); 279 } 280 l.addAll(entry.getValue()); 281 } 282 } 283 284 for (String key : m.keySet()) { 285 m.put(key, Collections.unmodifiableList(m.get(key))); 286 } 287 288 return Collections.unmodifiableMap(m); 289 } 290 291 /** Prints the key-value pairs represented by this 292 header. Also prints the RFC required blank line 293 at the end. Omits pairs with a null key. */ 294 public synchronized void print(PrintStream p) { 295 for (int i = 0; i < nkeys; i++) 296 if (keys[i] != null) { 297 p.print(keys[i] + | 227 228 /** 229 * return an Iterator that returns all values of a particular 230 * key in sequence 231 */ 232 public Iterator<String> multiValueIterator (String k) { 233 return new HeaderIterator (k, this); 234 } 235 236 public synchronized Map<String, List<String>> getHeaders() { 237 return getHeaders(null); 238 } 239 240 public synchronized Map<String, List<String>> getHeaders(String[] excludeList) { 241 return filterAndAddHeaders(excludeList, null); 242 } 243 244 public synchronized Map<String, List<String>> filterAndAddHeaders( 245 String[] excludeList, Map<String, List<String>> include) { 246 boolean skipIt = false; 247 Map<String, List<String>> m = new HashMap<>(); 248 for (int i = nkeys; --i >= 0;) { 249 if (excludeList != null) { 250 // check if the key is in the excludeList. 251 // if so, don't include it in the Map. 252 for (int j = 0; j < excludeList.length; j++) { 253 if ((excludeList[j] != null) && 254 (excludeList[j].equalsIgnoreCase(keys[i]))) { 255 skipIt = true; 256 break; 257 } 258 } 259 } 260 if (!skipIt) { 261 List<String> l = m.get(keys[i]); 262 if (l == null) { 263 l = new ArrayList<>(); 264 m.put(keys[i], l); 265 } 266 l.add(values[i]); 267 } else { 268 // reset the flag 269 skipIt = false; 270 } 271 } 272 273 if (include != null) { 274 for (Map.Entry<String,List<String>> entry: include.entrySet()) { 275 List<String> l = m.get(entry.getKey()); 276 if (l == null) { 277 l = new ArrayList<>(); 278 m.put(entry.getKey(), l); 279 } 280 l.addAll(entry.getValue()); 281 } 282 } 283 284 for (String key : m.keySet()) { 285 m.put(key, Collections.unmodifiableList(m.get(key))); 286 } 287 288 return Collections.unmodifiableMap(m); 289 } 290 291 /** Prints the key-value pairs represented by this 292 header. Also prints the RFC required blank line 293 at the end. Omits pairs with a null key. */ 294 public synchronized void print(PrintStream p) { 295 for (int i = 0; i < nkeys; i++) 296 if (keys[i] != null) { 297 p.print(keys[i] + |