/*
 * 
 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * The contents of this file are subject to the Sun Community Source
 * License v3.0/Jini Technology Specific Attachment v 1.0 (the
 * "License"). You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 * http://wwws.sun.com/software/jini/licensing/SCSL3_JiniTSA1.html.
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Reference Code is Jini Technology Core Platform code, v2.0. The
 * Developer of the Reference Code is Sun Microsystems, Inc.
 * 
 * Contributor(s): Sun Microsystems, Inc.
 * 
 * The contents of this file comply with the Jini Technology Core
 * Platform Compatibility Kit, v2.0A.
 * 
 * Tester(s): Sun Microsystems, Inc.
 * 
 * Test Platform(s):
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Solaris(TM)SPARC/x86
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Linux (Intel x86)
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Windows (Intel Platform)
 * 
 */

package net.jini.url.httpmd;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.security.Permission;
import java.util.Map;

/**
 * An HTTP URL connection that delegates all operations defined by
 * HttpURLConnection and URLConnection.
 *
 * @author Sun Microsystems, Inc.
 * 
 */
class DelegatingHttpURLConnection extends HttpURLConnection {
    
    /** The HTTP URL connection to which operations should be delegated. */
    HttpURLConnection delegateConnection;

    /**
     * Creates an HttpURLConnection for the specified URL that delegates all
     * operations to the value of the delegateConnection field, which should be
     * set separately.
     */
    DelegatingHttpURLConnection(URL url) {
	super(url);
    }

    /* -- HttpURLConnection methods -- */

    public void setInstanceFollowRedirects(boolean followRedirects) {
	delegateConnection.setInstanceFollowRedirects(followRedirects);
    }

    public boolean getInstanceFollowRedirects() {
	return delegateConnection.getInstanceFollowRedirects();
    }

    public void setRequestMethod(String method) throws ProtocolException {
	delegateConnection.setRequestMethod(method);
    }

    public String getRequestMethod() {
	return delegateConnection.getRequestMethod();
    }
    
    public int getResponseCode() throws IOException {
	return delegateConnection.getResponseCode();
    }

    public String getResponseMessage() throws IOException {
	return delegateConnection.getResponseMessage();
    }

    public void disconnect() {
	delegateConnection.disconnect();
    }

    public boolean usingProxy() {
	return delegateConnection.usingProxy();
    }

    public InputStream getErrorStream() {
	return delegateConnection.getErrorStream();
    }

    /* -- URLConnection methods -- */

    public void connect() throws IOException {
	delegateConnection.connect();
    }

    public URL getURL() {
	return delegateConnection.getURL();
    }

    public int getContentLength() {
	return delegateConnection.getContentLength();
    }

    public String getContentType() {
	return delegateConnection.getContentType();
    }

    public String getContentEncoding() {
	return delegateConnection.getContentEncoding();
    }

    public long getExpiration() {
	return delegateConnection.getExpiration();
    }

    public long getDate() {
	return delegateConnection.getDate();
    }

    public long getLastModified() {
	return delegateConnection.getLastModified();
    }

    public String getHeaderField(String name) {
	return delegateConnection.getHeaderField(name);
    }

    public Map getHeaderFields() {
	return delegateConnection.getHeaderFields();
    }

    public int getHeaderFieldInt(String name, int Default) {
	return delegateConnection.getHeaderFieldInt(name, Default);
    }

    public long getHeaderFieldDate(String name, long Default) {
	return delegateConnection.getHeaderFieldDate(name, Default);
    }

    public String getHeaderFieldKey(int n) {
	return delegateConnection.getHeaderFieldKey(n);
    }

    public String getHeaderField(int n) {
	return delegateConnection.getHeaderField(n);
    }

    public Object getContent() throws IOException {
	return delegateConnection.getContent();
    }

    public Object getContent(Class[] classes) throws IOException {
	return delegateConnection.getContent(classes);
    }

    public Permission getPermission() throws IOException {
	return delegateConnection.getPermission();
    }

    public InputStream getInputStream() throws IOException {
	return delegateConnection.getInputStream();
    }

    public OutputStream getOutputStream() throws IOException {
	return delegateConnection.getOutputStream();
    }

    public void setDoInput(boolean doinput) {
	delegateConnection.setDoInput(doinput);
    }

    public boolean getDoInput() {
	return delegateConnection.getDoInput();
    }

    public void setDoOutput(boolean dooutput) {
	delegateConnection.setDoOutput(dooutput);
    }

    public boolean getDoOutput() {
	return delegateConnection.getDoOutput();
    }

    public void setAllowUserInteraction(boolean allowuserinteraction) {
	delegateConnection.setAllowUserInteraction(allowuserinteraction);
    }

    public boolean getAllowUserInteraction() {
	return delegateConnection.getAllowUserInteraction();
    }

    public void setUseCaches(boolean usecaches) {
	delegateConnection.setUseCaches(usecaches);
    }

    public boolean getUseCaches() {
	return delegateConnection.getUseCaches();
    }

    public void setIfModifiedSince(long ifmodifiedsince) {
	delegateConnection.setIfModifiedSince(ifmodifiedsince);
    }

    public long getIfModifiedSince() {
	return delegateConnection.getIfModifiedSince();
    }

    public boolean getDefaultUseCaches() {
	return delegateConnection.getDefaultUseCaches();
    }

    public void setDefaultUseCaches(boolean defaultusecaches) {
	delegateConnection.setDefaultUseCaches(defaultusecaches);
    }

    public void setRequestProperty(String key, String value) {
	delegateConnection.setRequestProperty(key, value);
    }

    public void addRequestProperty(String key, String value) {
	delegateConnection.addRequestProperty(key, value);
    }

    public String getRequestProperty(String key) {
	return delegateConnection.getRequestProperty(key);
    }

    public Map getRequestProperties() {
	return delegateConnection.getRequestProperties();
    }
}
    
