001    /*
002     * Copyright 1999-2002,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.latka.http;
018    
019    import java.util.LinkedList;
020    import java.util.List;
021    
022    /**
023     * Implementation of {@link RequestHeaders} that stores its name-value pairs
024     * in a list
025     * 
026     * @author Morgran Delagrange
027     * @author dIon Gillard
028     * @version $Id: RequestHeadersImpl.java 155424 2005-02-26 13:09:29Z dirkv $
029     */
030    public class RequestHeadersImpl implements RequestHeaders {
031    
032        /**
033         * The list of headers. Each element is a string array of two elements; 
034         * the header name and value.
035         */
036        protected List _list = new LinkedList();
037    
038        /**
039         * Protected access, headers can only be copied from 
040         * request to request.
041         */
042        protected RequestHeadersImpl() {
043        }
044    
045        /**
046         * Defined in interface
047         * @param headerName name of the header to be added
048         * @param headerValue value of the header to be added
049         * @see RequestHeaders#addHeader(String,String)
050         */
051        public void addHeader(String headerName, String headerValue) {
052            _list.add(new String[] { headerName, headerValue });
053        }
054    
055        /**
056         * Defined in interface
057         * @return a list of headers
058         * @see RequestHeaders#getHeaders()
059         */
060        public List getHeaders() {
061            return _list;
062        }
063    }