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