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.Asn1Null; 26 import android.location.cts.asn1.base.Asn1SequenceOf; 27 import android.location.cts.asn1.base.Asn1Tag; 28 import android.location.cts.asn1.base.BitStream; 29 import android.location.cts.asn1.base.BitStreamReader; 30 import com.google.common.collect.ImmutableList; 31 import java.util.Collection; 32 import javax.annotation.Nullable; 33 34 35 /** 36 */ 37 public class MNC 38 extends Asn1SequenceOf<MCC_MNC_Digit> { 39 // 40 41 private static final Asn1Tag TAG_MNC 42 = Asn1Tag.fromClassAndNumber(-1, -1); 43 MNC()44 public MNC() { 45 super(); 46 setMinSize(2); 47 setMaxSize(3); 48 49 } 50 51 @Override 52 @Nullable getTag()53 protected Asn1Tag getTag() { 54 return TAG_MNC; 55 } 56 57 @Override isTagImplicit()58 protected boolean isTagImplicit() { 59 return true; 60 } 61 getPossibleFirstTags()62 public static Collection<Asn1Tag> getPossibleFirstTags() { 63 if (TAG_MNC != null) { 64 return ImmutableList.of(TAG_MNC); 65 } else { 66 return Asn1SequenceOf.getPossibleFirstTags(); 67 } 68 } 69 70 /** 71 * Creates a new MNC from encoded stream. 72 */ fromPerUnaligned(byte[] encodedBytes)73 public static MNC fromPerUnaligned(byte[] encodedBytes) { 74 MNC result = new MNC(); 75 result.decodePerUnaligned(new BitStreamReader(encodedBytes)); 76 return result; 77 } 78 79 /** 80 * Creates a new MNC from encoded stream. 81 */ fromPerAligned(byte[] encodedBytes)82 public static MNC fromPerAligned(byte[] encodedBytes) { 83 MNC result = new MNC(); 84 result.decodePerAligned(new BitStreamReader(encodedBytes)); 85 return result; 86 } 87 88 createAndAddValue()89 @Override public MCC_MNC_Digit createAndAddValue() { 90 MCC_MNC_Digit value = new MCC_MNC_Digit(); 91 add(value); 92 return value; 93 } 94 95 96 encodePerUnaligned()97 @Override public Iterable<BitStream> encodePerUnaligned() { 98 return super.encodePerUnaligned(); 99 } 100 encodePerAligned()101 @Override public Iterable<BitStream> encodePerAligned() { 102 return super.encodePerAligned(); 103 } 104 decodePerUnaligned(BitStreamReader reader)105 @Override public void decodePerUnaligned(BitStreamReader reader) { 106 super.decodePerUnaligned(reader); 107 } 108 decodePerAligned(BitStreamReader reader)109 @Override public void decodePerAligned(BitStreamReader reader) { 110 super.decodePerAligned(reader); 111 } 112 toString()113 @Override public String toString() { 114 return toIndentedString(""); 115 } 116 toIndentedString(String indent)117 public String toIndentedString(String indent) { 118 StringBuilder builder = new StringBuilder(); 119 builder.append("MNC = [\n"); 120 final String internalIndent = indent + " "; 121 for (MCC_MNC_Digit value : getValues()) { 122 builder.append(internalIndent) 123 .append(value.toIndentedString(internalIndent)); 124 } 125 builder.append(indent).append("];\n"); 126 return builder.toString(); 127 } 128 } 129