Package esmska.data
Class CountryPrefix
- java.lang.Object
-
- esmska.data.CountryPrefix
-
public class CountryPrefix extends java.lang.ObjectClass containing list of all telephone country prefixes (as defined in List of country calling codes) and some helper methods.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringINTERNATIONAL_CODECountry code for "international"
-
Constructor Summary
Constructors Constructor Description CountryPrefix()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringextractCountryCode(java.lang.String gatewayName)Extract country code from gateway namestatic java.lang.StringextractCountryPrefix(java.lang.String number)Extract country prefix from phone number.static java.lang.StringgetCountryCode(java.lang.String countryPrefix)Get country code for country with specified telephone country prefix.static java.util.ArrayList<java.lang.String>getCountryCodes()Get all country codes sorted ascendinglystatic java.lang.StringgetCountryPrefix(java.lang.String countryCode)Get telephone country prefix for country with country code.static booleanisValidCountryPrefix(java.lang.String prefix)Check validity of country prefixstatic java.lang.StringstripCountryPrefix(java.lang.String number, boolean onlyCurrent)Strip current country prefix from number if possible
-
-
-
Field Detail
-
INTERNATIONAL_CODE
public static final java.lang.String INTERNATIONAL_CODE
Country code for "international"- See Also:
- Constant Field Values
-
-
Method Detail
-
getCountryPrefix
public static java.lang.String getCountryPrefix(java.lang.String countryCode)
Get telephone country prefix for country with country code.- Parameters:
countryCode- two letter country code as defined in ISO 3166-1 alpha-2.- Returns:
- corresponding telephone country prefix or empty string if country wasn't found
-
getCountryCode
public static java.lang.String getCountryCode(java.lang.String countryPrefix)
Get country code for country with specified telephone country prefix.- Parameters:
countryPrefix- telephone country prefix as defined in List of country calling codes. May be null or invalid.- Returns:
- corresponding two letter country code or null if country prefix wasn't found
-
getCountryCodes
public static java.util.ArrayList<java.lang.String> getCountryCodes()
Get all country codes sorted ascendingly
-
stripCountryPrefix
public static java.lang.String stripCountryPrefix(java.lang.String number, boolean onlyCurrent)Strip current country prefix from number if possible- Parameters:
number- number, can be nullonlyCurrent- strip only currently set country prefix (in user preferences), do not touch numbers with other prefixes- Returns:
- number with stripped country prefix from start if possible (valid prefix); otherwise non-modified number
-
extractCountryPrefix
public static java.lang.String extractCountryPrefix(java.lang.String number)
Extract country prefix from phone number.- Parameters:
number- Phone number in fully international format. May be null or incomplete.- Returns:
- Country prefix if valid one is found in the number. Null otherwise.
-
isValidCountryPrefix
public static boolean isValidCountryPrefix(java.lang.String prefix)
Check validity of country prefix- Returns:
- true if prefix is in form +[0-9]{1,4} and is valid for some existing country, false otherwise
-
extractCountryCode
public static java.lang.String extractCountryCode(java.lang.String gatewayName)
Extract country code from gateway name- Parameters:
gatewayName- gateway name; may be invalid or null- Returns:
- country code CC or INT; or null when
gatewayNameinvalid or null
-
-