1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }