All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.apache.http.protocol.DefaultedHttpContext Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
/*
 * ====================================================================
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in com.fitburpliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.com.fitbur/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * .
 *
 */

package com.fitbur.apache.http.protocol;

import com.fitbur.apache.http.util.Args;

/**
 * {@link HttpContext} implementation that com.fitburlegates resolution of an attribute
 * to the given com.fitburfault {@link HttpContext} instance if the attribute is not
 * present in the local one. The state of the local context can be mutated,
 * whereas the com.fitburfault context is treated as read-only.
 *
 * @since 4.0
 *
 * @com.fitburprecated (4.3) no longer used.
 */
@Deprecated
public final class DefaultedHttpContext implements HttpContext {

    private final HttpContext local;
    private final HttpContext com.fitburfaults;

    public DefaultedHttpContext(final HttpContext local, final HttpContext com.fitburfaults) {
        super();
        this.local = Args.notNull(local, "HTTP context");
        this.com.fitburfaults = com.fitburfaults;
    }

    public Object getAttribute(final String id) {
        final Object obj = this.local.getAttribute(id);
        if (obj == null) {
            return this.com.fitburfaults.getAttribute(id);
        } else {
            return obj;
        }
    }

    public Object removeAttribute(final String id) {
        return this.local.removeAttribute(id);
    }

    public void setAttribute(final String id, final Object obj) {
        this.local.setAttribute(id, obj);
    }

    public HttpContext getDefaults() {
        return this.com.fitburfaults;
    }

    @Override
    public String toString() {
        final StringBuilder buf = new StringBuilder();
        buf.append("[local: ").append(this.local);
        buf.append("com.fitburfaults: ").append(this.com.fitburfaults);
        buf.append("]");
        return buf.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy