LimeWire Consolidated API

com.limegroup.gnutella.altlocs
Class AlternateLocationCollection<T extends AlternateLocation>

java.lang.Object
  extended by com.limegroup.gnutella.altlocs.AlternateLocationCollection<T>
All Implemented Interfaces:
HTTPHeaderValue, Iterable<T>

public class AlternateLocationCollection<T extends AlternateLocation>
extends Object
implements HTTPHeaderValue, Iterable<T>

This class holds a collection of AlternateLocation instances, providing type safety for alternate location data.

See Also:
AlternateLocation

Field Summary
static AlternateLocationCollection EMPTY
           
 
Method Summary
 boolean add(T al)
          Adds a new AlternateLocation to the list.
 void clear()
           
 boolean contains(Object loc)
           
static
<T extends AlternateLocation>
AlternateLocationCollection<T>
create(URN sha1)
          Factory constructor for creating a new AlternateLocationCollection for this URN.
 boolean equals(Object o)
           
 int getAltLocsSize()
           
static
<T extends AlternateLocation>
AlternateLocationCollection<T>
getEmptyCollection()
          Returns a type-safe empty collection.
 URN getSHA1Urn()
          Returns the SHA1 for this AlternateLocationCollection.
 boolean hasAlternateLocations()
           
 String httpStringValue()
          Implements the HTTPHeaderValue interface.
 Iterator<T> iterator()
           
 boolean remove(T al)
          Removes this AlternateLocation from the active locations and adds it to the removed locations.
 String toString()
          Overrides Object.toString to print out all of the alternate locations for this collection of alternate locations.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final AlternateLocationCollection EMPTY
Method Detail

getEmptyCollection

public static <T extends AlternateLocation> AlternateLocationCollection<T> getEmptyCollection()
Returns a type-safe empty collection.

Type Parameters:
T -
Returns:

create

public static <T extends AlternateLocation> AlternateLocationCollection<T> create(URN sha1)
Factory constructor for creating a new AlternateLocationCollection for this URN.

Parameters:
sha1 - the SHA1 URN for this collection
Returns:
a new AlternateLocationCollection instance for this SHA1

getSHA1Urn

public URN getSHA1Urn()
Returns the SHA1 for this AlternateLocationCollection.


add

public boolean add(T al)
Adds a new AlternateLocation to the list. If the alternate location is already present in the collection, it's count will be incremented. Implements the AlternateLocationCollector interface.

Parameters:
al - the AlternateLocation to add
Returns:
true if added, false otherwise.
Throws:
IllegalArgumentException - if the AlternateLocation being added does not have a SHA1 urn or if the SHA1 urn does not match the urn for this collection

remove

public boolean remove(T al)
Removes this AlternateLocation from the active locations and adds it to the removed locations.


clear

public void clear()

hasAlternateLocations

public boolean hasAlternateLocations()

contains

public boolean contains(Object loc)
Returns:
true is this contains loc

httpStringValue

public String httpStringValue()
Implements the HTTPHeaderValue interface.

Specified by:
httpStringValue in interface HTTPHeaderValue
Returns:
an HTTP-compliant string of alternate locations, delimited by commas, or the empty string if there are no alternate locations to report

getAltLocsSize

public int getAltLocsSize()

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T extends AlternateLocation>

toString

public String toString()
Overrides Object.toString to print out all of the alternate locations for this collection of alternate locations.

Overrides:
toString in class Object
Returns:
the string representation of all alternate locations in this collection

equals

public boolean equals(Object o)
Overrides:
equals in class Object

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.