001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.transport.http;
021:
022: import org.apache.commons.httpclient.Header;
023:
024: import java.util.Collection;
025: import java.util.HashMap;
026: import java.util.Map;
027: import java.util.Set;
028:
029: public class CommonsTransportHeaders implements Map {
030: private Header[] headers;
031:
032: HashMap headerMap = null;
033:
034: public CommonsTransportHeaders(Header[] headers) {
035: this .headers = headers;
036: }
037:
038: private void init() {
039: headerMap = new HashMap();
040:
041: for (int i = 0; i < headers.length; i++) {
042: headerMap.put(headers[i].getName(), headers[i].getValue());
043: }
044: }
045:
046: public int size() {
047: if (headerMap == null) {
048: init();
049: }
050: return headerMap.size();
051: }
052:
053: public void clear() {
054: if (headerMap != null) {
055: headerMap.clear();
056: }
057: }
058:
059: public boolean isEmpty() {
060: if (headerMap == null) {
061: init();
062: }
063: return headerMap.isEmpty();
064: }
065:
066: public boolean containsKey(Object key) {
067: if (headerMap == null) {
068: init();
069: }
070: return headerMap.containsKey(key);
071: }
072:
073: public boolean containsValue(Object value) {
074: if (headerMap == null) {
075: init();
076: }
077: return headerMap.containsValue(value);
078: }
079:
080: public Collection values() {
081: if (headerMap == null) {
082: init();
083: }
084: return headerMap.values();
085: }
086:
087: public void putAll(Map t) {
088: if (headerMap == null) {
089: init();
090: }
091: headerMap.putAll(t);
092: }
093:
094: public Set entrySet() {
095: if (headerMap == null) {
096: init();
097: }
098: return headerMap.entrySet();
099: }
100:
101: public Set keySet() {
102: if (headerMap == null) {
103: init();
104: }
105: return headerMap.keySet();
106: }
107:
108: public Object get(Object key) {
109: if (headerMap == null) {
110: init();
111: }
112: return headerMap.get(key);
113: }
114:
115: public Object remove(Object key) {
116: if (headerMap == null) {
117: init();
118: }
119: return headerMap.remove(key);
120: }
121:
122: public Object put(Object key, Object value) {
123: if (headerMap == null) {
124: init();
125: }
126: return headerMap.put(key, value);
127: }
128: }
|