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