All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class BaseLayer.BAddressTable

Abstract.AddressTable
   |
   +----BaseLayer.BAddressTable

public class BAddressTable
extends AddressTable
Implementation of AddressTable in Abstract Layer. AddressTable class for store and retain Address. The static addresses can be stored to the AddressTable from file reading and dynamic addresses can be stored by addAddress method. You can extend this class to use 'description' field of Address more structured way.


Constructor Index

 o BAddressTable()
Default constructor
 o BAddressTable(BufferedReader)
Construct AddressTable from file reading.

Method Index

 o addAddress(Address)
If the address table for the id is already exist, The address will be replaced with new one.
 o getAddress(String)
Get an Address object using agent name
 o getAddressTableWithType(String)
Get an AddressTable of the same Type address
 o removeAddress(String)
Remove address from the table.

Constructors

 o BAddressTable
 public BAddressTable()
Default constructor

 o BAddressTable
 public BAddressTable(BufferedReader in) throws IOException, ConnectionException
Construct AddressTable from file reading. If you are going to use different file format other than provided here, subclass AddressTable and override this constructor. The Address file format is a collection of Addresses and each Address should be finished with '\n' and items are separated by ','. Therefore you should not add '\n' and ',' unintentionally.
Each line's format is :
[Agent Name],[Internet Host Address],[Port No],[Message method for Connection],[String Description]\n Example of AddressTable file format :
AgentNameA,java.stanford.edu,1234,ServerThread,(AServer Connection)\n AgentNameB,aaa.bb.com,3456,ReceiverThread,(Sort Service)\n AgentNameC,ccc.aol.com,21,FTPClient,MyFTPClientService\n ..

Parameters:
in - BufferedReader for reading Addresses
Throws: IOException,
ConnectionException

Methods

 o addAddress
 public void addAddress(Address addr)
If the address table for the id is already exist, The address will be replaced with new one.

Parameters:
id - : Agent Name
addr - : Address object for the agent
Overrides:
addAddress in class AddressTable
 o removeAddress
 public void removeAddress(String id)
Remove address from the table. If the geven agent name is not in the address table, nothing will happen

Parameters:
id - Agent name want to be removed from the AddressTable
 o getAddress
 public Address getAddress(String id)
Get an Address object using agent name

Parameters:
id - Agent name
Returns:
Address object, the agent has. Null if the address is not defined
 o getAddressTableWithType
 public AddressTable getAddressTableWithType(String type)
Get an AddressTable of the same Type address

Parameters:
type - Type definition(e.g. Message method) to retrieve
Returns:
AddressTable

All Packages  Class Hierarchy  This Package  Previous  Next  Index