Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.apache.tomcat.util.http.fileupload.util;
Default implementation of the org.apache.tomcat.util.http.fileupload.FileItemHeaders interface.

Michael C. Macaluso
public class FileItemHeadersImpl implements FileItemHeadersSerializable {
    private static final long serialVersionUID = -4455695752627032559L;

Map of String keys to a List of String instances.
    private final Map<String,List<String>> headerNameToValueListMap =
        new HashMap<String,List<String>>();

List to preserve order of headers as added. This would not be needed if a LinkedHashMap could be used, but don't want to depend on 1.4.
    private final List<StringheaderNameList = new ArrayList<String>();
    public String getHeader(String name) {
        String nameLower = name.toLowerCase(.);
        List<StringheaderValueList = .get(nameLower);
        if (null == headerValueList) {
            return null;
        return headerValueList.get(0);
    public Iterator<StringgetHeaderNames() {
        return .iterator();
    public Iterator<StringgetHeaders(String name) {
        String nameLower = name.toLowerCase(.);
        List<StringheaderValueList = .get(nameLower);
        if (null == headerValueList) {
            return Collections.<String>emptyList().iterator();
        return headerValueList.iterator();

Method to add header values to this instance.

name name of this header
value value of this header
    public synchronized void addHeader(String nameString value) {
        String nameLower = name.toLowerCase();
        List<StringheaderValueList = .get(nameLower);
        if (null == headerValueList) {
            headerValueList = new ArrayList<String>();
New to GrepCode? Check out our FAQ X