/**
  * Return all values for the given header as a List of value objects.
  *
  * @param name the name of the header
  * @return the associated header values, or an empty List if none
  */
 public List<Object> getHeaderValues(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   if (header != null) {
     return header.getValues();
   } else {
     return Collections.emptyList();
   }
 }
 private void doAddHeaderValue(String name, Object value, boolean replace) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   Assert.notNull(value, "Header value must not be null");
   if (header == null) {
     header = new HeaderValueHolder();
     this.headers.put(name, header);
   }
   if (replace) {
     header.setValue(value);
   } else {
     header.addValue(value);
   }
 }
 public int getIntHeader(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   Object value = (header != null ? header.getValue() : null);
   if (value instanceof Number) {
     return ((Number) value).intValue();
   } else if (value instanceof String) {
     return Integer.parseInt((String) value);
   } else if (value != null) {
     throw new NumberFormatException("Value for header '" + name + "' is not a Number: " + value);
   } else {
     return -1;
   }
 }
 public void addHeader(String name, Object value) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   if (header == null) {
     header = new HeaderValueHolder();
     this.headers.put(name, header);
   }
   if (value instanceof Collection) {
     header.addValues((Collection) value);
   } else if (value.getClass().isArray()) {
     header.addValueArray(value);
   } else {
     header.addValue(value);
   }
 }
 public long getDateHeader(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   Object value = (header != null ? header.getValue() : null);
   if (value instanceof Date) {
     return ((Date) value).getTime();
   } else if (value instanceof Number) {
     return ((Number) value).longValue();
   } else if (value != null) {
     throw new IllegalArgumentException(
         "Value for header '" + name + "' is neither a Date nor a Number: " + value);
   } else {
     return -1L;
   }
 }
 @SuppressWarnings("rawtypes")
 private void doAddHeaderValue(String name, Object value, boolean replace) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   Assert.notNull(value, "Header value must not be null");
   if (header == null || replace) {
     header = new HeaderValueHolder();
     this.headers.put(name, header);
   }
   if (value instanceof Collection) {
     header.addValues((Collection) value);
   } else if (value.getClass().isArray()) {
     header.addValueArray(value);
   } else {
     header.addValue(value);
   }
 }
 @Override
 public Enumeration getHeaders(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   return Collections.enumeration(header != null ? header.getValues() : Collections.EMPTY_LIST);
 }
 @Override
 public String getHeader(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   return (header != null ? header.getValue().toString() : null);
 }
 /**
  * Return the primary value for the given header, if any.
  *
  * <p>Will return the first value in case of multiple values.
  *
  * @param name the name of the header
  * @return the associated header value, or {@code null} if none
  */
 public Object getHeaderValue(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   return (header != null ? header.getValue() : null);
 }
 @Override
 public boolean containsHeader(String name) {
   return (HeaderValueHolder.getByName(this.headers, name) != null);
 }
 public Enumeration<String> getHeaders(String name) {
   HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
   return Collections.enumeration(
       header != null ? header.getStringValues() : new LinkedList<String>());
 }