• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.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 com.google.common.collect.ImmutableList;
33 import java.util.Collection;
34 import javax.annotation.Nullable;
35 
36 
37 /**
38 */
39 public  class PLMN_Identity extends Asn1Sequence {
40   //
41 
42   private static final Asn1Tag TAG_PLMN_Identity
43       = Asn1Tag.fromClassAndNumber(-1, -1);
44 
PLMN_Identity()45   public PLMN_Identity() {
46     super();
47   }
48 
49   @Override
50   @Nullable
getTag()51   protected Asn1Tag getTag() {
52     return TAG_PLMN_Identity;
53   }
54 
55   @Override
isTagImplicit()56   protected boolean isTagImplicit() {
57     return true;
58   }
59 
getPossibleFirstTags()60   public static Collection<Asn1Tag> getPossibleFirstTags() {
61     if (TAG_PLMN_Identity != null) {
62       return ImmutableList.of(TAG_PLMN_Identity);
63     } else {
64       return Asn1Sequence.getPossibleFirstTags();
65     }
66   }
67 
68   /**
69    * Creates a new PLMN_Identity from encoded stream.
70    */
fromPerUnaligned(byte[] encodedBytes)71   public static PLMN_Identity fromPerUnaligned(byte[] encodedBytes) {
72     PLMN_Identity result = new PLMN_Identity();
73     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
74     return result;
75   }
76 
77   /**
78    * Creates a new PLMN_Identity from encoded stream.
79    */
fromPerAligned(byte[] encodedBytes)80   public static PLMN_Identity fromPerAligned(byte[] encodedBytes) {
81     PLMN_Identity result = new PLMN_Identity();
82     result.decodePerAligned(new BitStreamReader(encodedBytes));
83     return result;
84   }
85 
86 
87 
isExtensible()88   @Override protected boolean isExtensible() {
89     return false;
90   }
91 
containsExtensionValues()92   @Override public boolean containsExtensionValues() {
93     for (SequenceComponent extensionComponent : getExtensionComponents()) {
94       if (extensionComponent.isExplicitlySet()) return true;
95     }
96     return false;
97   }
98 
99 
100   private MCC mcc_;
getMcc()101   public MCC getMcc() {
102     return mcc_;
103   }
104   /**
105    * @throws ClassCastException if value is not a MCC
106    */
setMcc(Asn1Object value)107   public void setMcc(Asn1Object value) {
108     this.mcc_ = (MCC) value;
109   }
setMccToNewInstance()110   public MCC setMccToNewInstance() {
111     mcc_ = new MCC();
112     return mcc_;
113   }
114 
115   private MNC mnc_;
getMnc()116   public MNC getMnc() {
117     return mnc_;
118   }
119   /**
120    * @throws ClassCastException if value is not a MNC
121    */
setMnc(Asn1Object value)122   public void setMnc(Asn1Object value) {
123     this.mnc_ = (MNC) value;
124   }
setMncToNewInstance()125   public MNC setMncToNewInstance() {
126     mnc_ = new MNC();
127     return mnc_;
128   }
129 
130 
131 
132 
133 
134 
getComponents()135   @Override public Iterable<? extends SequenceComponent> getComponents() {
136     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
137 
138     builder.add(new SequenceComponent() {
139           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0);
140 
141           @Override public boolean isExplicitlySet() {
142             return getMcc() != null;
143           }
144 
145           @Override public boolean hasDefaultValue() {
146             return false;
147           }
148 
149           @Override public boolean isOptional() {
150             return true;
151           }
152 
153           @Override public Asn1Object getComponentValue() {
154             return getMcc();
155           }
156 
157           @Override public void setToNewInstance() {
158             setMccToNewInstance();
159           }
160 
161           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
162             return tag == null ? MCC.getPossibleFirstTags() : ImmutableList.of(tag);
163           }
164 
165           @Override
166           public Asn1Tag getTag() {
167             return tag;
168           }
169 
170           @Override
171           public boolean isImplicitTagging() {
172             return true;
173           }
174 
175           @Override public String toIndentedString(String indent) {
176                 return "mcc : "
177                     + getMcc().toIndentedString(indent);
178               }
179         });
180 
181     builder.add(new SequenceComponent() {
182           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1);
183 
184           @Override public boolean isExplicitlySet() {
185             return getMnc() != null;
186           }
187 
188           @Override public boolean hasDefaultValue() {
189             return false;
190           }
191 
192           @Override public boolean isOptional() {
193             return false;
194           }
195 
196           @Override public Asn1Object getComponentValue() {
197             return getMnc();
198           }
199 
200           @Override public void setToNewInstance() {
201             setMncToNewInstance();
202           }
203 
204           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
205             return tag == null ? MNC.getPossibleFirstTags() : ImmutableList.of(tag);
206           }
207 
208           @Override
209           public Asn1Tag getTag() {
210             return tag;
211           }
212 
213           @Override
214           public boolean isImplicitTagging() {
215             return true;
216           }
217 
218           @Override public String toIndentedString(String indent) {
219                 return "mnc : "
220                     + getMnc().toIndentedString(indent);
221               }
222         });
223 
224     return builder.build();
225   }
226 
227   @Override public Iterable<? extends SequenceComponent>
getExtensionComponents()228                                                     getExtensionComponents() {
229     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
230 
231       return builder.build();
232     }
233 
234 
235 
236 
237 
238 
239 
240 
241 
encodePerUnaligned()242   @Override public Iterable<BitStream> encodePerUnaligned() {
243     return super.encodePerUnaligned();
244   }
245 
encodePerAligned()246   @Override public Iterable<BitStream> encodePerAligned() {
247     return super.encodePerAligned();
248   }
249 
decodePerUnaligned(BitStreamReader reader)250   @Override public void decodePerUnaligned(BitStreamReader reader) {
251     super.decodePerUnaligned(reader);
252   }
253 
decodePerAligned(BitStreamReader reader)254   @Override public void decodePerAligned(BitStreamReader reader) {
255     super.decodePerAligned(reader);
256   }
257 
toString()258   @Override public String toString() {
259     return toIndentedString("");
260   }
261 
toIndentedString(String indent)262   public String toIndentedString(String indent) {
263     StringBuilder builder = new StringBuilder();
264     builder.append("PLMN_Identity = {\n");
265     final String internalIndent = indent + "  ";
266     for (SequenceComponent component : getComponents()) {
267       if (component.isExplicitlySet()) {
268         builder.append(internalIndent)
269             .append(component.toIndentedString(internalIndent));
270       }
271     }
272     if (isExtensible()) {
273       builder.append(internalIndent).append("...\n");
274       for (SequenceComponent component : getExtensionComponents()) {
275         if (component.isExplicitlySet()) {
276           builder.append(internalIndent)
277               .append(component.toIndentedString(internalIndent));
278         }
279       }
280     }
281     builder.append(indent).append("};\n");
282     return builder.toString();
283   }
284 }
285