1 /* 2 * Copyright (C) 2017 The Android Open Source Project 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 package android.location.cts.asn1.supl2.ulp_components; 18 19 /* 20 */ 21 22 23 // 24 // 25 import android.location.cts.asn1.base.Asn1BitString; 26 import android.location.cts.asn1.base.Asn1Choice; 27 import android.location.cts.asn1.base.Asn1IA5String; 28 import android.location.cts.asn1.base.Asn1Null; 29 import android.location.cts.asn1.base.Asn1Object; 30 import android.location.cts.asn1.base.Asn1OctetString; 31 import android.location.cts.asn1.base.Asn1Tag; 32 import android.location.cts.asn1.base.BitStream; 33 import android.location.cts.asn1.base.BitStreamReader; 34 import android.location.cts.asn1.base.ChoiceComponent; 35 import com.google.common.collect.ImmutableList; 36 import java.nio.ByteBuffer; 37 import java.util.Collection; 38 import java.util.HashMap; 39 import java.util.Map; 40 import javax.annotation.Nullable; 41 42 43 /** 44 */ 45 public class SETId extends Asn1Choice { 46 // 47 48 private static final Asn1Tag TAG_SETId 49 = Asn1Tag.fromClassAndNumber(-1, -1); 50 51 private static final Map<Asn1Tag, Select> tagToSelection = new HashMap<>(); 52 53 private boolean extension; 54 private ChoiceComponent selection; 55 private Asn1Object element; 56 57 static { 58 for (Select select : Select.values()) { 59 for (Asn1Tag tag : select.getPossibleFirstTags()) { 60 Select select0; 61 if ((select0 = tagToSelection.put(tag, select)) != null) { 62 throw new IllegalStateException( 63 "SETId: " + tag + " maps to both " + select0 + " and " + select); 64 } 65 } 66 } 67 } 68 SETId()69 public SETId() { 70 super(); 71 } 72 73 @Override 74 @Nullable getTag()75 protected Asn1Tag getTag() { 76 return TAG_SETId; 77 } 78 79 @Override isTagImplicit()80 protected boolean isTagImplicit() { 81 return true; 82 } 83 getPossibleFirstTags()84 public static Collection<Asn1Tag> getPossibleFirstTags() { 85 if (TAG_SETId != null) { 86 return ImmutableList.of(TAG_SETId); 87 } else { 88 return tagToSelection.keySet(); 89 } 90 } 91 92 /** 93 * Creates a new SETId from encoded stream. 94 */ fromPerUnaligned(byte[] encodedBytes)95 public static SETId fromPerUnaligned(byte[] encodedBytes) { 96 SETId result = new SETId(); 97 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 98 return result; 99 } 100 101 /** 102 * Creates a new SETId from encoded stream. 103 */ fromPerAligned(byte[] encodedBytes)104 public static SETId fromPerAligned(byte[] encodedBytes) { 105 SETId result = new SETId(); 106 result.decodePerAligned(new BitStreamReader(encodedBytes)); 107 return result; 108 } 109 110 111 hasExtensionValue()112 @Override protected boolean hasExtensionValue() { 113 return extension; 114 } 115 getSelectionOrdinal()116 @Override protected Integer getSelectionOrdinal() { 117 return selection.ordinal(); 118 } 119 120 @Nullable 121 @Override getSelectedComponent()122 protected ChoiceComponent getSelectedComponent() { 123 return selection; 124 } 125 getOptionCount()126 @Override protected int getOptionCount() { 127 if (hasExtensionValue()) { 128 return Extend.values().length; 129 } 130 return Select.values().length; 131 } 132 createAndSetValue(boolean isExtensionValue, int ordinal)133 protected Asn1Object createAndSetValue(boolean isExtensionValue, 134 int ordinal) { 135 extension = isExtensionValue; 136 if (isExtensionValue) { 137 selection = Extend.values()[ordinal]; 138 } else { 139 selection = Select.values()[ordinal]; 140 } 141 element = selection.createElement(); 142 return element; 143 } 144 createAndSetValue(Asn1Tag tag)145 @Override protected ChoiceComponent createAndSetValue(Asn1Tag tag) { 146 Select select = tagToSelection.get(tag); 147 if (select == null) { 148 throw new IllegalArgumentException("Unknown selection tag: " + tag); 149 } 150 element = select.createElement(); 151 selection = select; 152 extension = false; 153 return select; 154 } 155 isExtensible()156 @Override protected boolean isExtensible() { 157 return true; 158 } 159 getValue()160 @Override protected Asn1Object getValue() { 161 return element; 162 } 163 164 165 private static enum Select implements ChoiceComponent { 166 167 $Msisdn(Asn1Tag.fromClassAndNumber(2, 0), 168 true) { 169 @Override createElement()170 public Asn1Object createElement() { 171 return new SETId.msisdnType(); 172 } 173 174 @Override getPossibleFirstTags()175 Collection<Asn1Tag> getPossibleFirstTags() { 176 return tag == null ? SETId.msisdnType.getPossibleFirstTags() : ImmutableList.of(tag); 177 } 178 179 @Override elementIndentedString(Asn1Object element, String indent)180 String elementIndentedString(Asn1Object element, String indent) { 181 return toString() + " : " + element.toIndentedString(indent); 182 } 183 }, 184 185 $Mdn(Asn1Tag.fromClassAndNumber(2, 1), 186 true) { 187 @Override createElement()188 public Asn1Object createElement() { 189 return new SETId.mdnType(); 190 } 191 192 @Override getPossibleFirstTags()193 Collection<Asn1Tag> getPossibleFirstTags() { 194 return tag == null ? SETId.mdnType.getPossibleFirstTags() : ImmutableList.of(tag); 195 } 196 197 @Override elementIndentedString(Asn1Object element, String indent)198 String elementIndentedString(Asn1Object element, String indent) { 199 return toString() + " : " + element.toIndentedString(indent); 200 } 201 }, 202 203 $Min(Asn1Tag.fromClassAndNumber(2, 2), 204 true) { 205 @Override createElement()206 public Asn1Object createElement() { 207 return new SETId.minType(); 208 } 209 210 @Override getPossibleFirstTags()211 Collection<Asn1Tag> getPossibleFirstTags() { 212 return tag == null ? SETId.minType.getPossibleFirstTags() : ImmutableList.of(tag); 213 } 214 215 @Override elementIndentedString(Asn1Object element, String indent)216 String elementIndentedString(Asn1Object element, String indent) { 217 return toString() + " : " + element.toIndentedString(indent); 218 } 219 }, 220 221 $Imsi(Asn1Tag.fromClassAndNumber(2, 3), 222 true) { 223 @Override createElement()224 public Asn1Object createElement() { 225 return new SETId.imsiType(); 226 } 227 228 @Override getPossibleFirstTags()229 Collection<Asn1Tag> getPossibleFirstTags() { 230 return tag == null ? SETId.imsiType.getPossibleFirstTags() : ImmutableList.of(tag); 231 } 232 233 @Override elementIndentedString(Asn1Object element, String indent)234 String elementIndentedString(Asn1Object element, String indent) { 235 return toString() + " : " + element.toIndentedString(indent); 236 } 237 }, 238 239 $Nai(Asn1Tag.fromClassAndNumber(2, 4), 240 true) { 241 @Override createElement()242 public Asn1Object createElement() { 243 return new SETId.naiType(); 244 } 245 246 @Override getPossibleFirstTags()247 Collection<Asn1Tag> getPossibleFirstTags() { 248 return tag == null ? SETId.naiType.getPossibleFirstTags() : ImmutableList.of(tag); 249 } 250 251 @Override elementIndentedString(Asn1Object element, String indent)252 String elementIndentedString(Asn1Object element, String indent) { 253 return toString() + " : " + element.toIndentedString(indent); 254 } 255 }, 256 257 $IPAddress(Asn1Tag.fromClassAndNumber(2, 5), 258 true) { 259 @Override createElement()260 public Asn1Object createElement() { 261 return new IPAddress(); 262 } 263 264 @Override getPossibleFirstTags()265 Collection<Asn1Tag> getPossibleFirstTags() { 266 return tag == null ? IPAddress.getPossibleFirstTags() : ImmutableList.of(tag); 267 } 268 269 @Override elementIndentedString(Asn1Object element, String indent)270 String elementIndentedString(Asn1Object element, String indent) { 271 return toString() + " : " + element.toIndentedString(indent); 272 } 273 }, 274 275 ; 276 277 @Nullable final Asn1Tag tag; 278 final boolean isImplicitTagging; 279 Select(@ullable Asn1Tag tag, boolean isImplicitTagging)280 Select(@Nullable Asn1Tag tag, boolean isImplicitTagging) { 281 this.tag = tag; 282 this.isImplicitTagging = isImplicitTagging; 283 } 284 285 @Override createElement()286 public Asn1Object createElement() { 287 throw new IllegalStateException("Select template error"); 288 } 289 290 @Override 291 @Nullable getTag()292 public Asn1Tag getTag() { 293 return tag; 294 } 295 296 @Override isImplicitTagging()297 public boolean isImplicitTagging() { 298 return isImplicitTagging; 299 } 300 getPossibleFirstTags()301 abstract Collection<Asn1Tag> getPossibleFirstTags(); 302 elementIndentedString(Asn1Object element, String indent)303 abstract String elementIndentedString(Asn1Object element, String indent); 304 } 305 306 /* 307 */ 308 309 310 // 311 312 /** 313 */ 314 public static class msisdnType extends Asn1OctetString { 315 // 316 317 private static final Asn1Tag TAG_msisdnType 318 = Asn1Tag.fromClassAndNumber(-1, -1); 319 msisdnType()320 public msisdnType() { 321 super(); 322 setMinSize(8); 323 setMaxSize(8); 324 325 } 326 327 @Override 328 @Nullable getTag()329 protected Asn1Tag getTag() { 330 return TAG_msisdnType; 331 } 332 333 @Override isTagImplicit()334 protected boolean isTagImplicit() { 335 return true; 336 } 337 getPossibleFirstTags()338 public static Collection<Asn1Tag> getPossibleFirstTags() { 339 if (TAG_msisdnType != null) { 340 return ImmutableList.of(TAG_msisdnType); 341 } else { 342 return Asn1OctetString.getPossibleFirstTags(); 343 } 344 } 345 346 /** 347 * Creates a new msisdnType from encoded stream. 348 */ fromPerUnaligned(byte[] encodedBytes)349 public static msisdnType fromPerUnaligned(byte[] encodedBytes) { 350 msisdnType result = new msisdnType(); 351 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 352 return result; 353 } 354 355 /** 356 * Creates a new msisdnType from encoded stream. 357 */ fromPerAligned(byte[] encodedBytes)358 public static msisdnType fromPerAligned(byte[] encodedBytes) { 359 msisdnType result = new msisdnType(); 360 result.decodePerAligned(new BitStreamReader(encodedBytes)); 361 return result; 362 } 363 encodePerUnaligned()364 @Override public Iterable<BitStream> encodePerUnaligned() { 365 return super.encodePerUnaligned(); 366 } 367 encodePerAligned()368 @Override public Iterable<BitStream> encodePerAligned() { 369 return super.encodePerAligned(); 370 } 371 decodePerUnaligned(BitStreamReader reader)372 @Override public void decodePerUnaligned(BitStreamReader reader) { 373 super.decodePerUnaligned(reader); 374 } 375 decodePerAligned(BitStreamReader reader)376 @Override public void decodePerAligned(BitStreamReader reader) { 377 super.decodePerAligned(reader); 378 } 379 getTypeName()380 @Override protected String getTypeName() { 381 return "msisdnType"; 382 } 383 } 384 385 isMsisdn()386 public boolean isMsisdn() { 387 return !hasExtensionValue() && Select.$Msisdn == selection; 388 } 389 390 /** 391 * @throws {@code IllegalStateException} if {@code !isMsisdn}. 392 */ 393 @SuppressWarnings("unchecked") getMsisdn()394 public SETId.msisdnType getMsisdn() { 395 if (!isMsisdn()) { 396 throw new IllegalStateException("SETId value not a Msisdn"); 397 } 398 return (SETId.msisdnType) element; 399 } 400 setMsisdn(SETId.msisdnType selected)401 public void setMsisdn(SETId.msisdnType selected) { 402 selection = Select.$Msisdn; 403 extension = false; 404 element = selected; 405 } 406 setMsisdnToNewInstance()407 public SETId.msisdnType setMsisdnToNewInstance() { 408 SETId.msisdnType element = new SETId.msisdnType(); 409 setMsisdn(element); 410 return element; 411 } 412 413 /* 414 */ 415 416 417 // 418 419 /** 420 */ 421 public static class mdnType extends Asn1OctetString { 422 // 423 424 private static final Asn1Tag TAG_mdnType 425 = Asn1Tag.fromClassAndNumber(-1, -1); 426 mdnType()427 public mdnType() { 428 super(); 429 setMinSize(8); 430 setMaxSize(8); 431 432 } 433 434 @Override 435 @Nullable getTag()436 protected Asn1Tag getTag() { 437 return TAG_mdnType; 438 } 439 440 @Override isTagImplicit()441 protected boolean isTagImplicit() { 442 return true; 443 } 444 getPossibleFirstTags()445 public static Collection<Asn1Tag> getPossibleFirstTags() { 446 if (TAG_mdnType != null) { 447 return ImmutableList.of(TAG_mdnType); 448 } else { 449 return Asn1OctetString.getPossibleFirstTags(); 450 } 451 } 452 453 /** 454 * Creates a new mdnType from encoded stream. 455 */ fromPerUnaligned(byte[] encodedBytes)456 public static mdnType fromPerUnaligned(byte[] encodedBytes) { 457 mdnType result = new mdnType(); 458 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 459 return result; 460 } 461 462 /** 463 * Creates a new mdnType from encoded stream. 464 */ fromPerAligned(byte[] encodedBytes)465 public static mdnType fromPerAligned(byte[] encodedBytes) { 466 mdnType result = new mdnType(); 467 result.decodePerAligned(new BitStreamReader(encodedBytes)); 468 return result; 469 } 470 encodePerUnaligned()471 @Override public Iterable<BitStream> encodePerUnaligned() { 472 return super.encodePerUnaligned(); 473 } 474 encodePerAligned()475 @Override public Iterable<BitStream> encodePerAligned() { 476 return super.encodePerAligned(); 477 } 478 decodePerUnaligned(BitStreamReader reader)479 @Override public void decodePerUnaligned(BitStreamReader reader) { 480 super.decodePerUnaligned(reader); 481 } 482 decodePerAligned(BitStreamReader reader)483 @Override public void decodePerAligned(BitStreamReader reader) { 484 super.decodePerAligned(reader); 485 } 486 getTypeName()487 @Override protected String getTypeName() { 488 return "mdnType"; 489 } 490 } 491 492 isMdn()493 public boolean isMdn() { 494 return !hasExtensionValue() && Select.$Mdn == selection; 495 } 496 497 /** 498 * @throws {@code IllegalStateException} if {@code !isMdn}. 499 */ 500 @SuppressWarnings("unchecked") getMdn()501 public SETId.mdnType getMdn() { 502 if (!isMdn()) { 503 throw new IllegalStateException("SETId value not a Mdn"); 504 } 505 return (SETId.mdnType) element; 506 } 507 setMdn(SETId.mdnType selected)508 public void setMdn(SETId.mdnType selected) { 509 selection = Select.$Mdn; 510 extension = false; 511 element = selected; 512 } 513 setMdnToNewInstance()514 public SETId.mdnType setMdnToNewInstance() { 515 SETId.mdnType element = new SETId.mdnType(); 516 setMdn(element); 517 return element; 518 } 519 520 /* 521 */ 522 523 524 // 525 526 /** 527 */ 528 public static class minType extends Asn1BitString { 529 // 530 531 private static final Asn1Tag TAG_minType 532 = Asn1Tag.fromClassAndNumber(-1, -1); 533 minType()534 public minType() { 535 super(); 536 setMinSize(34); 537 setMaxSize(34); 538 539 } 540 541 @Override 542 @Nullable getTag()543 protected Asn1Tag getTag() { 544 return TAG_minType; 545 } 546 547 @Override isTagImplicit()548 protected boolean isTagImplicit() { 549 return true; 550 } 551 getPossibleFirstTags()552 public static Collection<Asn1Tag> getPossibleFirstTags() { 553 if (TAG_minType != null) { 554 return ImmutableList.of(TAG_minType); 555 } else { 556 return Asn1BitString.getPossibleFirstTags(); 557 } 558 } 559 560 /** 561 * Creates a new minType from encoded stream. 562 */ fromPerUnaligned(byte[] encodedBytes)563 public static minType fromPerUnaligned(byte[] encodedBytes) { 564 minType result = new minType(); 565 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 566 return result; 567 } 568 569 /** 570 * Creates a new minType from encoded stream. 571 */ fromPerAligned(byte[] encodedBytes)572 public static minType fromPerAligned(byte[] encodedBytes) { 573 minType result = new minType(); 574 result.decodePerAligned(new BitStreamReader(encodedBytes)); 575 return result; 576 } 577 encodePerUnaligned()578 @Override public Iterable<BitStream> encodePerUnaligned() { 579 return super.encodePerUnaligned(); 580 } 581 encodePerAligned()582 @Override public Iterable<BitStream> encodePerAligned() { 583 return super.encodePerAligned(); 584 } 585 decodePerUnaligned(BitStreamReader reader)586 @Override public void decodePerUnaligned(BitStreamReader reader) { 587 super.decodePerUnaligned(reader); 588 } 589 decodePerAligned(BitStreamReader reader)590 @Override public void decodePerAligned(BitStreamReader reader) { 591 super.decodePerAligned(reader); 592 } 593 toString()594 @Override public String toString() { 595 return toIndentedString(""); 596 } 597 toIndentedString(String indent)598 public String toIndentedString(String indent) { 599 return "minType = " + getValue() + ";\n"; 600 } 601 } 602 603 isMin()604 public boolean isMin() { 605 return !hasExtensionValue() && Select.$Min == selection; 606 } 607 608 /** 609 * @throws {@code IllegalStateException} if {@code !isMin}. 610 */ 611 @SuppressWarnings("unchecked") getMin()612 public SETId.minType getMin() { 613 if (!isMin()) { 614 throw new IllegalStateException("SETId value not a Min"); 615 } 616 return (SETId.minType) element; 617 } 618 setMin(SETId.minType selected)619 public void setMin(SETId.minType selected) { 620 selection = Select.$Min; 621 extension = false; 622 element = selected; 623 } 624 setMinToNewInstance()625 public SETId.minType setMinToNewInstance() { 626 SETId.minType element = new SETId.minType(); 627 setMin(element); 628 return element; 629 } 630 631 /* 632 */ 633 634 635 // 636 637 /** 638 */ 639 public static class imsiType extends Asn1OctetString { 640 // 641 642 private static final Asn1Tag TAG_imsiType 643 = Asn1Tag.fromClassAndNumber(-1, -1); 644 imsiType()645 public imsiType() { 646 super(); 647 setMinSize(8); 648 setMaxSize(8); 649 650 } 651 652 @Override 653 @Nullable getTag()654 protected Asn1Tag getTag() { 655 return TAG_imsiType; 656 } 657 658 @Override isTagImplicit()659 protected boolean isTagImplicit() { 660 return true; 661 } 662 getPossibleFirstTags()663 public static Collection<Asn1Tag> getPossibleFirstTags() { 664 if (TAG_imsiType != null) { 665 return ImmutableList.of(TAG_imsiType); 666 } else { 667 return Asn1OctetString.getPossibleFirstTags(); 668 } 669 } 670 671 /** 672 * Creates a new imsiType from encoded stream. 673 */ fromPerUnaligned(byte[] encodedBytes)674 public static imsiType fromPerUnaligned(byte[] encodedBytes) { 675 imsiType result = new imsiType(); 676 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 677 return result; 678 } 679 680 /** 681 * Creates a new imsiType from encoded stream. 682 */ fromPerAligned(byte[] encodedBytes)683 public static imsiType fromPerAligned(byte[] encodedBytes) { 684 imsiType result = new imsiType(); 685 result.decodePerAligned(new BitStreamReader(encodedBytes)); 686 return result; 687 } 688 encodePerUnaligned()689 @Override public Iterable<BitStream> encodePerUnaligned() { 690 return super.encodePerUnaligned(); 691 } 692 encodePerAligned()693 @Override public Iterable<BitStream> encodePerAligned() { 694 return super.encodePerAligned(); 695 } 696 decodePerUnaligned(BitStreamReader reader)697 @Override public void decodePerUnaligned(BitStreamReader reader) { 698 super.decodePerUnaligned(reader); 699 } 700 decodePerAligned(BitStreamReader reader)701 @Override public void decodePerAligned(BitStreamReader reader) { 702 super.decodePerAligned(reader); 703 } 704 getTypeName()705 @Override protected String getTypeName() { 706 return "imsiType"; 707 } 708 } 709 710 isImsi()711 public boolean isImsi() { 712 return !hasExtensionValue() && Select.$Imsi == selection; 713 } 714 715 /** 716 * @throws {@code IllegalStateException} if {@code !isImsi}. 717 */ 718 @SuppressWarnings("unchecked") getImsi()719 public SETId.imsiType getImsi() { 720 if (!isImsi()) { 721 throw new IllegalStateException("SETId value not a Imsi"); 722 } 723 return (SETId.imsiType) element; 724 } 725 setImsi(SETId.imsiType selected)726 public void setImsi(SETId.imsiType selected) { 727 selection = Select.$Imsi; 728 extension = false; 729 element = selected; 730 } 731 setImsiToNewInstance()732 public SETId.imsiType setImsiToNewInstance() { 733 SETId.imsiType element = new SETId.imsiType(); 734 setImsi(element); 735 return element; 736 } 737 738 /* 739 */ 740 741 742 // 743 744 /** 745 */ 746 public static class naiType extends Asn1IA5String { 747 // 748 749 private static final Asn1Tag TAG_naiType 750 = Asn1Tag.fromClassAndNumber(-1, -1); 751 naiType()752 public naiType() { 753 super(); 754 setMinSize(1); 755 setMaxSize(1000); 756 757 758 } 759 760 @Override 761 @Nullable getTag()762 protected Asn1Tag getTag() { 763 return TAG_naiType; 764 } 765 766 @Override isTagImplicit()767 protected boolean isTagImplicit() { 768 return true; 769 } 770 getPossibleFirstTags()771 public static Collection<Asn1Tag> getPossibleFirstTags() { 772 if (TAG_naiType != null) { 773 return ImmutableList.of(TAG_naiType); 774 } else { 775 return Asn1IA5String.getPossibleFirstTags(); 776 } 777 } 778 779 /** 780 * Creates a new naiType from encoded stream. 781 */ fromPerUnaligned(byte[] encodedBytes)782 public static naiType fromPerUnaligned(byte[] encodedBytes) { 783 naiType result = new naiType(); 784 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 785 return result; 786 } 787 788 /** 789 * Creates a new naiType from encoded stream. 790 */ fromPerAligned(byte[] encodedBytes)791 public static naiType fromPerAligned(byte[] encodedBytes) { 792 naiType result = new naiType(); 793 result.decodePerAligned(new BitStreamReader(encodedBytes)); 794 return result; 795 } 796 encodePerUnaligned()797 @Override public Iterable<BitStream> encodePerUnaligned() { 798 return super.encodePerUnaligned(); 799 } 800 encodePerAligned()801 @Override public Iterable<BitStream> encodePerAligned() { 802 return super.encodePerAligned(); 803 } 804 decodePerUnaligned(BitStreamReader reader)805 @Override public void decodePerUnaligned(BitStreamReader reader) { 806 super.decodePerUnaligned(reader); 807 } 808 decodePerAligned(BitStreamReader reader)809 @Override public void decodePerAligned(BitStreamReader reader) { 810 super.decodePerAligned(reader); 811 } 812 toString()813 @Override public String toString() { 814 return toIndentedString(""); 815 } 816 toIndentedString(String indent)817 public String toIndentedString(String indent) { 818 return "naiType = " + getValue() + ";\n"; 819 } 820 } 821 822 isNai()823 public boolean isNai() { 824 return !hasExtensionValue() && Select.$Nai == selection; 825 } 826 827 /** 828 * @throws {@code IllegalStateException} if {@code !isNai}. 829 */ 830 @SuppressWarnings("unchecked") getNai()831 public SETId.naiType getNai() { 832 if (!isNai()) { 833 throw new IllegalStateException("SETId value not a Nai"); 834 } 835 return (SETId.naiType) element; 836 } 837 setNai(SETId.naiType selected)838 public void setNai(SETId.naiType selected) { 839 selection = Select.$Nai; 840 extension = false; 841 element = selected; 842 } 843 setNaiToNewInstance()844 public SETId.naiType setNaiToNewInstance() { 845 SETId.naiType element = new SETId.naiType(); 846 setNai(element); 847 return element; 848 } 849 850 851 isIPAddress()852 public boolean isIPAddress() { 853 return !hasExtensionValue() && Select.$IPAddress == selection; 854 } 855 856 /** 857 * @throws {@code IllegalStateException} if {@code !isIPAddress}. 858 */ 859 @SuppressWarnings("unchecked") getIPAddress()860 public IPAddress getIPAddress() { 861 if (!isIPAddress()) { 862 throw new IllegalStateException("SETId value not a IPAddress"); 863 } 864 return (IPAddress) element; 865 } 866 setIPAddress(IPAddress selected)867 public void setIPAddress(IPAddress selected) { 868 selection = Select.$IPAddress; 869 extension = false; 870 element = selected; 871 } 872 setIPAddressToNewInstance()873 public IPAddress setIPAddressToNewInstance() { 874 IPAddress element = new IPAddress(); 875 setIPAddress(element); 876 return element; 877 } 878 879 880 private static enum Extend implements ChoiceComponent { 881 882 ; 883 @Nullable private final Asn1Tag tag; 884 private final boolean isImplicitTagging; 885 Extend(@ullable Asn1Tag tag, boolean isImplicitTagging)886 Extend(@Nullable Asn1Tag tag, boolean isImplicitTagging) { 887 this.tag = tag; 888 this.isImplicitTagging = isImplicitTagging; 889 } 890 createElement()891 public Asn1Object createElement() { 892 throw new IllegalStateException("Extend template error"); 893 } 894 895 @Override 896 @Nullable getTag()897 public Asn1Tag getTag() { 898 return tag; 899 } 900 901 @Override isImplicitTagging()902 public boolean isImplicitTagging() { 903 return isImplicitTagging; 904 } 905 elementIndentedString(Asn1Object element, String indent)906 String elementIndentedString(Asn1Object element, String indent) { 907 throw new IllegalStateException("Extend template error"); 908 } 909 } 910 911 encodePerUnaligned()912 @Override public Iterable<BitStream> encodePerUnaligned() { 913 return super.encodePerUnaligned(); 914 } 915 encodePerAligned()916 @Override public Iterable<BitStream> encodePerAligned() { 917 return super.encodePerAligned(); 918 } 919 decodePerUnaligned(BitStreamReader reader)920 @Override public void decodePerUnaligned(BitStreamReader reader) { 921 super.decodePerUnaligned(reader); 922 } 923 decodePerAligned(BitStreamReader reader)924 @Override public void decodePerAligned(BitStreamReader reader) { 925 super.decodePerAligned(reader); 926 } 927 toString()928 @Override public String toString() { 929 return toIndentedString(""); 930 } 931 elementIndentedString(String indent)932 private String elementIndentedString(String indent) { 933 if (element == null) { 934 return "null;\n"; 935 } 936 if (extension) { 937 return Extend.values()[selection.ordinal()] 938 .elementIndentedString(element, indent + " "); 939 } else { 940 return Select.values()[selection.ordinal()] 941 .elementIndentedString(element, indent + " "); 942 } 943 } 944 toIndentedString(String indent)945 public String toIndentedString(String indent) { 946 return "SETId = " + elementIndentedString(indent) + indent + ";\n"; 947 } 948 } 949