mobile/android/thirdparty/ch/boye/httpclientandroidlib/entity/HttpEntityWrapper.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     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  */
    28 package ch.boye.httpclientandroidlib.entity;
    30 import java.io.IOException;
    31 import java.io.InputStream;
    32 import java.io.OutputStream;
    34 import ch.boye.httpclientandroidlib.Header;
    35 import ch.boye.httpclientandroidlib.HttpEntity;
    37 /**
    38  * Base class for wrapping entities.
    39  * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all
    40  * calls to it. Implementations of wrapping entities can derive
    41  * from this class and need to override only those methods that
    42  * should not be delegated to the wrapped entity.
    43  *
    44  * @since 4.0
    45  */
    46 public class HttpEntityWrapper implements HttpEntity {
    48     /** The wrapped entity. */
    49     protected HttpEntity wrappedEntity;
    51     /**
    52      * Creates a new entity wrapper.
    53      *
    54      * @param wrapped   the entity to wrap, not null
    55      * @throws IllegalArgumentException if wrapped is null
    56      */
    57     public HttpEntityWrapper(HttpEntity wrapped) {
    58         super();
    60         if (wrapped == null) {
    61             throw new IllegalArgumentException
    62                 ("wrapped entity must not be null");
    63         }
    64         wrappedEntity = wrapped;
    66     } // constructor
    69     public boolean isRepeatable() {
    70         return wrappedEntity.isRepeatable();
    71     }
    73     public boolean isChunked() {
    74         return wrappedEntity.isChunked();
    75     }
    77     public long getContentLength() {
    78         return wrappedEntity.getContentLength();
    79     }
    81     public Header getContentType() {
    82         return wrappedEntity.getContentType();
    83     }
    85     public Header getContentEncoding() {
    86         return wrappedEntity.getContentEncoding();
    87     }
    89     public InputStream getContent()
    90         throws IOException {
    91         return wrappedEntity.getContent();
    92     }
    94     public void writeTo(OutputStream outstream)
    95         throws IOException {
    96         wrappedEntity.writeTo(outstream);
    97     }
    99     public boolean isStreaming() {
   100         return wrappedEntity.isStreaming();
   101     }
   103     /**
   104      * @deprecated Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
   105      * otherwise call {@link #writeTo(OutputStream)} which is required to free the resources.
   106      */
   107     public void consumeContent() throws IOException {
   108         wrappedEntity.consumeContent();
   109     }
   111 }

mercurial