Home | History | Annotate | Download | only in phonenumbers
      1 /*
      2  * Copyright (C) 2010 Google Inc.
      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 
     17 /**
     18  * Definition of the class representing metadata for international telephone numbers. This class is
     19  * hand created based on the class file compiled from phonemetadata.proto. Please refer to that file
     20  * for detailed descriptions of the meaning of each field.
     21  */
     22 
     23 package com.android.i18n.phonenumbers;
     24 
     25 import java.io.Externalizable;
     26 import java.io.IOException;
     27 import java.io.ObjectInput;
     28 import java.io.ObjectOutput;
     29 
     30 public final class Phonemetadata {
     31   private Phonemetadata() {}
     32   public static class NumberFormat implements Externalizable {
     33     private static final long serialVersionUID = 1;
     34     public NumberFormat() {}
     35 
     36     /**
     37      * Provides a dummy builder to 'emulate' the API of the code generated by the latest version of
     38      * Protocol Buffers. This lets BuildMetadataFromXml class to build with both this hand created
     39      * class and the one generated by the latest version of Protocol Buffers.
     40      */
     41     public static final class Builder extends NumberFormat {
     42       public NumberFormat build() {
     43         return this;
     44       }
     45     }
     46     public static Builder newBuilder() {
     47       return new Builder();
     48     }
     49 
     50     // required string pattern = 1;
     51     private boolean hasPattern;
     52     private String pattern_ = "";
     53     public boolean hasPattern() { return hasPattern; }
     54     public String getPattern() { return pattern_; }
     55     public NumberFormat setPattern(String value) {
     56       hasPattern = true;
     57       pattern_ = value;
     58       return this;
     59     }
     60 
     61     // required string format = 2;
     62     private boolean hasFormat;
     63     private String format_ = "";
     64     public boolean hasFormat() { return hasFormat; }
     65     public String getFormat() { return format_; }
     66     public NumberFormat setFormat(String value) {
     67       hasFormat = true;
     68       format_ = value;
     69       return this;
     70     }
     71 
     72     // repeated string leading_digits_pattern = 3;
     73     private java.util.List<String> leadingDigitsPattern_ = new java.util.ArrayList<String>();
     74     public java.util.List<String> leadingDigitPatterns() {
     75       return leadingDigitsPattern_;
     76     }
     77     public int leadingDigitsPatternSize() { return leadingDigitsPattern_.size(); }
     78     public String getLeadingDigitsPattern(int index) {
     79       return leadingDigitsPattern_.get(index);
     80     }
     81     public NumberFormat addLeadingDigitsPattern(String value) {
     82       if (value == null) {
     83         throw new NullPointerException();
     84       }
     85       leadingDigitsPattern_.add(value);
     86       return this;
     87     }
     88 
     89     // optional string national_prefix_formatting_rule = 4;
     90     private boolean hasNationalPrefixFormattingRule;
     91     private String nationalPrefixFormattingRule_ = "";
     92     public boolean hasNationalPrefixFormattingRule() { return hasNationalPrefixFormattingRule; }
     93     public String getNationalPrefixFormattingRule() { return nationalPrefixFormattingRule_; }
     94     public NumberFormat setNationalPrefixFormattingRule(String value) {
     95       hasNationalPrefixFormattingRule = true;
     96       nationalPrefixFormattingRule_ = value;
     97       return this;
     98     }
     99     public NumberFormat clearNationalPrefixFormattingRule() {
    100       hasNationalPrefixFormattingRule = false;
    101       nationalPrefixFormattingRule_ = "";
    102       return this;
    103     }
    104 
    105     // optional string domestic_carrier_code_formatting_rule = 5;
    106     private boolean hasDomesticCarrierCodeFormattingRule;
    107     private String domesticCarrierCodeFormattingRule_ = "";
    108     public boolean hasDomesticCarrierCodeFormattingRule() {
    109       return hasDomesticCarrierCodeFormattingRule; }
    110     public String getDomesticCarrierCodeFormattingRule() {
    111       return domesticCarrierCodeFormattingRule_; }
    112     public NumberFormat setDomesticCarrierCodeFormattingRule(String value) {
    113       hasDomesticCarrierCodeFormattingRule = true;
    114       domesticCarrierCodeFormattingRule_ = value;
    115       return this;
    116     }
    117 
    118     public NumberFormat mergeFrom(NumberFormat other) {
    119       if (other.hasPattern()) {
    120         setPattern(other.getPattern());
    121       }
    122       if (other.hasFormat()) {
    123         setFormat(other.getFormat());
    124       }
    125       int leadingDigitsPatternSize = other.leadingDigitsPatternSize();
    126       for (int i = 0; i < leadingDigitsPatternSize; i++) {
    127         addLeadingDigitsPattern(other.getLeadingDigitsPattern(i));
    128       }
    129       if (other.hasNationalPrefixFormattingRule()) {
    130         setNationalPrefixFormattingRule(other.getNationalPrefixFormattingRule());
    131       }
    132       if (other.hasDomesticCarrierCodeFormattingRule()) {
    133         setDomesticCarrierCodeFormattingRule(other.getDomesticCarrierCodeFormattingRule());
    134       }
    135       return this;
    136     }
    137 
    138     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    139       objectOutput.writeUTF(pattern_);
    140       objectOutput.writeUTF(format_);
    141       int leadingDigitsPatternSize = leadingDigitsPatternSize();
    142       objectOutput.writeInt(leadingDigitsPatternSize);
    143       for (int i = 0; i < leadingDigitsPatternSize; i++) {
    144         objectOutput.writeUTF(leadingDigitsPattern_.get(i));
    145       }
    146 
    147       objectOutput.writeBoolean(hasNationalPrefixFormattingRule);
    148       if (hasNationalPrefixFormattingRule) {
    149         objectOutput.writeUTF(nationalPrefixFormattingRule_);
    150       }
    151       objectOutput.writeBoolean(hasDomesticCarrierCodeFormattingRule);
    152       if (hasDomesticCarrierCodeFormattingRule) {
    153         objectOutput.writeUTF(domesticCarrierCodeFormattingRule_);
    154       }
    155     }
    156 
    157     public void readExternal(ObjectInput objectInput) throws IOException {
    158       setPattern(objectInput.readUTF());
    159       setFormat(objectInput.readUTF());
    160       int leadingDigitsPatternSize = objectInput.readInt();
    161       for (int i = 0; i < leadingDigitsPatternSize; i++) {
    162         leadingDigitsPattern_.add(objectInput.readUTF());
    163       }
    164       if (objectInput.readBoolean()) {
    165         setNationalPrefixFormattingRule(objectInput.readUTF());
    166       }
    167       if (objectInput.readBoolean()) {
    168         setDomesticCarrierCodeFormattingRule(objectInput.readUTF());
    169       }
    170     }
    171   }
    172 
    173   public static class PhoneNumberDesc implements Externalizable {
    174     private static final long serialVersionUID = 1;
    175     public PhoneNumberDesc() {}
    176 
    177     /**
    178      * Provides a dummy builder.
    179      *
    180      * @see NumberFormat.Builder
    181      */
    182     public static final class Builder extends PhoneNumberDesc {
    183       public PhoneNumberDesc build() {
    184         return this;
    185       }
    186     }
    187     public static Builder newBuilder() {
    188       return new Builder();
    189     }
    190 
    191     // optional string national_number_pattern = 2;
    192     private boolean hasNationalNumberPattern;
    193     private String nationalNumberPattern_ = "";
    194     public boolean hasNationalNumberPattern() { return hasNationalNumberPattern; }
    195     public String getNationalNumberPattern() { return nationalNumberPattern_; }
    196     public PhoneNumberDesc setNationalNumberPattern(String value) {
    197       hasNationalNumberPattern = true;
    198       nationalNumberPattern_ = value;
    199       return this;
    200     }
    201 
    202     // optional string possible_number_pattern = 3;
    203     private boolean hasPossibleNumberPattern;
    204     private String possibleNumberPattern_ = "";
    205     public boolean hasPossibleNumberPattern() { return hasPossibleNumberPattern; }
    206     public String getPossibleNumberPattern() { return possibleNumberPattern_; }
    207     public PhoneNumberDesc setPossibleNumberPattern(String value) {
    208       hasPossibleNumberPattern = true;
    209       possibleNumberPattern_ = value;
    210       return this;
    211     }
    212 
    213     // optional string example_number = 6;
    214     private boolean hasExampleNumber;
    215     private String exampleNumber_ = "";
    216     public boolean hasExampleNumber() { return hasExampleNumber; }
    217     public String getExampleNumber() { return exampleNumber_; }
    218     public PhoneNumberDesc setExampleNumber(String value) {
    219       hasExampleNumber = true;
    220       exampleNumber_ = value;
    221       return this;
    222     }
    223 
    224     public PhoneNumberDesc mergeFrom(PhoneNumberDesc other) {
    225       if (other.hasNationalNumberPattern()) {
    226         setNationalNumberPattern(other.getNationalNumberPattern());
    227       }
    228       if (other.hasPossibleNumberPattern()) {
    229         setPossibleNumberPattern(other.getPossibleNumberPattern());
    230       }
    231       if (other.hasExampleNumber()) {
    232         setExampleNumber(other.getExampleNumber());
    233       }
    234       return this;
    235     }
    236 
    237     public boolean exactlySameAs(PhoneNumberDesc other) {
    238       return nationalNumberPattern_.equals(other.nationalNumberPattern_) &&
    239           possibleNumberPattern_.equals(other.possibleNumberPattern_) &&
    240           exampleNumber_.equals(other.exampleNumber_);
    241     }
    242 
    243     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    244       objectOutput.writeBoolean(hasNationalNumberPattern);
    245       if (hasNationalNumberPattern) {
    246         objectOutput.writeUTF(nationalNumberPattern_);
    247       }
    248 
    249       objectOutput.writeBoolean(hasPossibleNumberPattern);
    250       if (hasPossibleNumberPattern) {
    251         objectOutput.writeUTF(possibleNumberPattern_);
    252       }
    253 
    254       objectOutput.writeBoolean(hasExampleNumber);
    255       if (hasExampleNumber) {
    256         objectOutput.writeUTF(exampleNumber_);
    257       }
    258     }
    259 
    260     public void readExternal(ObjectInput objectInput) throws IOException {
    261       if (objectInput.readBoolean()) {
    262         setNationalNumberPattern(objectInput.readUTF());
    263       }
    264 
    265       if (objectInput.readBoolean()) {
    266         setPossibleNumberPattern(objectInput.readUTF());
    267       }
    268 
    269       if (objectInput.readBoolean()) {
    270         setExampleNumber(objectInput.readUTF());
    271       }
    272     }
    273   }
    274 
    275   public static class PhoneMetadata implements Externalizable {
    276     private static final long serialVersionUID = 1;
    277     public PhoneMetadata() {}
    278 
    279     /**
    280      * Provides a dummy builder.
    281      *
    282      * @see NumberFormat.Builder
    283      */
    284     public static final class Builder extends PhoneMetadata {
    285       public PhoneMetadata build() {
    286         return this;
    287       }
    288     }
    289     public static Builder newBuilder() {
    290       return new Builder();
    291     }
    292 
    293     // required PhoneNumberDesc general_desc = 1;
    294     private boolean hasGeneralDesc;
    295     private PhoneNumberDesc generalDesc_ = null;
    296     public boolean hasGeneralDesc() { return hasGeneralDesc; }
    297     public PhoneNumberDesc getGeneralDesc() { return generalDesc_; }
    298     public PhoneMetadata setGeneralDesc(PhoneNumberDesc value) {
    299       if (value == null) {
    300         throw new NullPointerException();
    301       }
    302       hasGeneralDesc = true;
    303       generalDesc_ = value;
    304       return this;
    305     }
    306 
    307     // required PhoneNumberDesc fixed_line = 2;
    308     private boolean hasFixedLine;
    309     private PhoneNumberDesc fixedLine_ = null;
    310     public boolean hasFixedLine() { return hasFixedLine; }
    311     public PhoneNumberDesc getFixedLine() { return fixedLine_; }
    312     public PhoneMetadata setFixedLine(PhoneNumberDesc value) {
    313       if (value == null) {
    314         throw new NullPointerException();
    315       }
    316       hasFixedLine = true;
    317       fixedLine_ = value;
    318       return this;
    319     }
    320 
    321     // required PhoneNumberDesc mobile = 3;
    322     private boolean hasMobile;
    323     private PhoneNumberDesc mobile_ = null;
    324     public boolean hasMobile() { return hasMobile; }
    325     public PhoneNumberDesc getMobile() { return mobile_; }
    326     public PhoneMetadata setMobile(PhoneNumberDesc value) {
    327       if (value == null) {
    328         throw new NullPointerException();
    329       }
    330       hasMobile = true;
    331       mobile_ = value;
    332       return this;
    333     }
    334 
    335     // required PhoneNumberDesc toll_free = 4;
    336     private boolean hasTollFree;
    337     private PhoneNumberDesc tollFree_ = null;
    338     public boolean hasTollFree() { return hasTollFree; }
    339     public PhoneNumberDesc getTollFree() { return tollFree_; }
    340     public PhoneMetadata setTollFree(PhoneNumberDesc value) {
    341       if (value == null) {
    342         throw new NullPointerException();
    343       }
    344       hasTollFree = true;
    345       tollFree_ = value;
    346       return this;
    347     }
    348 
    349     // required PhoneNumberDesc premium_rate = 5;
    350     private boolean hasPremiumRate;
    351     private PhoneNumberDesc premiumRate_ = null;
    352     public boolean hasPremiumRate() { return hasPremiumRate; }
    353     public PhoneNumberDesc getPremiumRate() { return premiumRate_; }
    354     public PhoneMetadata setPremiumRate(PhoneNumberDesc value) {
    355       if (value == null) {
    356         throw new NullPointerException();
    357       }
    358       hasPremiumRate = true;
    359       premiumRate_ = value;
    360       return this;
    361     }
    362 
    363     // required PhoneNumberDesc shared_cost = 6;
    364     private boolean hasSharedCost;
    365     private PhoneNumberDesc sharedCost_ = null;
    366     public boolean hasSharedCost() { return hasSharedCost; }
    367     public PhoneNumberDesc getSharedCost() { return sharedCost_; }
    368     public PhoneMetadata setSharedCost(PhoneNumberDesc value) {
    369       if (value == null) {
    370         throw new NullPointerException();
    371       }
    372       hasSharedCost = true;
    373       sharedCost_ = value;
    374       return this;
    375     }
    376 
    377     // required PhoneNumberDesc personal_number = 7;
    378     private boolean hasPersonalNumber;
    379     private PhoneNumberDesc personalNumber_ = null;
    380     public boolean hasPersonalNumber() { return hasPersonalNumber; }
    381     public PhoneNumberDesc getPersonalNumber() { return personalNumber_; }
    382     public PhoneMetadata setPersonalNumber(PhoneNumberDesc value) {
    383       if (value == null) {
    384         throw new NullPointerException();
    385       }
    386       hasPersonalNumber = true;
    387       personalNumber_ = value;
    388       return this;
    389     }
    390 
    391     // required PhoneNumberDesc voip = 8;
    392     private boolean hasVoip;
    393     private PhoneNumberDesc voip_ = null;
    394     public boolean hasVoip() { return hasVoip; }
    395     public PhoneNumberDesc getVoip() { return voip_; }
    396     public PhoneMetadata setVoip(PhoneNumberDesc value) {
    397       if (value == null) {
    398         throw new NullPointerException();
    399       }
    400       hasVoip = true;
    401       voip_ = value;
    402       return this;
    403     }
    404 
    405     // required PhoneNumberDesc pager = 21;
    406     private boolean hasPager;
    407     private PhoneNumberDesc pager_ = null;
    408     public boolean hasPager() { return hasPager; }
    409     public PhoneNumberDesc getPager() { return pager_; }
    410     public PhoneMetadata setPager(PhoneNumberDesc value) {
    411       if (value == null) {
    412         throw new NullPointerException();
    413       }
    414       hasPager = true;
    415       pager_ = value;
    416       return this;
    417     }
    418 
    419     // required PhoneNumberDesc uan = 25;
    420     private boolean hasUan;
    421     private PhoneNumberDesc uan_ = null;
    422     public boolean hasUan() { return hasUan; }
    423     public PhoneNumberDesc getUan() { return uan_; }
    424     public PhoneMetadata setUan(PhoneNumberDesc value) {
    425       if (value == null) {
    426         throw new NullPointerException();
    427       }
    428       hasUan = true;
    429       uan_ = value;
    430       return this;
    431     }
    432 
    433     // required PhoneNumberDesc noInternationalDialling = 24;
    434     private boolean hasNoInternationalDialling;
    435     private PhoneNumberDesc noInternationalDialling_ = null;
    436     public boolean hasNoInternationalDialling() { return hasNoInternationalDialling; }
    437     public PhoneNumberDesc getNoInternationalDialling() { return noInternationalDialling_; }
    438     public PhoneMetadata setNoInternationalDialling(PhoneNumberDesc value) {
    439       if (value == null) {
    440         throw new NullPointerException();
    441       }
    442       hasNoInternationalDialling = true;
    443       noInternationalDialling_ = value;
    444       return this;
    445     }
    446 
    447     // required string id = 9;
    448     private boolean hasId;
    449     private String id_ = "";
    450     public boolean hasId() { return hasId; }
    451     public String getId() { return id_; }
    452     public PhoneMetadata setId(String value) {
    453       hasId = true;
    454       id_ = value;
    455       return this;
    456     }
    457 
    458     // required int32 country_code = 10;
    459     private boolean hasCountryCode;
    460     private int countryCode_ = 0;
    461     public boolean hasCountryCode() { return hasCountryCode; }
    462     public int getCountryCode() { return countryCode_; }
    463     public PhoneMetadata setCountryCode(int value) {
    464       hasCountryCode = true;
    465       countryCode_ = value;
    466       return this;
    467     }
    468 
    469     // required string international_prefix = 11;
    470     private boolean hasInternationalPrefix;
    471     private String internationalPrefix_ = "";
    472     public boolean hasInternationalPrefix() { return hasInternationalPrefix; }
    473     public String getInternationalPrefix() { return internationalPrefix_; }
    474     public PhoneMetadata setInternationalPrefix(String value) {
    475       hasInternationalPrefix = true;
    476       internationalPrefix_ = value;
    477       return this;
    478     }
    479 
    480     // optional string preferred_international_prefix = 17;
    481     private boolean hasPreferredInternationalPrefix;
    482     private String preferredInternationalPrefix_ = "";
    483     public boolean hasPreferredInternationalPrefix() { return hasPreferredInternationalPrefix; }
    484     public String getPreferredInternationalPrefix() { return preferredInternationalPrefix_; }
    485     public PhoneMetadata setPreferredInternationalPrefix(String value) {
    486       hasPreferredInternationalPrefix = true;
    487       preferredInternationalPrefix_ = value;
    488       return this;
    489     }
    490 
    491     // optional string national_prefix = 12;
    492     private boolean hasNationalPrefix;
    493     private String nationalPrefix_ = "";
    494     public boolean hasNationalPrefix() { return hasNationalPrefix; }
    495     public String getNationalPrefix() { return nationalPrefix_; }
    496     public PhoneMetadata setNationalPrefix(String value) {
    497       hasNationalPrefix = true;
    498       nationalPrefix_ = value;
    499       return this;
    500     }
    501 
    502     // optional string preferred_extn_prefix = 13;
    503     private boolean hasPreferredExtnPrefix;
    504     private String preferredExtnPrefix_ = "";
    505     public boolean hasPreferredExtnPrefix() { return hasPreferredExtnPrefix; }
    506     public String getPreferredExtnPrefix() { return preferredExtnPrefix_; }
    507     public PhoneMetadata setPreferredExtnPrefix(String value) {
    508       hasPreferredExtnPrefix = true;
    509       preferredExtnPrefix_ = value;
    510       return this;
    511     }
    512 
    513     // optional string national_prefix_for_parsing = 15;
    514     private boolean hasNationalPrefixForParsing;
    515     private String nationalPrefixForParsing_ = "";
    516     public boolean hasNationalPrefixForParsing() { return hasNationalPrefixForParsing; }
    517     public String getNationalPrefixForParsing() { return nationalPrefixForParsing_; }
    518     public PhoneMetadata setNationalPrefixForParsing(String value) {
    519       hasNationalPrefixForParsing = true;
    520       nationalPrefixForParsing_ = value;
    521       return this;
    522     }
    523 
    524     // optional string national_prefix_transform_rule = 16;
    525     private boolean hasNationalPrefixTransformRule;
    526     private String nationalPrefixTransformRule_ = "";
    527     public boolean hasNationalPrefixTransformRule() { return hasNationalPrefixTransformRule; }
    528     public String getNationalPrefixTransformRule() { return nationalPrefixTransformRule_; }
    529     public PhoneMetadata setNationalPrefixTransformRule(String value) {
    530       hasNationalPrefixTransformRule = true;
    531       nationalPrefixTransformRule_ = value;
    532       return this;
    533     }
    534 
    535     // optional bool same_mobile_and_fixed_line_pattern = 18 [default = false];
    536     private boolean hasSameMobileAndFixedLinePattern;
    537     private boolean sameMobileAndFixedLinePattern_ = false;
    538     public boolean hasSameMobileAndFixedLinePattern() { return hasSameMobileAndFixedLinePattern; }
    539     public boolean isSameMobileAndFixedLinePattern() { return sameMobileAndFixedLinePattern_; }
    540     public PhoneMetadata setSameMobileAndFixedLinePattern(boolean value) {
    541       hasSameMobileAndFixedLinePattern = true;
    542       sameMobileAndFixedLinePattern_ = value;
    543       return this;
    544     }
    545 
    546     // repeated NumberFormat number_format = 19;
    547     private java.util.List<NumberFormat> numberFormat_ = new java.util.ArrayList<NumberFormat>();
    548     public java.util.List<NumberFormat> numberFormats() {
    549       return numberFormat_;
    550     }
    551     public int numberFormatSize() { return numberFormat_.size(); }
    552     public NumberFormat getNumberFormat(int index) {
    553       return numberFormat_.get(index);
    554     }
    555     public PhoneMetadata addNumberFormat(NumberFormat value) {
    556       if (value == null) {
    557         throw new NullPointerException();
    558       }
    559       numberFormat_.add(value);
    560       return this;
    561     }
    562 
    563     // repeated NumberFormat intl_number_format = 20;
    564     private java.util.List<NumberFormat> intlNumberFormat_ =
    565         new java.util.ArrayList<NumberFormat>();
    566     public java.util.List<NumberFormat> intlNumberFormats() {
    567       return intlNumberFormat_;
    568     }
    569     public int intlNumberFormatSize() { return intlNumberFormat_.size(); }
    570     public NumberFormat getIntlNumberFormat(int index) {
    571       return intlNumberFormat_.get(index);
    572     }
    573 
    574     public PhoneMetadata addIntlNumberFormat(NumberFormat value) {
    575       if (value == null) {
    576         throw new NullPointerException();
    577       }
    578       intlNumberFormat_.add(value);
    579       return this;
    580     }
    581     public PhoneMetadata clearIntlNumberFormat() {
    582       intlNumberFormat_.clear();
    583       return this;
    584     }
    585 
    586     // optional bool main_country_for_code = 22 [default = false];
    587     private boolean hasMainCountryForCode;
    588     private boolean mainCountryForCode_ = false;
    589     public boolean hasMainCountryForCode() { return hasMainCountryForCode; }
    590     public boolean isMainCountryForCode() { return mainCountryForCode_; }
    591     // Method that lets this class have the same interface as the one generated by Protocol Buffers
    592     // which is used by C++ build tools.
    593     public boolean getMainCountryForCode() { return mainCountryForCode_; }
    594     public PhoneMetadata setMainCountryForCode(boolean value) {
    595       hasMainCountryForCode = true;
    596       mainCountryForCode_ = value;
    597       return this;
    598     }
    599 
    600     // optional string leading_digits = 23;
    601     private boolean hasLeadingDigits;
    602     private String leadingDigits_ = "";
    603     public boolean hasLeadingDigits() { return hasLeadingDigits; }
    604     public String getLeadingDigits() { return leadingDigits_; }
    605     public PhoneMetadata setLeadingDigits(String value) {
    606       hasLeadingDigits = true;
    607       leadingDigits_ = value;
    608       return this;
    609     }
    610 
    611     // optional bool leading_zero_possible = 26 [default = false];
    612     private boolean hasLeadingZeroPossible;
    613     private boolean leadingZeroPossible_ = false;
    614     public boolean hasLeadingZeroPossible() { return hasLeadingZeroPossible; }
    615     public boolean isLeadingZeroPossible() { return leadingZeroPossible_; }
    616     public PhoneMetadata setLeadingZeroPossible(boolean value) {
    617       hasLeadingZeroPossible = true;
    618       leadingZeroPossible_ = value;
    619       return this;
    620     }
    621 
    622     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    623       objectOutput.writeBoolean(hasGeneralDesc);
    624       if (hasGeneralDesc) {
    625         generalDesc_.writeExternal(objectOutput);
    626       }
    627       objectOutput.writeBoolean(hasFixedLine);
    628       if (hasFixedLine) {
    629         fixedLine_.writeExternal(objectOutput);
    630       }
    631       objectOutput.writeBoolean(hasMobile);
    632       if (hasMobile) {
    633         mobile_.writeExternal(objectOutput);
    634       }
    635       objectOutput.writeBoolean(hasTollFree);
    636       if (hasTollFree) {
    637         tollFree_.writeExternal(objectOutput);
    638       }
    639       objectOutput.writeBoolean(hasPremiumRate);
    640       if (hasPremiumRate) {
    641         premiumRate_.writeExternal(objectOutput);
    642       }
    643       objectOutput.writeBoolean(hasSharedCost);
    644       if (hasSharedCost) {
    645         sharedCost_.writeExternal(objectOutput);
    646       }
    647       objectOutput.writeBoolean(hasPersonalNumber);
    648       if (hasPersonalNumber) {
    649         personalNumber_.writeExternal(objectOutput);
    650       }
    651       objectOutput.writeBoolean(hasVoip);
    652       if (hasVoip) {
    653         voip_.writeExternal(objectOutput);
    654       }
    655       objectOutput.writeBoolean(hasPager);
    656       if (hasPager) {
    657         pager_.writeExternal(objectOutput);
    658       }
    659       objectOutput.writeBoolean(hasUan);
    660       if (hasUan) {
    661         uan_.writeExternal(objectOutput);
    662       }
    663       objectOutput.writeBoolean(hasNoInternationalDialling);
    664       if (hasNoInternationalDialling) {
    665         noInternationalDialling_.writeExternal(objectOutput);
    666       }
    667 
    668       objectOutput.writeUTF(id_);
    669       objectOutput.writeInt(countryCode_);
    670       objectOutput.writeUTF(internationalPrefix_);
    671 
    672       objectOutput.writeBoolean(hasPreferredInternationalPrefix);
    673       if (hasPreferredInternationalPrefix) {
    674         objectOutput.writeUTF(preferredInternationalPrefix_);
    675       }
    676 
    677       objectOutput.writeBoolean(hasNationalPrefix);
    678       if (hasNationalPrefix) {
    679         objectOutput.writeUTF(nationalPrefix_);
    680       }
    681 
    682       objectOutput.writeBoolean(hasPreferredExtnPrefix);
    683       if (hasPreferredExtnPrefix) {
    684         objectOutput.writeUTF(preferredExtnPrefix_);
    685       }
    686 
    687       objectOutput.writeBoolean(hasNationalPrefixForParsing);
    688       if (hasNationalPrefixForParsing) {
    689         objectOutput.writeUTF(nationalPrefixForParsing_);
    690       }
    691 
    692       objectOutput.writeBoolean(hasNationalPrefixTransformRule);
    693       if (hasNationalPrefixTransformRule) {
    694         objectOutput.writeUTF(nationalPrefixTransformRule_);
    695       }
    696 
    697       objectOutput.writeBoolean(sameMobileAndFixedLinePattern_);
    698 
    699       int numberFormatSize = numberFormatSize();
    700       objectOutput.writeInt(numberFormatSize);
    701       for (int i = 0; i < numberFormatSize; i++) {
    702         numberFormat_.get(i).writeExternal(objectOutput);
    703       }
    704 
    705       int intlNumberFormatSize = intlNumberFormatSize();
    706       objectOutput.writeInt(intlNumberFormatSize);
    707       for (int i = 0; i < intlNumberFormatSize; i++) {
    708         intlNumberFormat_.get(i).writeExternal(objectOutput);
    709       }
    710 
    711       objectOutput.writeBoolean(mainCountryForCode_);
    712 
    713       objectOutput.writeBoolean(hasLeadingDigits);
    714       if (hasLeadingDigits) {
    715         objectOutput.writeUTF(leadingDigits_);
    716       }
    717 
    718       objectOutput.writeBoolean(leadingZeroPossible_);
    719     }
    720 
    721     public void readExternal(ObjectInput objectInput) throws IOException {
    722       boolean hasDesc = objectInput.readBoolean();
    723       if (hasDesc) {
    724         PhoneNumberDesc desc = new PhoneNumberDesc();
    725         desc.readExternal(objectInput);
    726         setGeneralDesc(desc);
    727       }
    728       hasDesc = objectInput.readBoolean();
    729       if (hasDesc) {
    730         PhoneNumberDesc desc = new PhoneNumberDesc();
    731         desc.readExternal(objectInput);
    732         setFixedLine(desc);
    733       }
    734       hasDesc = objectInput.readBoolean();
    735       if (hasDesc) {
    736         PhoneNumberDesc desc = new PhoneNumberDesc();
    737         desc.readExternal(objectInput);
    738         setMobile(desc);
    739       }
    740       hasDesc = objectInput.readBoolean();
    741       if (hasDesc) {
    742         PhoneNumberDesc desc = new PhoneNumberDesc();
    743         desc.readExternal(objectInput);
    744         setTollFree(desc);
    745       }
    746       hasDesc = objectInput.readBoolean();
    747       if (hasDesc) {
    748         PhoneNumberDesc desc = new PhoneNumberDesc();
    749         desc.readExternal(objectInput);
    750         setPremiumRate(desc);
    751       }
    752       hasDesc = objectInput.readBoolean();
    753       if (hasDesc) {
    754         PhoneNumberDesc desc = new PhoneNumberDesc();
    755         desc.readExternal(objectInput);
    756         setSharedCost(desc);
    757       }
    758       hasDesc = objectInput.readBoolean();
    759       if (hasDesc) {
    760         PhoneNumberDesc desc = new PhoneNumberDesc();
    761         desc.readExternal(objectInput);
    762         setPersonalNumber(desc);
    763       }
    764       hasDesc = objectInput.readBoolean();
    765       if (hasDesc) {
    766         PhoneNumberDesc desc = new PhoneNumberDesc();
    767         desc.readExternal(objectInput);
    768         setVoip(desc);
    769       }
    770       hasDesc = objectInput.readBoolean();
    771       if (hasDesc) {
    772         PhoneNumberDesc desc = new PhoneNumberDesc();
    773         desc.readExternal(objectInput);
    774         setPager(desc);
    775       }
    776       hasDesc = objectInput.readBoolean();
    777       if (hasDesc) {
    778         PhoneNumberDesc desc = new PhoneNumberDesc();
    779         desc.readExternal(objectInput);
    780         setUan(desc);
    781       }
    782       hasDesc = objectInput.readBoolean();
    783       if (hasDesc) {
    784         PhoneNumberDesc desc = new PhoneNumberDesc();
    785         desc.readExternal(objectInput);
    786         setNoInternationalDialling(desc);
    787       }
    788 
    789       setId(objectInput.readUTF());
    790       setCountryCode(objectInput.readInt());
    791       setInternationalPrefix(objectInput.readUTF());
    792 
    793       boolean hasString = objectInput.readBoolean();
    794       if (hasString) {
    795         setPreferredInternationalPrefix(objectInput.readUTF());
    796       }
    797 
    798       hasString = objectInput.readBoolean();
    799       if (hasString) {
    800         setNationalPrefix(objectInput.readUTF());
    801       }
    802 
    803       hasString = objectInput.readBoolean();
    804       if (hasString) {
    805         setPreferredExtnPrefix(objectInput.readUTF());
    806       }
    807 
    808       hasString = objectInput.readBoolean();
    809       if (hasString) {
    810         setNationalPrefixForParsing(objectInput.readUTF());
    811       }
    812 
    813       hasString = objectInput.readBoolean();
    814       if (hasString) {
    815         setNationalPrefixTransformRule(objectInput.readUTF());
    816       }
    817 
    818       setSameMobileAndFixedLinePattern(objectInput.readBoolean());
    819 
    820       int nationalFormatSize = objectInput.readInt();
    821       for (int i = 0; i < nationalFormatSize; i++) {
    822         NumberFormat numFormat = new NumberFormat();
    823         numFormat.readExternal(objectInput);
    824         numberFormat_.add(numFormat);
    825       }
    826 
    827       int intlNumberFormatSize = objectInput.readInt();
    828       for (int i = 0; i < intlNumberFormatSize; i++) {
    829         NumberFormat numFormat = new NumberFormat();
    830         numFormat.readExternal(objectInput);
    831         intlNumberFormat_.add(numFormat);
    832       }
    833 
    834       setMainCountryForCode(objectInput.readBoolean());
    835 
    836       hasString = objectInput.readBoolean();
    837       if (hasString) {
    838         setLeadingDigits(objectInput.readUTF());
    839       }
    840 
    841       setLeadingZeroPossible(objectInput.readBoolean());
    842     }
    843   }
    844 
    845   public static class PhoneMetadataCollection implements Externalizable {
    846     private static final long serialVersionUID = 1;
    847     public PhoneMetadataCollection() {}
    848 
    849     /**
    850      * Provides a dummy builder.
    851      *
    852      * @see NumberFormat.Builder
    853      */
    854     public static final class Builder extends PhoneMetadataCollection {
    855       public PhoneMetadataCollection build() {
    856         return this;
    857       }
    858     }
    859     public static Builder newBuilder() {
    860       return new Builder();
    861     }
    862 
    863     // repeated PhoneMetadata metadata = 1;
    864     private java.util.List<PhoneMetadata> metadata_ = new java.util.ArrayList<PhoneMetadata>();
    865 
    866     public java.util.List<PhoneMetadata> getMetadataList() {
    867       return metadata_;
    868     }
    869     public int getMetadataCount() { return metadata_.size(); }
    870 
    871     public PhoneMetadataCollection addMetadata(PhoneMetadata value) {
    872       if (value == null) {
    873         throw new NullPointerException();
    874       }
    875       metadata_.add(value);
    876       return this;
    877     }
    878 
    879     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    880       int size = getMetadataCount();
    881       objectOutput.writeInt(size);
    882       for (int i = 0; i < size; i++) {
    883         metadata_.get(i).writeExternal(objectOutput);
    884       }
    885     }
    886 
    887     public void readExternal(ObjectInput objectInput) throws IOException {
    888       int size = objectInput.readInt();
    889       for (int i = 0; i < size; i++) {
    890         PhoneMetadata metadata = new PhoneMetadata();
    891         metadata.readExternal(objectInput);
    892         metadata_.add(metadata);
    893       }
    894     }
    895 
    896     public PhoneMetadataCollection clear() {
    897       metadata_.clear();
    898       return this;
    899     }
    900   }
    901 }
    902