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