public final class PhoneNumber extends com.google.protobuf.GeneratedMessageV3 implements PhoneNumberOrBuilder
An object representing a phone number, suitable as an API wire format.
This representation:
- should not be used for locale-specific formatting of a phone number, such
as "+1 (650) 253-0000 ext. 123"
- is not designed for efficient storage
- may not be suitable for dialing - specialized libraries (see references)
should be used to parse the number for that purpose
To do something meaningful with this number, such as format it for various
use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.
For instance, in Java this would be:
com.google.type.PhoneNumber wireProto =
com.google.type.PhoneNumber.newBuilder().build();
com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
if (!wireProto.getExtension().isEmpty()) {
phoneNumber.setExtension(wireProto.getExtension());
}
Reference(s):
- https://github.com/google/libphonenumber
Protobuf type google.type.PhoneNumber| Modifier and Type | Class and Description |
|---|---|
static class |
PhoneNumber.Builder
An object representing a phone number, suitable as an API wire format.
|
static class |
PhoneNumber.KindCase |
static class |
PhoneNumber.ShortCode
An object representing a short code, which is a phone number that is
typically much shorter than regular phone numbers and can be used to
address messages in MMS and SMS systems, as well as for abbreviated dialing
(e.g.
|
static interface |
PhoneNumber.ShortCodeOrBuilder |
com.google.protobuf.GeneratedMessageV3.BuilderParent, com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage,BuilderType extends com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage>, com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage>, com.google.protobuf.GeneratedMessageV3.FieldAccessorTable, com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter| Modifier and Type | Field and Description |
|---|---|
static int |
E164_NUMBER_FIELD_NUMBER |
static int |
EXTENSION_FIELD_NUMBER |
static int |
SHORT_CODE_FIELD_NUMBER |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
static PhoneNumber |
getDefaultInstance() |
PhoneNumber |
getDefaultInstanceForType() |
static com.google.protobuf.Descriptors.Descriptor |
getDescriptor() |
String |
getE164Number()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
|
com.google.protobuf.ByteString |
getE164NumberBytes()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
|
String |
getExtension()
The phone number's extension.
|
com.google.protobuf.ByteString |
getExtensionBytes()
The phone number's extension.
|
PhoneNumber.KindCase |
getKindCase() |
com.google.protobuf.Parser<PhoneNumber> |
getParserForType() |
int |
getSerializedSize() |
PhoneNumber.ShortCode |
getShortCode()
A short code.
|
PhoneNumber.ShortCodeOrBuilder |
getShortCodeOrBuilder()
A short code.
|
com.google.protobuf.UnknownFieldSet |
getUnknownFields() |
boolean |
hasE164Number()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
|
int |
hashCode() |
boolean |
hasShortCode()
A short code.
|
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable() |
boolean |
isInitialized() |
static PhoneNumber.Builder |
newBuilder() |
static PhoneNumber.Builder |
newBuilder(PhoneNumber prototype) |
PhoneNumber.Builder |
newBuilderForType() |
protected PhoneNumber.Builder |
newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) |
protected Object |
newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused) |
static PhoneNumber |
parseDelimitedFrom(InputStream input) |
static PhoneNumber |
parseDelimitedFrom(InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static PhoneNumber |
parseFrom(byte[] data) |
static PhoneNumber |
parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static PhoneNumber |
parseFrom(ByteBuffer data) |
static PhoneNumber |
parseFrom(ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static PhoneNumber |
parseFrom(com.google.protobuf.ByteString data) |
static PhoneNumber |
parseFrom(com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static PhoneNumber |
parseFrom(com.google.protobuf.CodedInputStream input) |
static PhoneNumber |
parseFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static PhoneNumber |
parseFrom(InputStream input) |
static PhoneNumber |
parseFrom(InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
static com.google.protobuf.Parser<PhoneNumber> |
parser() |
PhoneNumber.Builder |
toBuilder() |
void |
writeTo(com.google.protobuf.CodedOutputStream output) |
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof, internalGetMapField, isStringEmpty, makeExtensionsImmutable, mergeFromAndMakeImmutableInternal, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newDoubleList, newFloatList, newIntList, newLongList, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTagfindInitializationErrors, getInitializationErrorString, hashBoolean, hashEnum, hashEnumList, hashFields, hashLong, toStringaddAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic static final int E164_NUMBER_FIELD_NUMBER
public static final int SHORT_CODE_FIELD_NUMBER
public static final int EXTENSION_FIELD_NUMBER
protected Object newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
newInstance in class com.google.protobuf.GeneratedMessageV3public final com.google.protobuf.UnknownFieldSet getUnknownFields()
getUnknownFields in interface com.google.protobuf.MessageOrBuildergetUnknownFields in class com.google.protobuf.GeneratedMessageV3public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3public PhoneNumber.KindCase getKindCase()
getKindCase in interface PhoneNumberOrBuilderpublic boolean hasE164Number()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
The ITU E.164 format limits the latter to 12 digits, but in practice not
all countries respect that, so we relax that restriction here.
National-only numbers are not allowed.
References:
- https://www.itu.int/rec/T-REC-E.164-201011-I
- https://en.wikipedia.org/wiki/E.164.
- https://en.wikipedia.org/wiki/List_of_country_calling_codes
string e164_number = 1;hasE164Number in interface PhoneNumberOrBuilderpublic String getE164Number()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
The ITU E.164 format limits the latter to 12 digits, but in practice not
all countries respect that, so we relax that restriction here.
National-only numbers are not allowed.
References:
- https://www.itu.int/rec/T-REC-E.164-201011-I
- https://en.wikipedia.org/wiki/E.164.
- https://en.wikipedia.org/wiki/List_of_country_calling_codes
string e164_number = 1;getE164Number in interface PhoneNumberOrBuilderpublic com.google.protobuf.ByteString getE164NumberBytes()
The phone number, represented as a leading plus sign ('+'), followed by a
phone number that uses a relaxed ITU E.164 format consisting of the
country calling code (1 to 3 digits) and the subscriber number, with no
additional spaces or formatting, e.g.:
- correct: "+15552220123"
- incorrect: "+1 (555) 222-01234 x123".
The ITU E.164 format limits the latter to 12 digits, but in practice not
all countries respect that, so we relax that restriction here.
National-only numbers are not allowed.
References:
- https://www.itu.int/rec/T-REC-E.164-201011-I
- https://en.wikipedia.org/wiki/E.164.
- https://en.wikipedia.org/wiki/List_of_country_calling_codes
string e164_number = 1;getE164NumberBytes in interface PhoneNumberOrBuilderpublic boolean hasShortCode()
A short code. Reference(s): - https://en.wikipedia.org/wiki/Short_code
.google.type.PhoneNumber.ShortCode short_code = 2;hasShortCode in interface PhoneNumberOrBuilderpublic PhoneNumber.ShortCode getShortCode()
A short code. Reference(s): - https://en.wikipedia.org/wiki/Short_code
.google.type.PhoneNumber.ShortCode short_code = 2;getShortCode in interface PhoneNumberOrBuilderpublic PhoneNumber.ShortCodeOrBuilder getShortCodeOrBuilder()
A short code. Reference(s): - https://en.wikipedia.org/wiki/Short_code
.google.type.PhoneNumber.ShortCode short_code = 2;getShortCodeOrBuilder in interface PhoneNumberOrBuilderpublic String getExtension()
The phone number's extension. The extension is not standardized in ITU recommendations, except for being defined as a series of numbers with a maximum length of 40 digits. Other than digits, some other dialing characters such as ',' (indicating a wait) or '#' may be stored here. Note that no regions currently use extensions with short codes, so this field is normally only set in conjunction with an E.164 number. It is held separately from the E.164 number to allow for short code extensions in the future.
string extension = 3;getExtension in interface PhoneNumberOrBuilderpublic com.google.protobuf.ByteString getExtensionBytes()
The phone number's extension. The extension is not standardized in ITU recommendations, except for being defined as a series of numbers with a maximum length of 40 digits. Other than digits, some other dialing characters such as ',' (indicating a wait) or '#' may be stored here. Note that no regions currently use extensions with short codes, so this field is normally only set in conjunction with an E.164 number. It is held separately from the E.164 number to allow for short code extensions in the future.
string extension = 3;getExtensionBytes in interface PhoneNumberOrBuilderpublic final boolean isInitialized()
isInitialized in interface com.google.protobuf.MessageLiteOrBuilderisInitialized in class com.google.protobuf.GeneratedMessageV3public void writeTo(com.google.protobuf.CodedOutputStream output)
throws IOException
writeTo in interface com.google.protobuf.MessageLitewriteTo in class com.google.protobuf.GeneratedMessageV3IOExceptionpublic int getSerializedSize()
getSerializedSize in interface com.google.protobuf.MessageLitegetSerializedSize in class com.google.protobuf.GeneratedMessageV3public boolean equals(Object obj)
equals in interface com.google.protobuf.Messageequals in class com.google.protobuf.AbstractMessagepublic int hashCode()
hashCode in interface com.google.protobuf.MessagehashCode in class com.google.protobuf.AbstractMessagepublic static PhoneNumber parseFrom(ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
com.google.protobuf.InvalidProtocolBufferExceptionpublic static PhoneNumber parseFrom(InputStream input) throws IOException
IOExceptionpublic static PhoneNumber parseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic static PhoneNumber parseDelimitedFrom(InputStream input) throws IOException
IOExceptionpublic static PhoneNumber parseDelimitedFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic static PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input) throws IOException
IOExceptionpublic static PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
IOExceptionpublic PhoneNumber.Builder newBuilderForType()
newBuilderForType in interface com.google.protobuf.MessagenewBuilderForType in interface com.google.protobuf.MessageLitepublic static PhoneNumber.Builder newBuilder()
public static PhoneNumber.Builder newBuilder(PhoneNumber prototype)
public PhoneNumber.Builder toBuilder()
toBuilder in interface com.google.protobuf.MessagetoBuilder in interface com.google.protobuf.MessageLiteprotected PhoneNumber.Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
newBuilderForType in class com.google.protobuf.GeneratedMessageV3public static PhoneNumber getDefaultInstance()
public static com.google.protobuf.Parser<PhoneNumber> parser()
public com.google.protobuf.Parser<PhoneNumber> getParserForType()
getParserForType in interface com.google.protobuf.MessagegetParserForType in interface com.google.protobuf.MessageLitegetParserForType in class com.google.protobuf.GeneratedMessageV3public PhoneNumber getDefaultInstanceForType()
getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuildergetDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilderCopyright © 2021 Google LLC. All rights reserved.