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.ulp_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 Version extends Asn1Sequence {
41   //
42 
43   private static final Asn1Tag TAG_Version
44       = Asn1Tag.fromClassAndNumber(-1, -1);
45 
Version()46   public Version() {
47     super();
48   }
49 
50   @Override
51   @Nullable
getTag()52   protected Asn1Tag getTag() {
53     return TAG_Version;
54   }
55 
56   @Override
isTagImplicit()57   protected boolean isTagImplicit() {
58     return true;
59   }
60 
getPossibleFirstTags()61   public static Collection<Asn1Tag> getPossibleFirstTags() {
62     if (TAG_Version != null) {
63       return ImmutableList.of(TAG_Version);
64     } else {
65       return Asn1Sequence.getPossibleFirstTags();
66     }
67   }
68 
69   /**
70    * Creates a new Version from encoded stream.
71    */
fromPerUnaligned(byte[] encodedBytes)72   public static Version fromPerUnaligned(byte[] encodedBytes) {
73     Version result = new Version();
74     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
75     return result;
76   }
77 
78   /**
79    * Creates a new Version from encoded stream.
80    */
fromPerAligned(byte[] encodedBytes)81   public static Version fromPerAligned(byte[] encodedBytes) {
82     Version result = new Version();
83     result.decodePerAligned(new BitStreamReader(encodedBytes));
84     return result;
85   }
86 
87 
88 
isExtensible()89   @Override protected boolean isExtensible() {
90     return false;
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 Version.majType maj_;
getMaj()102   public Version.majType getMaj() {
103     return maj_;
104   }
105   /**
106    * @throws ClassCastException if value is not a Version.majType
107    */
setMaj(Asn1Object value)108   public void setMaj(Asn1Object value) {
109     this.maj_ = (Version.majType) value;
110   }
setMajToNewInstance()111   public Version.majType setMajToNewInstance() {
112     maj_ = new Version.majType();
113     return maj_;
114   }
115 
116   private Version.minType min_;
getMin()117   public Version.minType getMin() {
118     return min_;
119   }
120   /**
121    * @throws ClassCastException if value is not a Version.minType
122    */
setMin(Asn1Object value)123   public void setMin(Asn1Object value) {
124     this.min_ = (Version.minType) value;
125   }
setMinToNewInstance()126   public Version.minType setMinToNewInstance() {
127     min_ = new Version.minType();
128     return min_;
129   }
130 
131   private Version.servindType servind_;
getServind()132   public Version.servindType getServind() {
133     return servind_;
134   }
135   /**
136    * @throws ClassCastException if value is not a Version.servindType
137    */
setServind(Asn1Object value)138   public void setServind(Asn1Object value) {
139     this.servind_ = (Version.servindType) value;
140   }
setServindToNewInstance()141   public Version.servindType setServindToNewInstance() {
142     servind_ = new Version.servindType();
143     return servind_;
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 getMaj() != 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 getMaj();
171           }
172 
173           @Override public void setToNewInstance() {
174             setMajToNewInstance();
175           }
176 
177           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
178             return tag == null ? Version.majType.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 "maj : "
193                     + getMaj().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 getMin() != 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 getMin();
214           }
215 
216           @Override public void setToNewInstance() {
217             setMinToNewInstance();
218           }
219 
220           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
221             return tag == null ? Version.minType.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 "min : "
236                     + getMin().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 getServind() != 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 getServind();
257           }
258 
259           @Override public void setToNewInstance() {
260             setServindToNewInstance();
261           }
262 
263           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
264             return tag == null ? Version.servindType.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 "servind : "
279                     + getServind().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 public static class majType extends Asn1Integer {
303   //
304 
305   private static final Asn1Tag TAG_majType
306       = Asn1Tag.fromClassAndNumber(-1, -1);
307 
majType()308   public majType() {
309     super();
310     setValueRange("0", "255");
311 
312   }
313 
314   @Override
315   @Nullable
getTag()316   protected Asn1Tag getTag() {
317     return TAG_majType;
318   }
319 
320   @Override
isTagImplicit()321   protected boolean isTagImplicit() {
322     return true;
323   }
324 
getPossibleFirstTags()325   public static Collection<Asn1Tag> getPossibleFirstTags() {
326     if (TAG_majType != null) {
327       return ImmutableList.of(TAG_majType);
328     } else {
329       return Asn1Integer.getPossibleFirstTags();
330     }
331   }
332 
333   /**
334    * Creates a new majType from encoded stream.
335    */
fromPerUnaligned(byte[] encodedBytes)336   public static majType fromPerUnaligned(byte[] encodedBytes) {
337     majType result = new majType();
338     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
339     return result;
340   }
341 
342   /**
343    * Creates a new majType from encoded stream.
344    */
fromPerAligned(byte[] encodedBytes)345   public static majType fromPerAligned(byte[] encodedBytes) {
346     majType result = new majType();
347     result.decodePerAligned(new BitStreamReader(encodedBytes));
348     return result;
349   }
350 
encodePerUnaligned()351   @Override public Iterable<BitStream> encodePerUnaligned() {
352     return super.encodePerUnaligned();
353   }
354 
encodePerAligned()355   @Override public Iterable<BitStream> encodePerAligned() {
356     return super.encodePerAligned();
357   }
358 
decodePerUnaligned(BitStreamReader reader)359   @Override public void decodePerUnaligned(BitStreamReader reader) {
360     super.decodePerUnaligned(reader);
361   }
362 
decodePerAligned(BitStreamReader reader)363   @Override public void decodePerAligned(BitStreamReader reader) {
364     super.decodePerAligned(reader);
365   }
366 
toString()367   @Override public String toString() {
368     return toIndentedString("");
369   }
370 
toIndentedString(String indent)371   public String toIndentedString(String indent) {
372     return "majType = " + getInteger() + ";\n";
373   }
374 }
375 
376 
377 /*
378  */
379 
380 
381 //
382 
383 /**
384  */
385 public static class minType extends Asn1Integer {
386   //
387 
388   private static final Asn1Tag TAG_minType
389       = Asn1Tag.fromClassAndNumber(-1, -1);
390 
minType()391   public minType() {
392     super();
393     setValueRange("0", "255");
394 
395   }
396 
397   @Override
398   @Nullable
getTag()399   protected Asn1Tag getTag() {
400     return TAG_minType;
401   }
402 
403   @Override
isTagImplicit()404   protected boolean isTagImplicit() {
405     return true;
406   }
407 
getPossibleFirstTags()408   public static Collection<Asn1Tag> getPossibleFirstTags() {
409     if (TAG_minType != null) {
410       return ImmutableList.of(TAG_minType);
411     } else {
412       return Asn1Integer.getPossibleFirstTags();
413     }
414   }
415 
416   /**
417    * Creates a new minType from encoded stream.
418    */
fromPerUnaligned(byte[] encodedBytes)419   public static minType fromPerUnaligned(byte[] encodedBytes) {
420     minType result = new minType();
421     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
422     return result;
423   }
424 
425   /**
426    * Creates a new minType from encoded stream.
427    */
fromPerAligned(byte[] encodedBytes)428   public static minType fromPerAligned(byte[] encodedBytes) {
429     minType result = new minType();
430     result.decodePerAligned(new BitStreamReader(encodedBytes));
431     return result;
432   }
433 
encodePerUnaligned()434   @Override public Iterable<BitStream> encodePerUnaligned() {
435     return super.encodePerUnaligned();
436   }
437 
encodePerAligned()438   @Override public Iterable<BitStream> encodePerAligned() {
439     return super.encodePerAligned();
440   }
441 
decodePerUnaligned(BitStreamReader reader)442   @Override public void decodePerUnaligned(BitStreamReader reader) {
443     super.decodePerUnaligned(reader);
444   }
445 
decodePerAligned(BitStreamReader reader)446   @Override public void decodePerAligned(BitStreamReader reader) {
447     super.decodePerAligned(reader);
448   }
449 
toString()450   @Override public String toString() {
451     return toIndentedString("");
452   }
453 
toIndentedString(String indent)454   public String toIndentedString(String indent) {
455     return "minType = " + getInteger() + ";\n";
456   }
457 }
458 
459 
460 /*
461  */
462 
463 
464 //
465 
466 /**
467  */
468 public static class servindType extends Asn1Integer {
469   //
470 
471   private static final Asn1Tag TAG_servindType
472       = Asn1Tag.fromClassAndNumber(-1, -1);
473 
servindType()474   public servindType() {
475     super();
476     setValueRange("0", "255");
477 
478   }
479 
480   @Override
481   @Nullable
getTag()482   protected Asn1Tag getTag() {
483     return TAG_servindType;
484   }
485 
486   @Override
isTagImplicit()487   protected boolean isTagImplicit() {
488     return true;
489   }
490 
getPossibleFirstTags()491   public static Collection<Asn1Tag> getPossibleFirstTags() {
492     if (TAG_servindType != null) {
493       return ImmutableList.of(TAG_servindType);
494     } else {
495       return Asn1Integer.getPossibleFirstTags();
496     }
497   }
498 
499   /**
500    * Creates a new servindType from encoded stream.
501    */
fromPerUnaligned(byte[] encodedBytes)502   public static servindType fromPerUnaligned(byte[] encodedBytes) {
503     servindType result = new servindType();
504     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
505     return result;
506   }
507 
508   /**
509    * Creates a new servindType from encoded stream.
510    */
fromPerAligned(byte[] encodedBytes)511   public static servindType fromPerAligned(byte[] encodedBytes) {
512     servindType result = new servindType();
513     result.decodePerAligned(new BitStreamReader(encodedBytes));
514     return result;
515   }
516 
encodePerUnaligned()517   @Override public Iterable<BitStream> encodePerUnaligned() {
518     return super.encodePerUnaligned();
519   }
520 
encodePerAligned()521   @Override public Iterable<BitStream> encodePerAligned() {
522     return super.encodePerAligned();
523   }
524 
decodePerUnaligned(BitStreamReader reader)525   @Override public void decodePerUnaligned(BitStreamReader reader) {
526     super.decodePerUnaligned(reader);
527   }
528 
decodePerAligned(BitStreamReader reader)529   @Override public void decodePerAligned(BitStreamReader reader) {
530     super.decodePerAligned(reader);
531   }
532 
toString()533   @Override public String toString() {
534     return toIndentedString("");
535   }
536 
toIndentedString(String indent)537   public String toIndentedString(String indent) {
538     return "servindType = " + getInteger() + ";\n";
539   }
540 }
541 
542 
543 
544 
545 
encodePerUnaligned()546   @Override public Iterable<BitStream> encodePerUnaligned() {
547     return super.encodePerUnaligned();
548   }
549 
encodePerAligned()550   @Override public Iterable<BitStream> encodePerAligned() {
551     return super.encodePerAligned();
552   }
553 
decodePerUnaligned(BitStreamReader reader)554   @Override public void decodePerUnaligned(BitStreamReader reader) {
555     super.decodePerUnaligned(reader);
556   }
557 
decodePerAligned(BitStreamReader reader)558   @Override public void decodePerAligned(BitStreamReader reader) {
559     super.decodePerAligned(reader);
560   }
561 
toString()562   @Override public String toString() {
563     return toIndentedString("");
564   }
565 
toIndentedString(String indent)566   public String toIndentedString(String indent) {
567     StringBuilder builder = new StringBuilder();
568     builder.append("Version = {\n");
569     final String internalIndent = indent + "  ";
570     for (SequenceComponent component : getComponents()) {
571       if (component.isExplicitlySet()) {
572         builder.append(internalIndent)
573             .append(component.toIndentedString(internalIndent));
574       }
575     }
576     if (isExtensible()) {
577       builder.append(internalIndent).append("...\n");
578       for (SequenceComponent component : getExtensionComponents()) {
579         if (component.isExplicitlySet()) {
580           builder.append(internalIndent)
581               .append(component.toIndentedString(internalIndent));
582         }
583       }
584     }
585     builder.append(indent).append("};\n");
586     return builder.toString();
587   }
588 }
589