Proxy
Stay organized with collections
Save and categorize content based on your preferences.
This class represents a proxy setting, typically a type (http, socks) and
a socket address.
A Proxy
is an immutable object.
Field Summary
public
static
final
Proxy |
NO_PROXY |
A proxy setting that represents a DIRECT connection,
basically telling the protocol handler not to use any proxying. |
Public Constructor Summary
Public Method Summary
SocketAddress
|
address()
Returns the socket address of the proxy, or
null if its a direct connection.
|
final
boolean
|
equals( Object obj)
Compares this object against the specified object.
|
final
int
|
hashCode()
Returns a hashcode for this Proxy.
|
String
|
toString()
Constructs a string representation of this Proxy.
|
Proxy.Type
|
type()
Returns the proxy type.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Fields
public
static
final
Proxy
NO_PROXY
A proxy setting that represents a DIRECT
connection,
basically telling the protocol handler not to use any proxying.
Used, for instance, to create sockets bypassing any other global
proxy settings (like SOCKS):
Socket s = new Socket(Proxy.NO_PROXY);
Public Constructors
Creates an entry representing a PROXY connection.
Certain combinations are illegal. For instance, for types Http, and
Socks, a SocketAddress must be provided.
Use the Proxy.NO_PROXY
constant
for representing a direct connection.
Parameters
type |
the Type of the proxy |
sa |
the SocketAddress for that proxy |
Public Methods
Returns the socket address of the proxy, or
null
if its a direct connection.
Returns
- a
SocketAddress
representing the socket end
point of the proxy
public
final
boolean
equals
(Object obj)
Compares this object against the specified object.
The result is true
if and only if the argument is
not null
and it represents the same proxy as
this object.
Two instances of Proxy
represent the same
address if both the SocketAddresses and type are equal.
Parameters
obj |
the object to compare against. |
Returns
true
if the objects are the same;
false
otherwise.
public
final
int
hashCode
()
Returns a hashcode for this Proxy.
Returns
- a hash code value for this Proxy.
public
String
toString
()
Constructs a string representation of this Proxy.
This String is constructed by calling toString() on its type
and concatenating " @ " and the toString() result from its address
if its type is not DIRECT
.
Returns
- a string representation of this object.
Returns
- a Type representing the proxy type
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eProxy\u003c/code\u003e class represents a proxy setting, typically a type (http, socks) and a socket address, and is immutable.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eProxy.NO_PROXY\u003c/code\u003e represents a direct connection, instructing the protocol handler to bypass proxying.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eProxy\u003c/code\u003e instance is created using a \u003ccode\u003eProxy.Type\u003c/code\u003e and a \u003ccode\u003eSocketAddress\u003c/code\u003e, with specific types requiring a valid address.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003eaddress()\u003c/code\u003e, \u003ccode\u003etype()\u003c/code\u003e, \u003ccode\u003eequals()\u003c/code\u003e, \u003ccode\u003ehashCode()\u003c/code\u003e, and \u003ccode\u003etoString()\u003c/code\u003e provide information and functionality related to the proxy settings.\u003c/p\u003e\n"],["\u003cp\u003eDirect connections can be established using \u003ccode\u003eProxy.NO_PROXY\u003c/code\u003e to circumvent global proxy settings.\u003c/p\u003e\n"]]],["The `Proxy` class represents a proxy setting with a type (e.g., HTTP, SOCKS) and a socket address. It's immutable and can be created using its constructor, providing a `Proxy.Type` and `SocketAddress`. Key actions include retrieving the proxy's socket address, checking for equality with another proxy object, generating a hash code, getting a string representation of the object and checking the proxy type. `NO_PROXY` indicates a direct connection without proxying.\n"],null,[]]