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.rrlp_components; 18 19 /* 20 */ 21 22 23 // 24 // 25 import android.location.cts.asn1.base.Asn1Null; 26 import android.location.cts.asn1.base.Asn1Object; 27 import android.location.cts.asn1.base.Asn1Sequence; 28 import android.location.cts.asn1.base.Asn1Tag; 29 import android.location.cts.asn1.base.BitStream; 30 import android.location.cts.asn1.base.BitStreamReader; 31 import android.location.cts.asn1.base.SequenceComponent; 32 import com.google.common.collect.ImmutableList; 33 import java.util.Collection; 34 import javax.annotation.Nullable; 35 36 37 /** 38 */ 39 public class ControlHeader extends Asn1Sequence { 40 // 41 42 private static final Asn1Tag TAG_ControlHeader 43 = Asn1Tag.fromClassAndNumber(-1, -1); 44 45 public ControlHeader() { 46 super(); 47 } 48 49 @Override 50 @Nullable 51 protected Asn1Tag getTag() { 52 return TAG_ControlHeader; 53 } 54 55 @Override 56 protected boolean isTagImplicit() { 57 return true; 58 } 59 60 public static Collection<Asn1Tag> getPossibleFirstTags() { 61 if (TAG_ControlHeader != null) { 62 return ImmutableList.of(TAG_ControlHeader); 63 } else { 64 return Asn1Sequence.getPossibleFirstTags(); 65 } 66 } 67 68 /** 69 * Creates a new ControlHeader from encoded stream. 70 */ 71 public static ControlHeader fromPerUnaligned(byte[] encodedBytes) { 72 ControlHeader result = new ControlHeader(); 73 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 74 return result; 75 } 76 77 /** 78 * Creates a new ControlHeader from encoded stream. 79 */ 80 public static ControlHeader fromPerAligned(byte[] encodedBytes) { 81 ControlHeader result = new ControlHeader(); 82 result.decodePerAligned(new BitStreamReader(encodedBytes)); 83 return result; 84 } 85 86 87 88 @Override protected boolean isExtensible() { 89 return false; 90 } 91 92 @Override public boolean containsExtensionValues() { 93 for (SequenceComponent extensionComponent : getExtensionComponents()) { 94 if (extensionComponent.isExplicitlySet()) return true; 95 } 96 return false; 97 } 98 99 100 private ReferenceTime referenceTime_; 101 public ReferenceTime getReferenceTime() { 102 return referenceTime_; 103 } 104 /** 105 * @throws ClassCastException if value is not a ReferenceTime 106 */ 107 public void setReferenceTime(Asn1Object value) { 108 this.referenceTime_ = (ReferenceTime) value; 109 } 110 public ReferenceTime setReferenceTimeToNewInstance() { 111 referenceTime_ = new ReferenceTime(); 112 return referenceTime_; 113 } 114 115 private RefLocation refLocation_; 116 public RefLocation getRefLocation() { 117 return refLocation_; 118 } 119 /** 120 * @throws ClassCastException if value is not a RefLocation 121 */ 122 public void setRefLocation(Asn1Object value) { 123 this.refLocation_ = (RefLocation) value; 124 } 125 public RefLocation setRefLocationToNewInstance() { 126 refLocation_ = new RefLocation(); 127 return refLocation_; 128 } 129 130 private DGPSCorrections dgpsCorrections_; 131 public DGPSCorrections getDgpsCorrections() { 132 return dgpsCorrections_; 133 } 134 /** 135 * @throws ClassCastException if value is not a DGPSCorrections 136 */ 137 public void setDgpsCorrections(Asn1Object value) { 138 this.dgpsCorrections_ = (DGPSCorrections) value; 139 } 140 public DGPSCorrections setDgpsCorrectionsToNewInstance() { 141 dgpsCorrections_ = new DGPSCorrections(); 142 return dgpsCorrections_; 143 } 144 145 private NavigationModel navigationModel_; 146 public NavigationModel getNavigationModel() { 147 return navigationModel_; 148 } 149 /** 150 * @throws ClassCastException if value is not a NavigationModel 151 */ 152 public void setNavigationModel(Asn1Object value) { 153 this.navigationModel_ = (NavigationModel) value; 154 } 155 public NavigationModel setNavigationModelToNewInstance() { 156 navigationModel_ = new NavigationModel(); 157 return navigationModel_; 158 } 159 160 private IonosphericModel ionosphericModel_; 161 public IonosphericModel getIonosphericModel() { 162 return ionosphericModel_; 163 } 164 /** 165 * @throws ClassCastException if value is not a IonosphericModel 166 */ 167 public void setIonosphericModel(Asn1Object value) { 168 this.ionosphericModel_ = (IonosphericModel) value; 169 } 170 public IonosphericModel setIonosphericModelToNewInstance() { 171 ionosphericModel_ = new IonosphericModel(); 172 return ionosphericModel_; 173 } 174 175 private UTCModel utcModel_; 176 public UTCModel getUtcModel() { 177 return utcModel_; 178 } 179 /** 180 * @throws ClassCastException if value is not a UTCModel 181 */ 182 public void setUtcModel(Asn1Object value) { 183 this.utcModel_ = (UTCModel) value; 184 } 185 public UTCModel setUtcModelToNewInstance() { 186 utcModel_ = new UTCModel(); 187 return utcModel_; 188 } 189 190 private Almanac almanac_; 191 public Almanac getAlmanac() { 192 return almanac_; 193 } 194 /** 195 * @throws ClassCastException if value is not a Almanac 196 */ 197 public void setAlmanac(Asn1Object value) { 198 this.almanac_ = (Almanac) value; 199 } 200 public Almanac setAlmanacToNewInstance() { 201 almanac_ = new Almanac(); 202 return almanac_; 203 } 204 205 private AcquisAssist acquisAssist_; 206 public AcquisAssist getAcquisAssist() { 207 return acquisAssist_; 208 } 209 /** 210 * @throws ClassCastException if value is not a AcquisAssist 211 */ 212 public void setAcquisAssist(Asn1Object value) { 213 this.acquisAssist_ = (AcquisAssist) value; 214 } 215 public AcquisAssist setAcquisAssistToNewInstance() { 216 acquisAssist_ = new AcquisAssist(); 217 return acquisAssist_; 218 } 219 220 private SeqOf_BadSatelliteSet realTimeIntegrity_; 221 public SeqOf_BadSatelliteSet getRealTimeIntegrity() { 222 return realTimeIntegrity_; 223 } 224 /** 225 * @throws ClassCastException if value is not a SeqOf_BadSatelliteSet 226 */ 227 public void setRealTimeIntegrity(Asn1Object value) { 228 this.realTimeIntegrity_ = (SeqOf_BadSatelliteSet) value; 229 } 230 public SeqOf_BadSatelliteSet setRealTimeIntegrityToNewInstance() { 231 realTimeIntegrity_ = new SeqOf_BadSatelliteSet(); 232 return realTimeIntegrity_; 233 } 234 235 236 237 238 239 240 @Override public Iterable<? extends SequenceComponent> getComponents() { 241 ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder(); 242 243 builder.add(new SequenceComponent() { 244 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0); 245 246 @Override public boolean isExplicitlySet() { 247 return getReferenceTime() != null; 248 } 249 250 @Override public boolean hasDefaultValue() { 251 return false; 252 } 253 254 @Override public boolean isOptional() { 255 return true; 256 } 257 258 @Override public Asn1Object getComponentValue() { 259 return getReferenceTime(); 260 } 261 262 @Override public void setToNewInstance() { 263 setReferenceTimeToNewInstance(); 264 } 265 266 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 267 return tag == null ? ReferenceTime.getPossibleFirstTags() : ImmutableList.of(tag); 268 } 269 270 @Override 271 public Asn1Tag getTag() { 272 return tag; 273 } 274 275 @Override 276 public boolean isImplicitTagging() { 277 return true; 278 } 279 280 @Override public String toIndentedString(String indent) { 281 return "referenceTime : " 282 + getReferenceTime().toIndentedString(indent); 283 } 284 }); 285 286 builder.add(new SequenceComponent() { 287 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1); 288 289 @Override public boolean isExplicitlySet() { 290 return getRefLocation() != null; 291 } 292 293 @Override public boolean hasDefaultValue() { 294 return false; 295 } 296 297 @Override public boolean isOptional() { 298 return true; 299 } 300 301 @Override public Asn1Object getComponentValue() { 302 return getRefLocation(); 303 } 304 305 @Override public void setToNewInstance() { 306 setRefLocationToNewInstance(); 307 } 308 309 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 310 return tag == null ? RefLocation.getPossibleFirstTags() : ImmutableList.of(tag); 311 } 312 313 @Override 314 public Asn1Tag getTag() { 315 return tag; 316 } 317 318 @Override 319 public boolean isImplicitTagging() { 320 return true; 321 } 322 323 @Override public String toIndentedString(String indent) { 324 return "refLocation : " 325 + getRefLocation().toIndentedString(indent); 326 } 327 }); 328 329 builder.add(new SequenceComponent() { 330 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 2); 331 332 @Override public boolean isExplicitlySet() { 333 return getDgpsCorrections() != null; 334 } 335 336 @Override public boolean hasDefaultValue() { 337 return false; 338 } 339 340 @Override public boolean isOptional() { 341 return true; 342 } 343 344 @Override public Asn1Object getComponentValue() { 345 return getDgpsCorrections(); 346 } 347 348 @Override public void setToNewInstance() { 349 setDgpsCorrectionsToNewInstance(); 350 } 351 352 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 353 return tag == null ? DGPSCorrections.getPossibleFirstTags() : ImmutableList.of(tag); 354 } 355 356 @Override 357 public Asn1Tag getTag() { 358 return tag; 359 } 360 361 @Override 362 public boolean isImplicitTagging() { 363 return true; 364 } 365 366 @Override public String toIndentedString(String indent) { 367 return "dgpsCorrections : " 368 + getDgpsCorrections().toIndentedString(indent); 369 } 370 }); 371 372 builder.add(new SequenceComponent() { 373 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 3); 374 375 @Override public boolean isExplicitlySet() { 376 return getNavigationModel() != null; 377 } 378 379 @Override public boolean hasDefaultValue() { 380 return false; 381 } 382 383 @Override public boolean isOptional() { 384 return true; 385 } 386 387 @Override public Asn1Object getComponentValue() { 388 return getNavigationModel(); 389 } 390 391 @Override public void setToNewInstance() { 392 setNavigationModelToNewInstance(); 393 } 394 395 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 396 return tag == null ? NavigationModel.getPossibleFirstTags() : ImmutableList.of(tag); 397 } 398 399 @Override 400 public Asn1Tag getTag() { 401 return tag; 402 } 403 404 @Override 405 public boolean isImplicitTagging() { 406 return true; 407 } 408 409 @Override public String toIndentedString(String indent) { 410 return "navigationModel : " 411 + getNavigationModel().toIndentedString(indent); 412 } 413 }); 414 415 builder.add(new SequenceComponent() { 416 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 4); 417 418 @Override public boolean isExplicitlySet() { 419 return getIonosphericModel() != null; 420 } 421 422 @Override public boolean hasDefaultValue() { 423 return false; 424 } 425 426 @Override public boolean isOptional() { 427 return true; 428 } 429 430 @Override public Asn1Object getComponentValue() { 431 return getIonosphericModel(); 432 } 433 434 @Override public void setToNewInstance() { 435 setIonosphericModelToNewInstance(); 436 } 437 438 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 439 return tag == null ? IonosphericModel.getPossibleFirstTags() : ImmutableList.of(tag); 440 } 441 442 @Override 443 public Asn1Tag getTag() { 444 return tag; 445 } 446 447 @Override 448 public boolean isImplicitTagging() { 449 return true; 450 } 451 452 @Override public String toIndentedString(String indent) { 453 return "ionosphericModel : " 454 + getIonosphericModel().toIndentedString(indent); 455 } 456 }); 457 458 builder.add(new SequenceComponent() { 459 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 5); 460 461 @Override public boolean isExplicitlySet() { 462 return getUtcModel() != null; 463 } 464 465 @Override public boolean hasDefaultValue() { 466 return false; 467 } 468 469 @Override public boolean isOptional() { 470 return true; 471 } 472 473 @Override public Asn1Object getComponentValue() { 474 return getUtcModel(); 475 } 476 477 @Override public void setToNewInstance() { 478 setUtcModelToNewInstance(); 479 } 480 481 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 482 return tag == null ? UTCModel.getPossibleFirstTags() : ImmutableList.of(tag); 483 } 484 485 @Override 486 public Asn1Tag getTag() { 487 return tag; 488 } 489 490 @Override 491 public boolean isImplicitTagging() { 492 return true; 493 } 494 495 @Override public String toIndentedString(String indent) { 496 return "utcModel : " 497 + getUtcModel().toIndentedString(indent); 498 } 499 }); 500 501 builder.add(new SequenceComponent() { 502 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 6); 503 504 @Override public boolean isExplicitlySet() { 505 return getAlmanac() != null; 506 } 507 508 @Override public boolean hasDefaultValue() { 509 return false; 510 } 511 512 @Override public boolean isOptional() { 513 return true; 514 } 515 516 @Override public Asn1Object getComponentValue() { 517 return getAlmanac(); 518 } 519 520 @Override public void setToNewInstance() { 521 setAlmanacToNewInstance(); 522 } 523 524 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 525 return tag == null ? Almanac.getPossibleFirstTags() : ImmutableList.of(tag); 526 } 527 528 @Override 529 public Asn1Tag getTag() { 530 return tag; 531 } 532 533 @Override 534 public boolean isImplicitTagging() { 535 return true; 536 } 537 538 @Override public String toIndentedString(String indent) { 539 return "almanac : " 540 + getAlmanac().toIndentedString(indent); 541 } 542 }); 543 544 builder.add(new SequenceComponent() { 545 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 7); 546 547 @Override public boolean isExplicitlySet() { 548 return getAcquisAssist() != null; 549 } 550 551 @Override public boolean hasDefaultValue() { 552 return false; 553 } 554 555 @Override public boolean isOptional() { 556 return true; 557 } 558 559 @Override public Asn1Object getComponentValue() { 560 return getAcquisAssist(); 561 } 562 563 @Override public void setToNewInstance() { 564 setAcquisAssistToNewInstance(); 565 } 566 567 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 568 return tag == null ? AcquisAssist.getPossibleFirstTags() : ImmutableList.of(tag); 569 } 570 571 @Override 572 public Asn1Tag getTag() { 573 return tag; 574 } 575 576 @Override 577 public boolean isImplicitTagging() { 578 return true; 579 } 580 581 @Override public String toIndentedString(String indent) { 582 return "acquisAssist : " 583 + getAcquisAssist().toIndentedString(indent); 584 } 585 }); 586 587 builder.add(new SequenceComponent() { 588 Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 8); 589 590 @Override public boolean isExplicitlySet() { 591 return getRealTimeIntegrity() != null; 592 } 593 594 @Override public boolean hasDefaultValue() { 595 return false; 596 } 597 598 @Override public boolean isOptional() { 599 return true; 600 } 601 602 @Override public Asn1Object getComponentValue() { 603 return getRealTimeIntegrity(); 604 } 605 606 @Override public void setToNewInstance() { 607 setRealTimeIntegrityToNewInstance(); 608 } 609 610 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 611 return tag == null ? SeqOf_BadSatelliteSet.getPossibleFirstTags() : ImmutableList.of(tag); 612 } 613 614 @Override 615 public Asn1Tag getTag() { 616 return tag; 617 } 618 619 @Override 620 public boolean isImplicitTagging() { 621 return true; 622 } 623 624 @Override public String toIndentedString(String indent) { 625 return "realTimeIntegrity : " 626 + getRealTimeIntegrity().toIndentedString(indent); 627 } 628 }); 629 630 return builder.build(); 631 } 632 633 @Override public Iterable<? extends SequenceComponent> 634 getExtensionComponents() { 635 ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder(); 636 637 return builder.build(); 638 } 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 @Override public Iterable<BitStream> encodePerUnaligned() { 663 return super.encodePerUnaligned(); 664 } 665 666 @Override public Iterable<BitStream> encodePerAligned() { 667 return super.encodePerAligned(); 668 } 669 670 @Override public void decodePerUnaligned(BitStreamReader reader) { 671 super.decodePerUnaligned(reader); 672 } 673 674 @Override public void decodePerAligned(BitStreamReader reader) { 675 super.decodePerAligned(reader); 676 } 677 678 @Override public String toString() { 679 return toIndentedString(""); 680 } 681 682 public String toIndentedString(String indent) { 683 StringBuilder builder = new StringBuilder(); 684 builder.append("ControlHeader = {\n"); 685 final String internalIndent = indent + " "; 686 for (SequenceComponent component : getComponents()) { 687 if (component.isExplicitlySet()) { 688 builder.append(internalIndent) 689 .append(component.toIndentedString(internalIndent)); 690 } 691 } 692 if (isExtensible()) { 693 builder.append(internalIndent).append("...\n"); 694 for (SequenceComponent component : getExtensionComponents()) { 695 if (component.isExplicitlySet()) { 696 builder.append(internalIndent) 697 .append(component.toIndentedString(internalIndent)); 698 } 699 } 700 } 701 builder.append(indent).append("};\n"); 702 return builder.toString(); 703 } 704 } 705