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