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.Asn1Integer; 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 MultipleSets extends Asn1Sequence { 41 // 42 43 private static final Asn1Tag TAG_MultipleSets 44 = Asn1Tag.fromClassAndNumber(-1, -1); 45 46 public MultipleSets() { 47 super(); 48 } 49 50 @Override 51 @Nullable 52 protected Asn1Tag getTag() { 53 return TAG_MultipleSets; 54 } 55 56 @Override 57 protected boolean isTagImplicit() { 58 return true; 59 } 60 61 public static Collection<Asn1Tag> getPossibleFirstTags() { 62 if (TAG_MultipleSets != null) { 63 return ImmutableList.of(TAG_MultipleSets); 64 } else { 65 return Asn1Sequence.getPossibleFirstTags(); 66 } 67 } 68 69 /** 70 * Creates a new MultipleSets from encoded stream. 71 */ 72 public static MultipleSets fromPerUnaligned(byte[] encodedBytes) { 73 MultipleSets result = new MultipleSets(); 74 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 75 return result; 76 } 77 78 /** 79 * Creates a new MultipleSets from encoded stream. 80 */ 81 public static MultipleSets fromPerAligned(byte[] encodedBytes) { 82 MultipleSets result = new MultipleSets(); 83 result.decodePerAligned(new BitStreamReader(encodedBytes)); 84 return result; 85 } 86 87 88 89 @Override protected boolean isExtensible() { 90 return false; 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 MultipleSets.nbrOfSetsType nbrOfSets_; 102 public MultipleSets.nbrOfSetsType getNbrOfSets() { 103 return nbrOfSets_; 104 } 105 /** 106 * @throws ClassCastException if value is not a MultipleSets.nbrOfSetsType 107 */ 108 public void setNbrOfSets(Asn1Object value) { 109 this.nbrOfSets_ = (MultipleSets.nbrOfSetsType) value; 110 } 111 public MultipleSets.nbrOfSetsType setNbrOfSetsToNewInstance() { 112 nbrOfSets_ = new MultipleSets.nbrOfSetsType(); 113 return nbrOfSets_; 114 } 115 116 private MultipleSets.nbrOfReferenceBTSsType nbrOfReferenceBTSs_; 117 public MultipleSets.nbrOfReferenceBTSsType getNbrOfReferenceBTSs() { 118 return nbrOfReferenceBTSs_; 119 } 120 /** 121 * @throws ClassCastException if value is not a MultipleSets.nbrOfReferenceBTSsType 122 */ 123 public void setNbrOfReferenceBTSs(Asn1Object value) { 124 this.nbrOfReferenceBTSs_ = (MultipleSets.nbrOfReferenceBTSsType) value; 125 } 126 public MultipleSets.nbrOfReferenceBTSsType setNbrOfReferenceBTSsToNewInstance() { 127 nbrOfReferenceBTSs_ = new MultipleSets.nbrOfReferenceBTSsType(); 128 return nbrOfReferenceBTSs_; 129 } 130 131 private ReferenceRelation referenceRelation_; 132 public ReferenceRelation getReferenceRelation() { 133 return referenceRelation_; 134 } 135 /** 136 * @throws ClassCastException if value is not a ReferenceRelation 137 */ 138 public void setReferenceRelation(Asn1Object value) { 139 this.referenceRelation_ = (ReferenceRelation) value; 140 } 141 public ReferenceRelation setReferenceRelationToNewInstance() { 142 referenceRelation_ = new ReferenceRelation(); 143 return referenceRelation_; 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 getNbrOfSets() != 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 getNbrOfSets(); 171 } 172 173 @Override public void setToNewInstance() { 174 setNbrOfSetsToNewInstance(); 175 } 176 177 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 178 return tag == null ? MultipleSets.nbrOfSetsType.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 "nbrOfSets : " 193 + getNbrOfSets().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 getNbrOfReferenceBTSs() != 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 getNbrOfReferenceBTSs(); 214 } 215 216 @Override public void setToNewInstance() { 217 setNbrOfReferenceBTSsToNewInstance(); 218 } 219 220 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 221 return tag == null ? MultipleSets.nbrOfReferenceBTSsType.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 "nbrOfReferenceBTSs : " 236 + getNbrOfReferenceBTSs().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 getReferenceRelation() != 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 getReferenceRelation(); 257 } 258 259 @Override public void setToNewInstance() { 260 setReferenceRelationToNewInstance(); 261 } 262 263 @Override public Collection<Asn1Tag> getPossibleFirstTags() { 264 return tag == null ? ReferenceRelation.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 "referenceRelation : " 279 + getReferenceRelation().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 nbrOfSetsType extends Asn1Integer { 303 // 304 305 private static final Asn1Tag TAG_nbrOfSetsType 306 = Asn1Tag.fromClassAndNumber(-1, -1); 307 308 public nbrOfSetsType() { 309 super(); 310 setValueRange("2", "3"); 311 312 } 313 314 @Override 315 @Nullable 316 protected Asn1Tag getTag() { 317 return TAG_nbrOfSetsType; 318 } 319 320 @Override 321 protected boolean isTagImplicit() { 322 return true; 323 } 324 325 public static Collection<Asn1Tag> getPossibleFirstTags() { 326 if (TAG_nbrOfSetsType != null) { 327 return ImmutableList.of(TAG_nbrOfSetsType); 328 } else { 329 return Asn1Integer.getPossibleFirstTags(); 330 } 331 } 332 333 /** 334 * Creates a new nbrOfSetsType from encoded stream. 335 */ 336 public static nbrOfSetsType fromPerUnaligned(byte[] encodedBytes) { 337 nbrOfSetsType result = new nbrOfSetsType(); 338 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 339 return result; 340 } 341 342 /** 343 * Creates a new nbrOfSetsType from encoded stream. 344 */ 345 public static nbrOfSetsType fromPerAligned(byte[] encodedBytes) { 346 nbrOfSetsType result = new nbrOfSetsType(); 347 result.decodePerAligned(new BitStreamReader(encodedBytes)); 348 return result; 349 } 350 351 @Override public Iterable<BitStream> encodePerUnaligned() { 352 return super.encodePerUnaligned(); 353 } 354 355 @Override public Iterable<BitStream> encodePerAligned() { 356 return super.encodePerAligned(); 357 } 358 359 @Override public void decodePerUnaligned(BitStreamReader reader) { 360 super.decodePerUnaligned(reader); 361 } 362 363 @Override public void decodePerAligned(BitStreamReader reader) { 364 super.decodePerAligned(reader); 365 } 366 367 @Override public String toString() { 368 return toIndentedString(""); 369 } 370 371 public String toIndentedString(String indent) { 372 return "nbrOfSetsType = " + getInteger() + ";\n"; 373 } 374 } 375 376 377 /* 378 */ 379 380 381 // 382 383 /** 384 */ 385 public static class nbrOfReferenceBTSsType extends Asn1Integer { 386 // 387 388 private static final Asn1Tag TAG_nbrOfReferenceBTSsType 389 = Asn1Tag.fromClassAndNumber(-1, -1); 390 391 public nbrOfReferenceBTSsType() { 392 super(); 393 setValueRange("1", "3"); 394 395 } 396 397 @Override 398 @Nullable 399 protected Asn1Tag getTag() { 400 return TAG_nbrOfReferenceBTSsType; 401 } 402 403 @Override 404 protected boolean isTagImplicit() { 405 return true; 406 } 407 408 public static Collection<Asn1Tag> getPossibleFirstTags() { 409 if (TAG_nbrOfReferenceBTSsType != null) { 410 return ImmutableList.of(TAG_nbrOfReferenceBTSsType); 411 } else { 412 return Asn1Integer.getPossibleFirstTags(); 413 } 414 } 415 416 /** 417 * Creates a new nbrOfReferenceBTSsType from encoded stream. 418 */ 419 public static nbrOfReferenceBTSsType fromPerUnaligned(byte[] encodedBytes) { 420 nbrOfReferenceBTSsType result = new nbrOfReferenceBTSsType(); 421 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 422 return result; 423 } 424 425 /** 426 * Creates a new nbrOfReferenceBTSsType from encoded stream. 427 */ 428 public static nbrOfReferenceBTSsType fromPerAligned(byte[] encodedBytes) { 429 nbrOfReferenceBTSsType result = new nbrOfReferenceBTSsType(); 430 result.decodePerAligned(new BitStreamReader(encodedBytes)); 431 return result; 432 } 433 434 @Override public Iterable<BitStream> encodePerUnaligned() { 435 return super.encodePerUnaligned(); 436 } 437 438 @Override public Iterable<BitStream> encodePerAligned() { 439 return super.encodePerAligned(); 440 } 441 442 @Override public void decodePerUnaligned(BitStreamReader reader) { 443 super.decodePerUnaligned(reader); 444 } 445 446 @Override public void decodePerAligned(BitStreamReader reader) { 447 super.decodePerAligned(reader); 448 } 449 450 @Override public String toString() { 451 return toIndentedString(""); 452 } 453 454 public String toIndentedString(String indent) { 455 return "nbrOfReferenceBTSsType = " + getInteger() + ";\n"; 456 } 457 } 458 459 460 461 462 463 464 465 @Override public Iterable<BitStream> encodePerUnaligned() { 466 return super.encodePerUnaligned(); 467 } 468 469 @Override public Iterable<BitStream> encodePerAligned() { 470 return super.encodePerAligned(); 471 } 472 473 @Override public void decodePerUnaligned(BitStreamReader reader) { 474 super.decodePerUnaligned(reader); 475 } 476 477 @Override public void decodePerAligned(BitStreamReader reader) { 478 super.decodePerAligned(reader); 479 } 480 481 @Override public String toString() { 482 return toIndentedString(""); 483 } 484 485 public String toIndentedString(String indent) { 486 StringBuilder builder = new StringBuilder(); 487 builder.append("MultipleSets = {\n"); 488 final String internalIndent = indent + " "; 489 for (SequenceComponent component : getComponents()) { 490 if (component.isExplicitlySet()) { 491 builder.append(internalIndent) 492 .append(component.toIndentedString(internalIndent)); 493 } 494 } 495 if (isExtensible()) { 496 builder.append(internalIndent).append("...\n"); 497 for (SequenceComponent component : getExtensionComponents()) { 498 if (component.isExplicitlySet()) { 499 builder.append(internalIndent) 500 .append(component.toIndentedString(internalIndent)); 501 } 502 } 503 } 504 builder.append(indent).append("};\n"); 505 return builder.toString(); 506 } 507 } 508