View Javadoc

1   /*
2    * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/oac.hc3x/trunk/src/java/org/apache/commons/httpclient/params/HostParams.java $
3    * $Revision$
4    * $Date$
5    *
6    * ====================================================================
7    *
8    *  Licensed to the Apache Software Foundation (ASF) under one or more
9    *  contributor license agreements.  See the NOTICE file distributed with
10   *  this work for additional information regarding copyright ownership.
11   *  The ASF licenses this file to You under the Apache License, Version 2.0
12   *  (the "License"); you may not use this file except in compliance with
13   *  the License.  You may obtain a copy of the License at
14   *
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   *
17   *  Unless required by applicable law or agreed to in writing, software
18   *  distributed under the License is distributed on an "AS IS" BASIS,
19   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   *  See the License for the specific language governing permissions and
21   *  limitations under the License.
22   * ====================================================================
23   *
24   * This software consists of voluntary contributions made by many
25   * individuals on behalf of the Apache Software Foundation.  For more
26   * information on the Apache Software Foundation, please see
27   * <http://www.apache.org/>.
28   *
29   */
30  
31  package org.apache.commons.httpclient.params;
32  
33  /***
34   * This class represents a collection of HTTP protocol parameters applicable to 
35   * {@link org.apache.commons.httpclient.HostConfiguration instances of HostConfiguration}. 
36   * Protocol parameters may be linked together to form a hierarchy. If a particular 
37   * parameter value has not been explicitly defined in the collection itself, its 
38   * value will be drawn from the parent collection of parameters.
39   * 
40   * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
41   * 
42   * @version $Revision$
43   * 
44   * @since 3.0
45   */
46  public class HostParams extends DefaultHttpParams {
47  
48      /***
49       * Defines the request headers to be sent per default with each request.
50       * <p>
51       * This parameter expects a value of type {@link java.util.Collection}. The 
52       * collection is expected to contain {@link org.apache.commons.httpclient.Header}s. 
53       * </p>
54       */
55      public static final String DEFAULT_HEADERS = "http.default-headers"; 
56  
57      /***
58       * Creates a new collection of parameters with the collection returned
59       * by {@link #getDefaultParams()} as a parent. The collection will defer
60       * to its parent for a default value if a particular parameter is not 
61       * explicitly set in the collection itself.
62       * 
63       * @see #getDefaultParams()
64       */
65      public HostParams() {
66          super();
67      }
68  
69      /***
70       * Creates a new collection of parameters with the given parent. 
71       * The collection will defer to its parent for a default value 
72       * if a particular parameter is not explicitly set in the collection
73       * itself.
74       * 
75       * @param defaults the parent collection to defer to, if a parameter
76       * is not explictly set in the collection itself.
77       *
78       * @see #getDefaultParams()
79       */
80      public HostParams(HttpParams defaults) {
81          super(defaults);
82      }
83      
84      /***
85       * Sets the virtual host name.
86       * 
87       * @param hostname The host name
88       */
89      public void setVirtualHost(final String hostname) {
90          setParameter(HttpMethodParams.VIRTUAL_HOST, hostname);
91      }
92  
93      /***
94       * Returns the virtual host name.
95       * 
96       * @return The virtual host name
97       */
98      public String getVirtualHost() {
99          return (String) getParameter(HttpMethodParams.VIRTUAL_HOST);
100     }
101         
102 }