|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.altlocs.AlternateLocation
This class encapsulates the data for an alternate resource location, as specified in HUGE v0.93. This also provides utility methods for such operations as comparing alternate locations based on the date they were stored.
Field Summary | |
static java.lang.String |
ALT_VENDOR
The vendor to use. |
Method Summary | |
int |
compareTo(java.lang.Object obj)
The idea is that this is smaller than any AlternateLocation who has a greater value of _count. |
static AlternateLocation |
create(RemoteFileDesc rfd)
Creates a new AlternateLocation for the data stored in a RemoteFileDesc. |
static AlternateLocation |
create(java.lang.String location)
Constructs a new AlternateLocation instance based on the specified string argument. |
static AlternateLocation |
create(java.lang.String location,
URN urn)
Constructs a new AlternateLocation instance based on the specified string argument and URN. |
static AlternateLocation |
create(java.net.URL url)
Creates a new AlternateLocation instance for the given URL instance. |
static AlternateLocation |
create(URN urn)
Creates a new AlternateLocation for a file stored locally with the specified URN. |
AlternateLocation |
createClone()
could return null |
RemoteFileDesc |
createRemoteFileDesc(int size)
Creates a new RemoteFileDesc from this AlternateLocation |
boolean |
equals(java.lang.Object obj)
Overrides the equals method to accurately compare AlternateLocation instances. |
int |
getCount()
Accessor to find if this has been demoted |
boolean |
getDemoted()
package access, accessor to the value of _demoted |
Endpoint |
getHost()
Returns the host/port of this alternate location as an endpoint. |
URN |
getSHA1Urn()
Accessor for the SHA1 urn for this AlternateLocation. |
java.net.URL |
getUrl()
Returns an instance of the URL instance for this alternate location. |
int |
hashCode()
Overrides the hashCode method of Object to meet the contract of hashCode. |
java.lang.String |
httpStringValue()
Returns a string representation of the HTTP header value for this class. |
void |
increment()
increment the count. |
void |
setOld()
to set this._old to true, meaning that this is a location from the old mesh. |
java.lang.String |
toString()
Overrides toString to return a string representation of this AlternateLocation, namely the url and the date. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String ALT_VENDOR
Method Detail |
public static AlternateLocation create(java.lang.String location) throws java.io.IOException
location
- a string containing a single alternate location,
including a full URL for a file and an optional date
IOException
- if there is any problem constructing
the new instance from the specified string, or if the
argument is either null or the empty string -- we could (should?)
throw NullPointerException here, but since we're already forcing the
caller to catch IOException, we might as well throw in in both cases
java.io.IOException
public static AlternateLocation create(java.lang.String location, URN urn) throws java.io.IOException
location
- a string containing one of the following:
"http://my.address.com:port#/uri-res/N2R?urn:sha:SHA1LETTERS"
"1.2.3.4[:6346]"
If the first is given, then the SHA1 in the string MUST match
the SHA1 given.
IOException
- if there is any problem constructing
the new instance.
java.io.IOException
public static AlternateLocation create(java.net.URL url) throws java.net.MalformedURLException, java.io.IOException
url
- the URL instance for the resource
NullPointerException
- if the url argument is
null
MalformedURLException
- if a copy of the supplied
URL instance cannot be successfully created
IOException
- if the url argument is not a
valid location for any reason
java.net.MalformedURLException
java.io.IOException
public static AlternateLocation create(RemoteFileDesc rfd) throws java.io.IOException
rfd
- the RemoteFileDesc to use in creating the
AlternateLocation
IOException
- if the rfd does not contain
a valid urn or if it's a private address
NullPointerException
- if the rfd is
null
IOException
- if the port is invalid
java.io.IOException
public static AlternateLocation create(URN urn)
urn
- the URN of the locally stored filepublic java.net.URL getUrl()
public Endpoint getHost()
public URN getSHA1Urn()
public int getCount()
public boolean getDemoted()
public java.lang.String httpStringValue()
HTTPHeaderValue
httpStringValue
in interface HTTPHeaderValue
public RemoteFileDesc createRemoteFileDesc(int size)
size
- the size of the file for the new RemoteFileDesc
-- this is necessary to make sure the download bucketing works
correctly
public void increment()
demote
public void setOld()
public AlternateLocation createClone()
public boolean equals(java.lang.Object obj)
obj
- the Object instance to compare to
public int compareTo(java.lang.Object obj)
This is because we want to have a sorted set of AlternateLocation where any demoted AlternateLocation is put at the end of the list because it probably does not work.
Further we want to get AlternateLocations with smaller counts to be propogated more, since this will serve to get better load balancing of uploader.
compareTo
in interface java.lang.Comparable
public int hashCode()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |