JXTA

net.jxta.protocol
Class AccessPointAdvertisement

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.jxta.protocol.AccessPointAdvertisement
All Implemented Interfaces:
Cloneable

public abstract class AccessPointAdvertisement
extends ExtendableAdvertisement
implements Cloneable

Provides a simple association of a PeerID to an ordered list of EndpointAddress entries. Each EndpointAddress defines one Message Transport address by which the peer may be reached. The addresses are sorted in the preferred order (which may refer to performance, cost, efficiency, etc.) which they should be used.

The Access Point Advertisement is most commonly used as part of other Advertisements such as RouteAdvertisement.

See Also:
PeerAdvertisement, RouteAdvertisement

Constructor Summary
AccessPointAdvertisement()
           
 
Method Summary
 void addEndpointAddress(EndpointAddress address)
          Add a new EndpointAddresses to the access point
 void addEndpointAddress(String address)
          add a new EndpointAddresses to the access point
 void addEndpointAddresses(List<EndpointAddress> addrs)
          Add all of the provided EndpointAddresses.
 void addEndpointAddresses(Vector<String> addresses)
          Deprecated. Use addEndpointAddresses(List) instead.
 void clearEndpointAddresses()
          Clears all EndpointAddresses.
 AccessPointAdvertisement clone()
          

Make a deep copy.

 boolean contains(EndpointAddress addr)
          Check if the EndpointAddress is already associated with this access point
 String display()
          Generate a string that displays an access point information for logging or debugging purpose
 boolean equals(Object target)
          

Equals means the same PID and the same endpoint addresses.

static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 Enumeration<String> getEndpointAddresses()
          Returns the endpoint addresses associated with this access point.
 PeerID getPeerID()
          Gets the PeerID for this access point.
 Vector<String> getVectorEndpointAddresses()
          Deprecated. Returning the Vector is dangerous and unwise. This feature will be removed.
 int hashCode()
          
 void removeEndpointAddress(EndpointAddress addr)
          Remove the specified EndpointAddress.
 void removeEndpointAddresses(Collection<EndpointAddress> addrs)
          Remove the specified EndpointAddresses.
 void removeEndpointAddresses(List<String> addresses)
          remove a list of EndpointAddresses from the access point
 void setEndpointAddresses(Vector<String> addresses)
          Deprecated. This method causes the AccessPointAdvertisement to reference the provided array. This means that subsequent changes to the array will alter the endpoint addresses which are part of the AcccessPointAdvertisement.
 void setPeerID(PeerID pid)
          Sets the PeerID for this access point.
 int size()
          return number of endpoint addresses
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
getDocument, handleAttribute, handleElement
 
Methods inherited from class net.jxta.document.Advertisement
getAdvType, getID, getIndexFields, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccessPointAdvertisement

public AccessPointAdvertisement()
Method Detail

clone

public AccessPointAdvertisement clone()

Make a deep copy.

Overrides:
clone in class Advertisement

equals

public boolean equals(Object target)

Equals means the same PID and the same endpoint addresses.

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getAdvertisementType

public static String getAdvertisementType()
Returns the identifying type of this Advertisement.

Returns:
String the type of advertisement

getBaseAdvType

public final String getBaseAdvType()
Returns the base type of this advertisement hierarchy. Typically, only the most basic advertisement of a type will implement this method and declare it as final.

Specified by:
getBaseAdvType in class ExtendableAdvertisement
Returns:
String the base type of advertisements in this hierarchy.

getPeerID

public PeerID getPeerID()
Gets the PeerID for this access point.

Returns:
PeerID The peer id associated with the endpoint addresses or null if no peer has been directly associated.

setPeerID

public void setPeerID(PeerID pid)
Sets the PeerID for this access point.

Parameters:
pid - The peer id associated with the endpoint addresses or null if no peer is directly associated.

addEndpointAddresses

public void addEndpointAddresses(List<EndpointAddress> addrs)
Add all of the provided EndpointAddresses.

Parameters:
addrs - Add all of the specified endpoint addresses.

clearEndpointAddresses

public void clearEndpointAddresses()
Clears all EndpointAddresses.


removeEndpointAddress

public void removeEndpointAddress(EndpointAddress addr)
Remove the specified EndpointAddress.

Parameters:
addr - EndpointAddress to remove.

removeEndpointAddresses

public void removeEndpointAddresses(Collection<EndpointAddress> addrs)
Remove the specified EndpointAddresses.

Parameters:
addrs - EndpointAddresses to remove.

getEndpointAddresses

public Enumeration<String> getEndpointAddresses()
Returns the endpoint addresses associated with this access point.

Returns:
The endpoint addresses associated with this access point represented as String.

getVectorEndpointAddresses

@Deprecated
public Vector<String> getVectorEndpointAddresses()
Deprecated. Returning the Vector is dangerous and unwise. This feature will be removed.

Returns the vector of endpoint addresses associated with this access point. The result is a vector of endpoint addresses represented as String. The Vector contains the "live" data of this advertisement. It should be modified only with great care.

Returns:
The endpoint addresses associated with this access point represented as String.

setEndpointAddresses

@Deprecated
public void setEndpointAddresses(Vector<String> addresses)
Deprecated. This method causes the AccessPointAdvertisement to reference the provided array. This means that subsequent changes to the array will alter the endpoint addresses which are part of the AcccessPointAdvertisement.

Sets the list of endpoint addresses associated with this access point.

Parameters:
addresses - Vector of EndpointAddresses represented as String. The Vector is not copied!

addEndpointAddresses

@Deprecated
public void addEndpointAddresses(Vector<String> addresses)
Deprecated. Use addEndpointAddresses(List) instead.

Add a new list of EndpointAddresses to the access point.

Parameters:
addresses - List of EndpointAddresses represented as String.

addEndpointAddress

public void addEndpointAddress(EndpointAddress address)
Add a new EndpointAddresses to the access point

Parameters:
address - An EndpointAddress

addEndpointAddress

public void addEndpointAddress(String address)
add a new EndpointAddresses to the access point

Parameters:
address - EndpointAddress represented as String.

removeEndpointAddresses

public void removeEndpointAddresses(List<String> addresses)
remove a list of EndpointAddresses from the access point

Parameters:
addresses - List of EndpointAddresses represented as String.

size

public int size()
return number of endpoint addresses

Returns:
size number of endpointAddress in the hop

contains

public boolean contains(EndpointAddress addr)
Check if the EndpointAddress is already associated with this access point

Parameters:
addr - endpoint address to check
Returns:
true if the EndpointAddress is already associated with this access point

display

public String display()
Generate a string that displays an access point information for logging or debugging purpose

Returns:
String return a string containing the access point advertisement

JXSE