1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.asteriskjava.manager.event;
18
19
20 /***
21 * A NewCallerIdEvent is triggered when the caller id of a channel changes.<p>
22 * It is implemented in <code>channel.c</code>
23 *
24 * @author srt
25 * @version $Id: NewCallerIdEvent.java 476 2006-07-14 11:45:58Z srt $
26 */
27 public class NewCallerIdEvent extends AbstractChannelEvent
28 {
29 /***
30 * Serializable version identifier
31 */
32 static final long serialVersionUID = 6639570533512201213L;
33
34 /***
35 * Callerid presentation/screening.
36 */
37 private Integer cidCallingPres;
38 private String cidCallingPresTxt;
39
40 /***
41 * @param source
42 */
43 public NewCallerIdEvent(Object source)
44 {
45 super(source);
46 }
47
48 /***
49 * Returns the CallerId presentation/screening.
50 *
51 * @return the CallerId presentation/screening.
52 * @since 0.2
53 */
54 public Integer getCidCallingPres()
55 {
56 return cidCallingPres;
57 }
58
59 /***
60 * Returns the textual respresentation of the CallerId
61 * presentation/screening.
62 *
63 * @return the textual respresentation of the CallerId
64 * presentation/screening.
65 * @since 0.2
66 */
67 public String getCidCallingPresTxt()
68 {
69 return cidCallingPresTxt;
70 }
71
72 /***
73 * Sets the CallerId presentation/screening in the form "%d (%s)".
74 *
75 * @param s the CallerId presentation/screening in the form "%d (%s)".
76 * @since 0.2
77 */
78 public void setCidCallingPres(String s)
79 {
80 int spaceIdx;
81
82 if (s == null)
83 {
84 return;
85 }
86
87 spaceIdx = s.indexOf(' ');
88 if (spaceIdx <= 0)
89 {
90 spaceIdx = s.length();
91 }
92
93 try
94 {
95 this.cidCallingPres = Integer.valueOf(s.substring(0, spaceIdx));
96 }
97 catch (NumberFormatException e)
98 {
99 return;
100 }
101
102 if (s.length() > spaceIdx + 3)
103 {
104 this.cidCallingPresTxt = s.substring(spaceIdx + 2, s.length() - 1);
105 }
106 }
107 }