1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.asterisk.manager.event;
18
19
20 /***
21 * A NewCallerIdEvent is triggered when the caller id of a channel changes.<br>
22 * It is implemented in <code>channel.c</code>
23 *
24 * @author srt
25 * @version $Id: NewCallerIdEvent.java,v 1.6 2005/08/27 02:59:24 srt Exp $
26 */
27 public class NewCallerIdEvent extends ManagerEvent
28 {
29 /***
30 * Serializable version identifier
31 */
32 static final long serialVersionUID = 6639570533512201213L;
33
34 /***
35 * The new Caller*ID.
36 */
37 private String callerId;
38
39 /***
40 * The new Caller*ID Name.
41 */
42 private String callerIdName;
43
44 /***
45 * The name of the channel.
46 */
47 private String channel;
48
49 /***
50 * The unique id of the channel.
51 */
52 private String uniqueId;
53
54 /***
55 * Callerid presentation/screening.
56 */
57 private Integer cidCallingPres;
58 private String cidCallingPresTxt;
59
60 /***
61 * @param source
62 */
63 public NewCallerIdEvent(Object source)
64 {
65 super(source);
66 }
67
68 /***
69 * Returns the name of the channel.
70 *
71 * @return the name of the channel.
72 */
73 public String getChannel()
74 {
75 return channel;
76 }
77
78 /***
79 * Sets the name of the channel.
80 *
81 * @param channel the name of the channel
82 */
83 public void setChannel(String channel)
84 {
85 this.channel = channel;
86 }
87
88 /***
89 * Returns the unique id of the channel.
90 *
91 * @return the unique id of the channel.
92 */
93 public String getUniqueId()
94 {
95 return uniqueId;
96 }
97
98 /***
99 * Sets the unique id of the channel.
100 *
101 * @param uniqueId the unique id of the channel.
102 */
103 public void setUniqueId(String uniqueId)
104 {
105 this.uniqueId = uniqueId;
106 }
107
108 /***
109 * Returns the new caller id.
110 *
111 * @return the new caller id.
112 */
113 public String getCallerId()
114 {
115 return callerId;
116 }
117
118 /***
119 * Sets the new Caller*ID.
120 *
121 * @param callerId the new Caller*ID.
122 */
123 public void setCallerId(String callerId)
124 {
125 this.callerId = callerId;
126 }
127
128 /***
129 * Returns the new Caller*ID Name if set or "≶Unknown>" if none has
130 * been set.
131 *
132 * @return the new Caller*ID Name.
133 */
134 public String getCallerIdName()
135 {
136 return callerIdName;
137 }
138
139 /***
140 * Sets the new Caller*ID Name if set or "≶Unknown>" if none has been
141 * set.
142 *
143 * @param callerIdName the Caller*ID Name to set.
144 */
145 public void setCallerIdName(String callerIdName)
146 {
147 this.callerIdName = callerIdName;
148 }
149
150 /***
151 * Returns the CallerId presentation/screening.
152 *
153 * @return the CallerId presentation/screening.
154 * @since 0.2
155 */
156 public Integer getCidCallingPres()
157 {
158 return cidCallingPres;
159 }
160
161 /***
162 * Returns the textual respresentation of the CallerId
163 * presentation/screening.
164 *
165 * @return the textual respresentation of the CallerId
166 * presentation/screening.
167 * @since 0.2
168 */
169 public String getCidCallingPresTxt()
170 {
171 return cidCallingPresTxt;
172 }
173
174 /***
175 * Sets the CallerId presentation/screening in the form "%d (%s)".
176 *
177 * @param s the CallerId presentation/screening in the form "%d (%s)".
178 * @since 0.2
179 */
180 public void setCidCallingPres(String s)
181 {
182 int spaceIdx;
183
184 if (s == null)
185 {
186 return;
187 }
188
189 spaceIdx = s.indexOf(' ');
190 if (spaceIdx <= 0)
191 {
192 spaceIdx = s.length();
193 }
194
195 try
196 {
197 this.cidCallingPres = new Integer(s.substring(0, spaceIdx));
198 }
199 catch (NumberFormatException e)
200 {
201 return;
202 }
203
204 if (s.length() > spaceIdx + 3)
205 {
206 this.cidCallingPresTxt = s.substring(spaceIdx + 2, s.length() - 1);
207 }
208 }
209 }