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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/entity/HttpEntityWrapper.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib.entity;
    1.32 +
    1.33 +import java.io.IOException;
    1.34 +import java.io.InputStream;
    1.35 +import java.io.OutputStream;
    1.36 +
    1.37 +import ch.boye.httpclientandroidlib.Header;
    1.38 +import ch.boye.httpclientandroidlib.HttpEntity;
    1.39 +
    1.40 +/**
    1.41 + * Base class for wrapping entities.
    1.42 + * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all
    1.43 + * calls to it. Implementations of wrapping entities can derive
    1.44 + * from this class and need to override only those methods that
    1.45 + * should not be delegated to the wrapped entity.
    1.46 + *
    1.47 + * @since 4.0
    1.48 + */
    1.49 +public class HttpEntityWrapper implements HttpEntity {
    1.50 +
    1.51 +    /** The wrapped entity. */
    1.52 +    protected HttpEntity wrappedEntity;
    1.53 +
    1.54 +    /**
    1.55 +     * Creates a new entity wrapper.
    1.56 +     *
    1.57 +     * @param wrapped   the entity to wrap, not null
    1.58 +     * @throws IllegalArgumentException if wrapped is null
    1.59 +     */
    1.60 +    public HttpEntityWrapper(HttpEntity wrapped) {
    1.61 +        super();
    1.62 +
    1.63 +        if (wrapped == null) {
    1.64 +            throw new IllegalArgumentException
    1.65 +                ("wrapped entity must not be null");
    1.66 +        }
    1.67 +        wrappedEntity = wrapped;
    1.68 +
    1.69 +    } // constructor
    1.70 +
    1.71 +
    1.72 +    public boolean isRepeatable() {
    1.73 +        return wrappedEntity.isRepeatable();
    1.74 +    }
    1.75 +
    1.76 +    public boolean isChunked() {
    1.77 +        return wrappedEntity.isChunked();
    1.78 +    }
    1.79 +
    1.80 +    public long getContentLength() {
    1.81 +        return wrappedEntity.getContentLength();
    1.82 +    }
    1.83 +
    1.84 +    public Header getContentType() {
    1.85 +        return wrappedEntity.getContentType();
    1.86 +    }
    1.87 +
    1.88 +    public Header getContentEncoding() {
    1.89 +        return wrappedEntity.getContentEncoding();
    1.90 +    }
    1.91 +
    1.92 +    public InputStream getContent()
    1.93 +        throws IOException {
    1.94 +        return wrappedEntity.getContent();
    1.95 +    }
    1.96 +
    1.97 +    public void writeTo(OutputStream outstream)
    1.98 +        throws IOException {
    1.99 +        wrappedEntity.writeTo(outstream);
   1.100 +    }
   1.101 +
   1.102 +    public boolean isStreaming() {
   1.103 +        return wrappedEntity.isStreaming();
   1.104 +    }
   1.105 +
   1.106 +    /**
   1.107 +     * @deprecated Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
   1.108 +     * otherwise call {@link #writeTo(OutputStream)} which is required to free the resources.
   1.109 +     */
   1.110 +    public void consumeContent() throws IOException {
   1.111 +        wrappedEntity.consumeContent();
   1.112 +    }
   1.113 +
   1.114 +}

mercurial