View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.hc.core5.http.message;
29  
30  import java.util.Iterator;
31  
32  import org.apache.hc.core5.http.Header;
33  import org.apache.hc.core5.http.HttpMessage;
34  import org.apache.hc.core5.http.ProtocolException;
35  import org.apache.hc.core5.http.ProtocolVersion;
36  import org.apache.hc.core5.util.Args;
37  
38  /**
39   * Abstract {@link HttpMessage} wrapper.
40   */
41  public abstract class AbstractMessageWrapper implements HttpMessage {
42  
43      private final HttpMessage message;
44  
45      public AbstractMessageWrapper(final HttpMessage message) {
46          this.message = Args.notNull(message, "Message");
47      }
48  
49      @Override
50      public void setVersion(final ProtocolVersion version) {
51          message.setVersion(version);
52      }
53  
54      @Override
55      public ProtocolVersion getVersion() {
56          return message.getVersion();
57      }
58  
59      @Override
60      public void addHeader(final Header header) {
61          message.addHeader(header);
62      }
63  
64      @Override
65      public void addHeader(final String name, final Object value) {
66          message.addHeader(name, value);
67      }
68  
69      @Override
70      public void setHeader(final Header header) {
71          message.setHeader(header);
72      }
73  
74      @Override
75      public void setHeader(final String name, final Object value) {
76          message.setHeader(name, value);
77      }
78  
79      @Override
80      public void setHeaders(final Header... headers) {
81          message.setHeaders(headers);
82      }
83  
84      @Override
85      public boolean removeHeader(final Header header) {
86          return message.removeHeader(header);
87      }
88  
89      @Override
90      public boolean removeHeaders(final String name) {
91          return message.removeHeaders(name);
92      }
93  
94      @Override
95      public boolean containsHeader(final String name) {
96          return message.containsHeader(name);
97      }
98  
99      @Override
100     public int containsHeaders(final String name) {
101         return message.containsHeaders(name);
102     }
103 
104     @Override
105     public Header[] getHeaders(final String name) {
106         return message.getHeaders(name);
107     }
108 
109     @Override
110     public Header getSingleHeader(final String name) throws ProtocolException {
111         return message.getSingleHeader(name);
112     }
113 
114     @Override
115     public Header getFirstHeader(final String name) {
116         return message.getFirstHeader(name);
117     }
118 
119     @Override
120     public Header getLastHeader(final String name) {
121         return message.getLastHeader(name);
122     }
123 
124     @Override
125     public Header[] getAllHeaders() {
126         return message.getAllHeaders();
127     }
128 
129     @Override
130     public Iterator<Header> headerIterator() {
131         return message.headerIterator();
132     }
133 
134     @Override
135     public Iterator<Header> headerIterator(final String name) {
136         return message.headerIterator(name);
137     }
138 
139     @Override
140     public String toString() {
141         return message.toString();
142     }
143 
144 }