FileDocCategorySizeDatePackage
ProxyInfo.javaAPI DocAndroid 5.1 API11129Thu Mar 12 22:22:10 GMT 2015android.net

ProxyInfo

public class ProxyInfo extends Object implements android.os.Parcelable
Describes a proxy configuration. Proxy configurations are already integrated within the Apache HTTP stack. So {@link URLConnection} and {@link HttpClient} will use them automatically. Other HTTP stacks will need to obtain the proxy info from {@link Proxy#PROXY_CHANGE_ACTION} broadcast as the extra {@link Proxy#EXTRA_PROXY_INFO}.
deprecated
Please use {@link java.net.URL#openConnection}, {@link java.net.Proxy} and friends. The Apache HTTP client is no longer maintained and may be removed in a future release. Please visit this webpage for further details.

Fields Summary
private String
mHost
private int
mPort
private String
mExclusionList
private String[]
mParsedExclusionList
private Uri
mPacFileUrl
public static final String
LOCAL_EXCL_LIST
public static final int
LOCAL_PORT
public static final String
LOCAL_HOST
public static final Creator
CREATOR
Constructors Summary
public ProxyInfo(String host, int port, String exclList)
Create a ProxyProperties that points at a HTTP Proxy.

hide

        mHost = host;
        mPort = port;
        setExclusionList(exclList);
        mPacFileUrl = Uri.EMPTY;
    
public ProxyInfo(Uri pacFileUrl)
Create a ProxyProperties that points at a PAC URL.

hide

        mHost = LOCAL_HOST;
        mPort = LOCAL_PORT;
        setExclusionList(LOCAL_EXCL_LIST);
        if (pacFileUrl == null) {
            throw new NullPointerException();
        }
        mPacFileUrl = pacFileUrl;
    
public ProxyInfo(String pacFileUrl)
Create a ProxyProperties that points at a PAC URL.

hide

        mHost = LOCAL_HOST;
        mPort = LOCAL_PORT;
        setExclusionList(LOCAL_EXCL_LIST);
        mPacFileUrl = Uri.parse(pacFileUrl);
    
public ProxyInfo(Uri pacFileUrl, int localProxyPort)
Only used in PacManager after Local Proxy is bound.

hide

        mHost = LOCAL_HOST;
        mPort = localProxyPort;
        setExclusionList(LOCAL_EXCL_LIST);
        if (pacFileUrl == null) {
            throw new NullPointerException();
        }
        mPacFileUrl = pacFileUrl;
    
private ProxyInfo(String host, int port, String exclList, String[] parsedExclList)

        mHost = host;
        mPort = port;
        mExclusionList = exclList;
        mParsedExclusionList = parsedExclList;
        mPacFileUrl = Uri.EMPTY;
    
public ProxyInfo(ProxyInfo source)

hide

        if (source != null) {
            mHost = source.getHost();
            mPort = source.getPort();
            mPacFileUrl = source.mPacFileUrl;
            mExclusionList = source.getExclusionListAsString();
            mParsedExclusionList = source.mParsedExclusionList;
        } else {
            mPacFileUrl = Uri.EMPTY;
        }
    
Methods Summary
public static android.net.ProxyInfobuildDirectProxy(java.lang.String host, int port)
Constructs a {@link ProxyInfo} object that points at a Direct proxy on the specified host and port.


                          
           
        return new ProxyInfo(host, port, null);
    
public static android.net.ProxyInfobuildDirectProxy(java.lang.String host, int port, java.util.List exclList)
Constructs a {@link ProxyInfo} object that points at a Direct proxy on the specified host and port. The proxy will not be used to access any host in exclusion list, exclList.

param
exclList Hosts to exclude using the proxy on connections for. These hosts can use wildcards such as *.example.com.

        String[] array = exclList.toArray(new String[exclList.size()]);
        return new ProxyInfo(host, port, TextUtils.join(",", array), array);
    
public static android.net.ProxyInfobuildPacProxy(Uri pacUri)
Construct a {@link ProxyInfo} that will download and run the PAC script at the specified URL.

        return new ProxyInfo(pacUri);
    
public intdescribeContents()
Implement the Parcelable interface

hide

        return 0;
    
public booleanequals(java.lang.Object o)

        if (!(o instanceof ProxyInfo)) return false;
        ProxyInfo p = (ProxyInfo)o;
        // If PAC URL is present in either then they must be equal.
        // Other parameters will only be for fall back.
        if (!Uri.EMPTY.equals(mPacFileUrl)) {
            return mPacFileUrl.equals(p.getPacFileUrl()) && mPort == p.mPort;
        }
        if (!Uri.EMPTY.equals(p.mPacFileUrl)) {
            return false;
        }
        if (mExclusionList != null && !mExclusionList.equals(p.getExclusionListAsString())) {
            return false;
        }
        if (mHost != null && p.getHost() != null && mHost.equals(p.getHost()) == false) {
            return false;
        }
        if (mHost != null && p.mHost == null) return false;
        if (mHost == null && p.mHost != null) return false;
        if (mPort != p.mPort) return false;
        return true;
    
public java.lang.String[]getExclusionList()
When configured to use a Direct Proxy this returns the list of hosts for which the proxy is ignored.

        return mParsedExclusionList;
    
public java.lang.StringgetExclusionListAsString()
comma separated

hide

        return mExclusionList;
    
public java.lang.StringgetHost()
When configured to use a Direct Proxy this returns the host of the proxy.

        return mHost;
    
public UrigetPacFileUrl()
Returns the URL of the current PAC script or null if there is no PAC script.

        return mPacFileUrl;
    
public intgetPort()
When configured to use a Direct Proxy this returns the port of the proxy

        return mPort;
    
public java.net.InetSocketAddressgetSocketAddress()

hide

        InetSocketAddress inetSocketAddress = null;
        try {
            inetSocketAddress = new InetSocketAddress(mHost, mPort);
        } catch (IllegalArgumentException e) { }
        return inetSocketAddress;
    
public inthashCode()

        return ((null == mHost) ? 0 : mHost.hashCode())
        + ((null == mExclusionList) ? 0 : mExclusionList.hashCode())
        + mPort;
    
public booleanisValid()

hide

        if (!Uri.EMPTY.equals(mPacFileUrl)) return true;
        return Proxy.PROXY_VALID == Proxy.validate(mHost == null ? "" : mHost,
                                                mPort == 0 ? "" : Integer.toString(mPort),
                                                mExclusionList == null ? "" : mExclusionList);
    
public java.net.ProxymakeProxy()

hide

        java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
        if (mHost != null) {
            try {
                InetSocketAddress inetSocketAddress = new InetSocketAddress(mHost, mPort);
                proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, inetSocketAddress);
            } catch (IllegalArgumentException e) {
            }
        }
        return proxy;
    
private voidsetExclusionList(java.lang.String exclusionList)

        mExclusionList = exclusionList;
        if (mExclusionList == null) {
            mParsedExclusionList = new String[0];
        } else {
            mParsedExclusionList = exclusionList.toLowerCase(Locale.ROOT).split(",");
        }
    
public java.lang.StringtoString()

        StringBuilder sb = new StringBuilder();
        if (!Uri.EMPTY.equals(mPacFileUrl)) {
            sb.append("PAC Script: ");
            sb.append(mPacFileUrl);
        }
        if (mHost != null) {
            sb.append("[");
            sb.append(mHost);
            sb.append("] ");
            sb.append(Integer.toString(mPort));
            if (mExclusionList != null) {
                    sb.append(" xl=").append(mExclusionList);
            }
        } else {
            sb.append("[ProxyProperties.mHost == null]");
        }
        return sb.toString();
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface.

hide

        if (!Uri.EMPTY.equals(mPacFileUrl)) {
            dest.writeByte((byte)1);
            mPacFileUrl.writeToParcel(dest, 0);
            dest.writeInt(mPort);
            return;
        } else {
            dest.writeByte((byte)0);
        }
        if (mHost != null) {
            dest.writeByte((byte)1);
            dest.writeString(mHost);
            dest.writeInt(mPort);
        } else {
            dest.writeByte((byte)0);
        }
        dest.writeString(mExclusionList);
        dest.writeStringArray(mParsedExclusionList);