aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/protocol/DTMFTone.java
blob: 9f6a1a4c26cc61e9a08c87d2e3182e1f21f6ff9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.service.protocol;

/**
 * Class for representing all the different DTMF tones.
 *
 * @author JM HEITZ
 */
public final class DTMFTone
{
    /**
     * The "A" DTMF Tone
     */
    public static final DTMFTone DTMF_A=new DTMFTone("A");

    /**
     * The "B" DTMF Tone
     */
    public static final DTMFTone DTMF_B=new DTMFTone("B");

    /**
     * The "C" DTMF Tone
     */
    public static final DTMFTone DTMF_C=new DTMFTone("C");

    /**
     * The "D" DTMF Tone
     */
    public static final DTMFTone DTMF_D=new DTMFTone("D");

    /**
     * The "0" DTMF Tone
     */
    public static final DTMFTone DTMF_0=new DTMFTone("0");

    /**
     * The "1" DTMF Tone
     */
    public static final DTMFTone DTMF_1=new DTMFTone("1");

    /**
     * The "2" DTMF Tone
     */
    public static final DTMFTone DTMF_2=new DTMFTone("2");

    /**
     * The "3" DTMF Tone
     */
    public static final DTMFTone DTMF_3=new DTMFTone("3");

    /**
     * The "4" DTMF Tone
     */
    public static final DTMFTone DTMF_4=new DTMFTone("4");

    /**
     * The "5" DTMF Tone
     */
    public static final DTMFTone DTMF_5=new DTMFTone("5");

    /**
     * The "6" DTMF Tone
     */
    public static final DTMFTone DTMF_6=new DTMFTone("6");

    /**
     * The "7" DTMF Tone
     */
    public static final DTMFTone DTMF_7=new DTMFTone("7");

    /**
     * The "8" DTMF Tone
     */
    public static final DTMFTone DTMF_8=new DTMFTone("8");

    /**
     * The "9" DTMF Tone
     */
    public static final DTMFTone DTMF_9=new DTMFTone("9");

    /**
     * The "*" DTMF Tone
     */
    public static final DTMFTone DTMF_STAR=new DTMFTone("*");

    /**
     * The "#" DTMF Tone
     */
    public static final DTMFTone DTMF_SHARP=new DTMFTone("#");

    /**
     * The value of the DTMF tone
     */
    private final String value;

    /**
     * Creates a DTMF instance with the specified tone value. The method is
     * private since one would only have to use predefined static instances.
     *
     * @param value one of te DTMF_XXX fields, indicating the value of the tone.
     */
    private DTMFTone(String value)
    {
        this.value = value;
    }

    /**
     * Returns the string representation of this DTMF tone.
     *
     * @return the <tt>String</tt> representation of this DTMF tone.
     */
    public String getValue()
    {
        return this.value;
    }

    /**
     * Indicates whether some other object is "equal to" this tone.
     * <p>
     * @param target the reference object with which to compare.
     *
     * @return  <tt>true</tt> if target represents the same tone as this
     * object.
     */
    public boolean equals(Object target)
    {
        if(!(target instanceof DTMFTone))
        {
            return false;
        }
        DTMFTone targetDTMFTone = (DTMFTone)(target);

        return targetDTMFTone.value.equals(this.value);
    }

    /**
     * Returns a hash code value for the object. This method is
     * supported for the benefit of hashtables such as those provided by
     * <code>java.util.Hashtable</code>. The method would actually return the
     * hashcode of the string representation of this DTMF tone.
     * <p>
     *
     * @return  a hash code value for this object (same as calling
     * getValue().hashCode()).
     */
    public int hashCode()
    {
        return getValue().hashCode();
    }

}