View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-2001. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20  */
21  
22  package zeus.concepts; 
23  import java.util.Vector; 
24  import java.util.Enumeration;
25  
26  /*** 
27      FIPA_MTP_Description is used to store the result of parsing a mtp-description 
28      fragment. The toString method can be used to generate a FIPA format string for 
29      sending message transport profiles to agents on other platforms. 
30      *@author Simon Thompson
31      *@since 1.2
32      */
33  public class FIPA_MTP_Description {
34   
35      private String profile; 
36      private String mtpName; 
37      private Vector addresses = null; 
38   
39      public void setProfile (String prof) { 
40          this.profile = prof;
41      }
42      
43      
44      public void setMTPName (String mtp) { 
45          this.mtpName = mtp; 
46      }
47      
48      
49      public void addAddress (String address) { 
50          if (addresses == null) addresses = new Vector(); 
51          this.addresses.addElement(address);
52      }
53          
54      
55      public String getProfile () { 
56          return this.profile; 
57      }
58      
59      
60      public String getMTPName () { 
61          return this.mtpName; 
62      }
63      
64      
65      public String getAddresses () { 
66          if (addresses == null) return null; 
67          Enumeration allAddresses = addresses.elements(); 
68          String retVal = new String(); 
69          while (allAddresses.hasMoreElements()) {
70              String thisAddress = (String) allAddresses.nextElement(); 
71              retVal +=thisAddress + " ";
72          }
73          return retVal; 
74      }
75      
76      
77      /*** 
78          return a string that is formatted to FIPA spec. 
79          **/ 
80      public String toString() { 
81          String retVal = new String("(mtp-description"); 
82          if (profile != null) 
83              retVal += " :profile " + getProfile(); 
84          if (mtpName != null) 
85              retVal += " :mtp-name " + getMTPName(); 
86          if (addresses!= null) 
87              retVal += " :addresses (sequence " + getAddresses() +") " ; 
88          retVal += ") ";         
89          return (retVal); 
90      }
91  }