1 /* 2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/HttpEntityWrapper.java $ 3 * $Revision: 496070 $ 4 * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $ 5 * 6 * ==================================================================== 7 * Licensed to the Apache Software Foundation (ASF) under one 8 * or more contributor license agreements. See the NOTICE file 9 * distributed with this work for additional information 10 * regarding copyright ownership. The ASF licenses this file 11 * to you under the Apache License, Version 2.0 (the 12 * "License"); you may not use this file except in compliance 13 * with 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, 18 * software distributed under the License is distributed on an 19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 * KIND, either express or implied. See the License for the 21 * specific language governing permissions and limitations 22 * under the License. 23 * ==================================================================== 24 * 25 * This software consists of voluntary contributions made by many 26 * individuals on behalf of the Apache Software Foundation. For more 27 * information on the Apache Software Foundation, please see 28 * <http://www.apache.org/>. 29 * 30 */ 31 32 package org.apache.http.entity; 33 34 import java.io.IOException; 35 import java.io.InputStream; 36 import java.io.OutputStream; 37 38 import org.apache.http.Header; 39 import org.apache.http.HttpEntity; 40 41 /** 42 * Base class for wrapping entities. 43 * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all 44 * calls to it. Implementations of wrapping entities can derive 45 * from this class and need to override only those methods that 46 * should not be delegated to the wrapped entity. 47 * 48 * @version $Revision: 496070 $ 49 * 50 * @since 4.0 51 * 52 * @deprecated Please use {@link java.net.URL#openConnection} instead. 53 * Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a> 54 * for further details. 55 */ 56 @Deprecated 57 public class HttpEntityWrapper implements HttpEntity { 58 59 /** The wrapped entity. */ 60 protected HttpEntity wrappedEntity; 61 62 /** 63 * Creates a new entity wrapper. 64 * 65 * @param wrapped the entity to wrap 66 */ HttpEntityWrapper(HttpEntity wrapped)67 public HttpEntityWrapper(HttpEntity wrapped) { 68 super(); 69 70 if (wrapped == null) { 71 throw new IllegalArgumentException 72 ("wrapped entity must not be null"); 73 } 74 wrappedEntity = wrapped; 75 76 } // constructor 77 78 isRepeatable()79 public boolean isRepeatable() { 80 return wrappedEntity.isRepeatable(); 81 } 82 isChunked()83 public boolean isChunked() { 84 return wrappedEntity.isChunked(); 85 } 86 getContentLength()87 public long getContentLength() { 88 return wrappedEntity.getContentLength(); 89 } 90 getContentType()91 public Header getContentType() { 92 return wrappedEntity.getContentType(); 93 } 94 getContentEncoding()95 public Header getContentEncoding() { 96 return wrappedEntity.getContentEncoding(); 97 } 98 getContent()99 public InputStream getContent() 100 throws IOException { 101 return wrappedEntity.getContent(); 102 } 103 writeTo(OutputStream outstream)104 public void writeTo(OutputStream outstream) 105 throws IOException { 106 wrappedEntity.writeTo(outstream); 107 } 108 isStreaming()109 public boolean isStreaming() { 110 return wrappedEntity.isStreaming(); 111 } 112 consumeContent()113 public void consumeContent() 114 throws IOException { 115 wrappedEntity.consumeContent(); 116 } 117 118 } // class HttpEntityWrapper 119