1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package net.sf.asterisk.manager;
19
20 import java.util.*;
21
22 /***
23 * @author Ben Hencke
24 */
25 public class Call
26 {
27 private String uniqueId;
28 private Integer reason;
29 private Channel channel;
30
31 private Date startTime;
32 private Date endTime;
33
34 public Call()
35 {
36 startTime = new Date();
37 }
38
39 public String getUniqueId()
40 {
41 return uniqueId;
42 }
43
44 public void setUniqueId(String uniqueId)
45 {
46 this.uniqueId = uniqueId;
47 }
48
49 public Channel getChannel()
50 {
51 return channel;
52 }
53
54 public void setChannel(Channel channel)
55 {
56 this.channel = channel;
57 }
58
59 public Integer getReason()
60 {
61 return reason;
62 }
63
64 public void setReason(Integer reason)
65 {
66 this.reason = reason;
67 }
68
69 public Date getStartTime()
70 {
71 return startTime;
72 }
73
74 public void setStartTime(Date startTime)
75 {
76 this.startTime = startTime;
77 }
78
79 public Date getEndTime()
80 {
81 return endTime;
82 }
83
84 public void setEndTime(Date endTime)
85 {
86 this.endTime = endTime;
87 }
88
89 /***
90 * @return The duration of the call in milliseconds. If the call is has not
91 * ended, the duration so far is calculated.
92 */
93 public long calcDuration()
94 {
95 Date compTime;
96
97 if (endTime != null)
98 {
99 compTime = endTime;
100 }
101 else
102 {
103 compTime = new Date();
104 }
105
106 return compTime.getTime() - startTime.getTime();
107 }
108
109 public String toString()
110 {
111 StringBuffer sb;
112
113 sb = new StringBuffer(getClass().getName() + ": ");
114 sb.append("uniqueId=" + getUniqueId() + "; ");
115 sb.append("reason=" + getReason() + "; ");
116 sb.append("startTime=" + getStartTime() + "; ");
117 sb.append("endTime=" + getEndTime() + "; ");
118 sb.append("systemHashcode=" + System.identityHashCode(this));
119
120 return sb.toString();
121 }
122 }