1/*
2 * Copyright (C) 2011 The Libphonenumber Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.i18n.phonenumbers;
18
19import java.util.Set;
20
21/*
22 * Utility for international short phone numbers, such as short codes and emergency numbers. Note
23 * most commercial short numbers are not handled here, but by the PhoneNumberUtil.
24 *
25 * @deprecated("As of release 5.8, replaced by ShortNumberInfo.")
26 *
27 * @author Shaopeng Jia
28 * @author David Yonge-Mallo
29 */
30@Deprecated public class ShortNumberUtil {
31
32  /**
33   * Cost categories of short numbers.
34   */
35  public enum ShortNumberCost {
36    TOLL_FREE,
37    STANDARD_RATE,
38    PREMIUM_RATE,
39    UNKNOWN_COST
40  }
41
42  public ShortNumberUtil() {
43  }
44
45  /**
46   * Convenience method to get a list of what regions the library has metadata for.
47   */
48  public Set<String> getSupportedRegions() {
49    return ShortNumberInfo.getInstance().getSupportedRegions();
50  }
51
52  /**
53   * Returns true if the number might be used to connect to an emergency service in the given
54   * region.
55   *
56   * This method takes into account cases where the number might contain formatting, or might have
57   * additional digits appended (when it is okay to do that in the region specified).
58   *
59   * @param number  the phone number to test
60   * @param regionCode  the region where the phone number is being dialed
61   * @return  if the number might be used to connect to an emergency service in the given region.
62   */
63  public boolean connectsToEmergencyNumber(String number, String regionCode) {
64    return ShortNumberInfo.getInstance().connectsToEmergencyNumber(number, regionCode);
65  }
66
67  /**
68   * Returns true if the number exactly matches an emergency service number in the given region.
69   *
70   * This method takes into account cases where the number might contain formatting, but doesn't
71   * allow additional digits to be appended.
72   *
73   * @param number  the phone number to test
74   * @param regionCode  the region where the phone number is being dialed
75   * @return  if the number exactly matches an emergency services number in the given region.
76   */
77  public boolean isEmergencyNumber(String number, String regionCode) {
78    return ShortNumberInfo.getInstance().isEmergencyNumber(number, regionCode);
79  }
80}
81