Exemplo n.º 1
0
        /**
         * As per {@link #getDescriptionForValidNumber(PhoneNumber, Locale)} but explicitly checks
         * the validity of the number passed in.
         *
         * @param number  the phone number for which we want to get a text description
         * @param languageCode  the language code for which the description should be written
         * @return  a text description for the given language code for the given phone number, or empty
         *     string if the number passed in is invalid
         */
        public String getDescriptionForNumber(PhoneNumber number, Locale languageCode)
        {
            PhoneNumberType numberType = phoneUtil.getNumberType(number);

            if (numberType == PhoneNumberType.UNKNOWN)
            {
                return("");
            }
            else if (!canBeGeocoded(numberType))
            {
                return(getCountryNameForNumber(number, languageCode));
            }
            return(getDescriptionForValidNumber(number, languageCode));
        }
Exemplo n.º 2
0
 /**
  * A similar method is implemented as PhoneNumberUtil.isNumberGeographical, which performs a
  * stricter check, as it determines if a number has a geographical association. Also, if new
  * phone number types were added, we should check if this other method should be updated too.
  */
 private boolean canBeGeocoded(PhoneNumberType numberType)
 {
     return(numberType == PhoneNumberType.FIXED_LINE ||
            numberType == PhoneNumberType.MOBILE ||
            numberType == PhoneNumberType.FIXED_LINE_OR_MOBILE);
 }
 /**
    * A similar method is implemented as PhoneNumberUtil.isNumberGeographical, which performs a
    * stricter check, as it determines if a number has a geographical association. Also, if new
    * phone number types were added, we should check if this other method should be updated too.
    */
 private boolean canBeGeocoded(PhoneNumberType numberType)
 {
     return (numberType == PhoneNumberType.FIXED_LINE ||
     numberType == PhoneNumberType.MOBILE ||
     numberType == PhoneNumberType.FIXED_LINE_OR_MOBILE);
 }