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