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