|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.Endpoint
Immutable IP/port pair. Also contains an optional number and size of files, mainly for legacy reasons.
Field Summary | |
boolean |
processed
Needed for Network Discovery. |
Constructor Summary | |
Endpoint(byte[] hostBytes,
int port)
Creates a new Endpoint instance |
|
Endpoint(byte[] hostBytes,
int port,
long files,
long kbytes)
Creates a new Endpoint instance |
|
Endpoint(Endpoint ep)
Constructs a new endpoint from pre-existing endpoint by copying the fields |
|
Endpoint(java.lang.String hostAndPort)
Returns a new Endpoint from a Gnutella-style host/port pair: If hostAndPort is of the format "host:port", where port is a number, returns new Endpoint(host, port). |
|
Endpoint(java.lang.String hostAndPort,
boolean requireNumeric)
Same as new Endpoint(hostAndPort) but with additional restrictions on hostAndPart; if requireNumeric==true and the host part of hostAndPort is not as a numeric dotted-quad IP address, throws IllegalArgumentException. |
|
Endpoint(java.lang.String hostname,
int port)
|
|
Endpoint(java.lang.String hostname,
int port,
long files,
long kbytes)
|
Method Summary | |
protected java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object o)
The comparison function (It uses the connectivity as the measure for comparison ie if a.connectivity > b.connectivity then a.compareTo(b) > 0 |
boolean |
equals(java.lang.Object o)
Endpoints are equal if their hostnames and ports are. |
int |
getConnectivity()
returns the connectivity of the node |
long |
getFiles()
Returns the number of files the host has, or -1 if I don't know |
byte[] |
getHostBytes()
This method returns the IP of the end point as an array of bytes |
java.lang.String |
getHostname()
|
long |
getKbytes()
Returns the size of all files the host has, in kilobytes, or -1 if I don't know, it also makes sure that the kbytes/files ratio is not ridiculous, in which case it normalizes the values |
int |
getPort()
|
int |
getWeight()
Gets the weight of this endpoint |
int |
hashCode()
|
boolean |
isPrivateAddress()
|
boolean |
isSameSubnet(Endpoint other)
|
void |
normalizeFilesAndSize()
If the number of files or the kbytes exceed certain limit, it considers them as false data, and initializes the number of files as well as kbytes to zero in that case |
void |
setConnectivity(int connectivity)
Sets the connectivity of the node |
void |
setFiles(long files)
Sets the number of files the host has |
void |
setHostname(java.lang.String hostname)
|
void |
setKbytes(long kbytes)
Sets the size of all files the host has, in kilobytes, |
void |
setWeight(int weight)
Sets the weight of the node |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public transient boolean processed
Constructor Detail |
public Endpoint(java.lang.String hostAndPort) throws java.lang.IllegalArgumentException
public Endpoint(java.lang.String hostAndPort, boolean requireNumeric) throws java.lang.IllegalArgumentException
new Endpoint("www.limewire.org:6346", false) ==> ok new Endpoint("not a url:6346", false) ==> ok new Endpoint("www.limewire.org:6346", true) ==> IllegalArgumentException new Endpoint("64.61.25.172:6346", true) ==> ok new Endpoint("64.61.25.172", true) ==> ok new Endpoint("127.0.0.1:ABC", false) ==> IllegalArgumentExceptionNo DNS lookups are ever involved, so this constructor won't block.
(String))
public Endpoint(java.lang.String hostname, int port)
public Endpoint(byte[] hostBytes, int port)
hostBytes
- IP address of the host (MSB first)port
- The port number for the hostpublic Endpoint(java.lang.String hostname, int port, long files, long kbytes)
files
- the number of files the host haskbytes
- the size of all of the files, in kilobytespublic Endpoint(byte[] hostBytes, int port, long files, long kbytes)
hostBytes
- IP address of the host (MSB first)port
- The port number for the hostfiles
- the number of files the host haskbytes
- the size of all of the files, in kilobytespublic Endpoint(Endpoint ep)
ep
- The endpoint from whom to initialize the member fields of
this new endpointMethod Detail |
public void setConnectivity(int connectivity)
connectivity
- the connectivity to be setpublic void setWeight(int weight)
weight
- the weight to be setpublic int getWeight()
public int getConnectivity()
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- the other object to be compared topublic java.lang.String toString()
public java.lang.String getHostname()
public void setHostname(java.lang.String hostname)
public int getPort()
public long getFiles()
public void setFiles(long files)
public long getKbytes()
public void normalizeFilesAndSize()
public void setKbytes(long kbytes)
public boolean equals(java.lang.Object o)
public int hashCode()
protected java.lang.Object clone()
public byte[] getHostBytes() throws java.net.UnknownHostException
java.net.UnknownHostException
public boolean isPrivateAddress()
public boolean isSameSubnet(Endpoint other)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |