001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/entity/HttpEntityWrapper.java $
003: * $Revision: 496070 $
004: * $Date: 2007-01-14 13:18:34 +0100 (Sun, 14 Jan 2007) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http.entity;
033:
034: import java.io.IOException;
035: import java.io.InputStream;
036: import java.io.OutputStream;
037:
038: import org.apache.http.Header;
039: import org.apache.http.HttpEntity;
040:
041: /**
042: * Base class for wrapping entities.
043: * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all
044: * calls to it. Implementations of wrapping entities can derive
045: * from this class and need to override only those methods that
046: * should not be delegated to the wrapped entity.
047: *
048: * @version $Revision: 496070 $
049: *
050: * @since 4.0
051: */
052: public class HttpEntityWrapper implements HttpEntity {
053:
054: /** The wrapped entity. */
055: protected HttpEntity wrappedEntity;
056:
057: /**
058: * Creates a new entity wrapper.
059: *
060: * @param wrapped the entity to wrap
061: */
062: public HttpEntityWrapper(HttpEntity wrapped) {
063: super ();
064:
065: if (wrapped == null) {
066: throw new IllegalArgumentException(
067: "wrapped entity must not be null");
068: }
069: wrappedEntity = wrapped;
070:
071: } // constructor
072:
073: public boolean isRepeatable() {
074: return wrappedEntity.isRepeatable();
075: }
076:
077: public boolean isChunked() {
078: return wrappedEntity.isChunked();
079: }
080:
081: public long getContentLength() {
082: return wrappedEntity.getContentLength();
083: }
084:
085: public Header getContentType() {
086: return wrappedEntity.getContentType();
087: }
088:
089: public Header getContentEncoding() {
090: return wrappedEntity.getContentEncoding();
091: }
092:
093: public InputStream getContent() throws IOException {
094: return wrappedEntity.getContent();
095: }
096:
097: public void writeTo(OutputStream outstream) throws IOException {
098: wrappedEntity.writeTo(outstream);
099: }
100:
101: public boolean isStreaming() {
102: return wrappedEntity.isStreaming();
103: }
104:
105: public void consumeContent() throws IOException {
106: wrappedEntity.consumeContent();
107: }
108:
109: } // class HttpEntityWrapper
|