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 GANSS_ID3_element extends Asn1Sequence {
41   //
42 
43   private static final Asn1Tag TAG_GANSS_ID3_element
44       = Asn1Tag.fromClassAndNumber(-1, -1);
45 
GANSS_ID3_element()46   public GANSS_ID3_element() {
47     super();
48   }
49 
50   @Override
51   @Nullable
getTag()52   protected Asn1Tag getTag() {
53     return TAG_GANSS_ID3_element;
54   }
55 
56   @Override
isTagImplicit()57   protected boolean isTagImplicit() {
58     return true;
59   }
60 
getPossibleFirstTags()61   public static Collection<Asn1Tag> getPossibleFirstTags() {
62     if (TAG_GANSS_ID3_element != null) {
63       return ImmutableList.of(TAG_GANSS_ID3_element);
64     } else {
65       return Asn1Sequence.getPossibleFirstTags();
66     }
67   }
68 
69   /**
70    * Creates a new GANSS_ID3_element from encoded stream.
71    */
fromPerUnaligned(byte[] encodedBytes)72   public static GANSS_ID3_element fromPerUnaligned(byte[] encodedBytes) {
73     GANSS_ID3_element result = new GANSS_ID3_element();
74     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
75     return result;
76   }
77 
78   /**
79    * Creates a new GANSS_ID3_element from encoded stream.
80    */
fromPerAligned(byte[] encodedBytes)81   public static GANSS_ID3_element fromPerAligned(byte[] encodedBytes) {
82     GANSS_ID3_element result = new GANSS_ID3_element();
83     result.decodePerAligned(new BitStreamReader(encodedBytes));
84     return result;
85   }
86 
87 
88 
isExtensible()89   @Override protected boolean isExtensible() {
90     return true;
91   }
92 
containsExtensionValues()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 SVID svID_;
getSvID()102   public SVID getSvID() {
103     return svID_;
104   }
105   /**
106    * @throws ClassCastException if value is not a SVID
107    */
setSvID(Asn1Object value)108   public void setSvID(Asn1Object value) {
109     this.svID_ = (SVID) value;
110   }
setSvIDToNewInstance()111   public SVID setSvIDToNewInstance() {
112     svID_ = new SVID();
113     return svID_;
114   }
115 
116   private GANSSSignals signalsAvailable_;
getSignalsAvailable()117   public GANSSSignals getSignalsAvailable() {
118     return signalsAvailable_;
119   }
120   /**
121    * @throws ClassCastException if value is not a GANSSSignals
122    */
setSignalsAvailable(Asn1Object value)123   public void setSignalsAvailable(Asn1Object value) {
124     this.signalsAvailable_ = (GANSSSignals) value;
125   }
setSignalsAvailableToNewInstance()126   public GANSSSignals setSignalsAvailableToNewInstance() {
127     signalsAvailable_ = new GANSSSignals();
128     return signalsAvailable_;
129   }
130 
131   private GANSS_ID3_element.channelNumberType channelNumber_;
getChannelNumber()132   public GANSS_ID3_element.channelNumberType getChannelNumber() {
133     return channelNumber_;
134   }
135   /**
136    * @throws ClassCastException if value is not a GANSS_ID3_element.channelNumberType
137    */
setChannelNumber(Asn1Object value)138   public void setChannelNumber(Asn1Object value) {
139     this.channelNumber_ = (GANSS_ID3_element.channelNumberType) value;
140   }
setChannelNumberToNewInstance()141   public GANSS_ID3_element.channelNumberType setChannelNumberToNewInstance() {
142     channelNumber_ = new GANSS_ID3_element.channelNumberType();
143     return channelNumber_;
144   }
145 
146 
147 
148 
149 
150 
getComponents()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 getSvID() != 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 getSvID();
171           }
172 
173           @Override public void setToNewInstance() {
174             setSvIDToNewInstance();
175           }
176 
177           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
178             return tag == null ? SVID.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 "svID : "
193                     + getSvID().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 getSignalsAvailable() != 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 getSignalsAvailable();
214           }
215 
216           @Override public void setToNewInstance() {
217             setSignalsAvailableToNewInstance();
218           }
219 
220           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
221             return tag == null ? GANSSSignals.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 "signalsAvailable : "
236                     + getSignalsAvailable().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 getChannelNumber() != null;
245           }
246 
247           @Override public boolean hasDefaultValue() {
248             return false;
249           }
250 
251           @Override public boolean isOptional() {
252             return false;
253           }
254 
255           @Override public Asn1Object getComponentValue() {
256             return getChannelNumber();
257           }
258 
259           @Override public void setToNewInstance() {
260             setChannelNumberToNewInstance();
261           }
262 
263           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
264             return tag == null ? GANSS_ID3_element.channelNumberType.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 "channelNumber : "
279                     + getChannelNumber().toIndentedString(indent);
280               }
281         });
282 
283     return builder.build();
284   }
285 
286   @Override public Iterable<? extends SequenceComponent>
getExtensionComponents()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 //
303 
304 /**
305  */
306 public static class channelNumberType extends Asn1Integer {
307   //
308 
309   private static final Asn1Tag TAG_channelNumberType
310       = Asn1Tag.fromClassAndNumber(-1, -1);
311 
channelNumberType()312   public channelNumberType() {
313     super();
314     setValueRange("-7", "13");
315 
316   }
317 
318   @Override
319   @Nullable
getTag()320   protected Asn1Tag getTag() {
321     return TAG_channelNumberType;
322   }
323 
324   @Override
isTagImplicit()325   protected boolean isTagImplicit() {
326     return true;
327   }
328 
getPossibleFirstTags()329   public static Collection<Asn1Tag> getPossibleFirstTags() {
330     if (TAG_channelNumberType != null) {
331       return ImmutableList.of(TAG_channelNumberType);
332     } else {
333       return Asn1Integer.getPossibleFirstTags();
334     }
335   }
336 
337   /**
338    * Creates a new channelNumberType from encoded stream.
339    */
fromPerUnaligned(byte[] encodedBytes)340   public static channelNumberType fromPerUnaligned(byte[] encodedBytes) {
341     channelNumberType result = new channelNumberType();
342     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
343     return result;
344   }
345 
346   /**
347    * Creates a new channelNumberType from encoded stream.
348    */
fromPerAligned(byte[] encodedBytes)349   public static channelNumberType fromPerAligned(byte[] encodedBytes) {
350     channelNumberType result = new channelNumberType();
351     result.decodePerAligned(new BitStreamReader(encodedBytes));
352     return result;
353   }
354 
encodePerUnaligned()355   @Override public Iterable<BitStream> encodePerUnaligned() {
356     return super.encodePerUnaligned();
357   }
358 
encodePerAligned()359   @Override public Iterable<BitStream> encodePerAligned() {
360     return super.encodePerAligned();
361   }
362 
decodePerUnaligned(BitStreamReader reader)363   @Override public void decodePerUnaligned(BitStreamReader reader) {
364     super.decodePerUnaligned(reader);
365   }
366 
decodePerAligned(BitStreamReader reader)367   @Override public void decodePerAligned(BitStreamReader reader) {
368     super.decodePerAligned(reader);
369   }
370 
toString()371   @Override public String toString() {
372     return toIndentedString("");
373   }
374 
toIndentedString(String indent)375   public String toIndentedString(String indent) {
376     return "channelNumberType = " + getInteger() + ";\n";
377   }
378 }
379 
380 
381 
382 
383 
encodePerUnaligned()384   @Override public Iterable<BitStream> encodePerUnaligned() {
385     return super.encodePerUnaligned();
386   }
387 
encodePerAligned()388   @Override public Iterable<BitStream> encodePerAligned() {
389     return super.encodePerAligned();
390   }
391 
decodePerUnaligned(BitStreamReader reader)392   @Override public void decodePerUnaligned(BitStreamReader reader) {
393     super.decodePerUnaligned(reader);
394   }
395 
decodePerAligned(BitStreamReader reader)396   @Override public void decodePerAligned(BitStreamReader reader) {
397     super.decodePerAligned(reader);
398   }
399 
toString()400   @Override public String toString() {
401     return toIndentedString("");
402   }
403 
toIndentedString(String indent)404   public String toIndentedString(String indent) {
405     StringBuilder builder = new StringBuilder();
406     builder.append("GANSS_ID3_element = {\n");
407     final String internalIndent = indent + "  ";
408     for (SequenceComponent component : getComponents()) {
409       if (component.isExplicitlySet()) {
410         builder.append(internalIndent)
411             .append(component.toIndentedString(internalIndent));
412       }
413     }
414     if (isExtensible()) {
415       builder.append(internalIndent).append("...\n");
416       for (SequenceComponent component : getExtensionComponents()) {
417         if (component.isExplicitlySet()) {
418           builder.append(internalIndent)
419               .append(component.toIndentedString(internalIndent));
420         }
421       }
422     }
423     builder.append(indent).append("};\n");
424     return builder.toString();
425   }
426 }
427