• 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.ulp;
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 android.location.cts.asn1.supl2.ulp_components.SessionID;
34 import android.location.cts.asn1.supl2.ulp_components.Version;
35 import com.google.common.collect.ImmutableList;
36 import java.util.Collection;
37 import javax.annotation.Nullable;
38 
39 
40 /**
41 */
42 public  class ULP_PDU extends Asn1Sequence {
43   //
44 
45   private static final Asn1Tag TAG_ULP_PDU
46       = Asn1Tag.fromClassAndNumber(-1, -1);
47 
ULP_PDU()48   public ULP_PDU() {
49     super();
50   }
51 
52   @Override
53   @Nullable
getTag()54   protected Asn1Tag getTag() {
55     return TAG_ULP_PDU;
56   }
57 
58   @Override
isTagImplicit()59   protected boolean isTagImplicit() {
60     return true;
61   }
62 
getPossibleFirstTags()63   public static Collection<Asn1Tag> getPossibleFirstTags() {
64     if (TAG_ULP_PDU != null) {
65       return ImmutableList.of(TAG_ULP_PDU);
66     } else {
67       return Asn1Sequence.getPossibleFirstTags();
68     }
69   }
70 
71   /**
72    * Creates a new ULP_PDU from encoded stream.
73    */
fromPerUnaligned(byte[] encodedBytes)74   public static ULP_PDU fromPerUnaligned(byte[] encodedBytes) {
75     ULP_PDU result = new ULP_PDU();
76     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
77     return result;
78   }
79 
80   /**
81    * Creates a new ULP_PDU from encoded stream.
82    */
fromPerAligned(byte[] encodedBytes)83   public static ULP_PDU fromPerAligned(byte[] encodedBytes) {
84     ULP_PDU result = new ULP_PDU();
85     result.decodePerAligned(new BitStreamReader(encodedBytes));
86     return result;
87   }
88 
89 
90 
isExtensible()91   @Override protected boolean isExtensible() {
92     return false;
93   }
94 
containsExtensionValues()95   @Override public boolean containsExtensionValues() {
96     for (SequenceComponent extensionComponent : getExtensionComponents()) {
97       if (extensionComponent.isExplicitlySet()) return true;
98     }
99     return false;
100   }
101 
102 
103   private ULP_PDU.lengthType length_;
getLength()104   public ULP_PDU.lengthType getLength() {
105     return length_;
106   }
107   /**
108    * @throws ClassCastException if value is not a ULP_PDU.lengthType
109    */
setLength(Asn1Object value)110   public void setLength(Asn1Object value) {
111     this.length_ = (ULP_PDU.lengthType) value;
112   }
setLengthToNewInstance()113   public ULP_PDU.lengthType setLengthToNewInstance() {
114     length_ = new ULP_PDU.lengthType();
115     return length_;
116   }
117 
118   private Version version_;
getVersion()119   public Version getVersion() {
120     return version_;
121   }
122   /**
123    * @throws ClassCastException if value is not a Version
124    */
setVersion(Asn1Object value)125   public void setVersion(Asn1Object value) {
126     this.version_ = (Version) value;
127   }
setVersionToNewInstance()128   public Version setVersionToNewInstance() {
129     version_ = new Version();
130     return version_;
131   }
132 
133   private SessionID sessionID_;
getSessionID()134   public SessionID getSessionID() {
135     return sessionID_;
136   }
137   /**
138    * @throws ClassCastException if value is not a SessionID
139    */
setSessionID(Asn1Object value)140   public void setSessionID(Asn1Object value) {
141     this.sessionID_ = (SessionID) value;
142   }
setSessionIDToNewInstance()143   public SessionID setSessionIDToNewInstance() {
144     sessionID_ = new SessionID();
145     return sessionID_;
146   }
147 
148   private UlpMessage message_;
getMessage()149   public UlpMessage getMessage() {
150     return message_;
151   }
152   /**
153    * @throws ClassCastException if value is not a UlpMessage
154    */
setMessage(Asn1Object value)155   public void setMessage(Asn1Object value) {
156     this.message_ = (UlpMessage) value;
157   }
setMessageToNewInstance()158   public UlpMessage setMessageToNewInstance() {
159     message_ = new UlpMessage();
160     return message_;
161   }
162 
163 
164 
165 
166 
167 
getComponents()168   @Override public Iterable<? extends SequenceComponent> getComponents() {
169     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
170 
171     builder.add(new SequenceComponent() {
172           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0);
173 
174           @Override public boolean isExplicitlySet() {
175             return getLength() != null;
176           }
177 
178           @Override public boolean hasDefaultValue() {
179             return false;
180           }
181 
182           @Override public boolean isOptional() {
183             return false;
184           }
185 
186           @Override public Asn1Object getComponentValue() {
187             return getLength();
188           }
189 
190           @Override public void setToNewInstance() {
191             setLengthToNewInstance();
192           }
193 
194           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
195             return tag == null ? ULP_PDU.lengthType.getPossibleFirstTags() : ImmutableList.of(tag);
196           }
197 
198           @Override
199           public Asn1Tag getTag() {
200             return tag;
201           }
202 
203           @Override
204           public boolean isImplicitTagging() {
205             return true;
206           }
207 
208           @Override public String toIndentedString(String indent) {
209                 return "length : "
210                     + getLength().toIndentedString(indent);
211               }
212         });
213 
214     builder.add(new SequenceComponent() {
215           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1);
216 
217           @Override public boolean isExplicitlySet() {
218             return getVersion() != null;
219           }
220 
221           @Override public boolean hasDefaultValue() {
222             return false;
223           }
224 
225           @Override public boolean isOptional() {
226             return false;
227           }
228 
229           @Override public Asn1Object getComponentValue() {
230             return getVersion();
231           }
232 
233           @Override public void setToNewInstance() {
234             setVersionToNewInstance();
235           }
236 
237           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
238             return tag == null ? Version.getPossibleFirstTags() : ImmutableList.of(tag);
239           }
240 
241           @Override
242           public Asn1Tag getTag() {
243             return tag;
244           }
245 
246           @Override
247           public boolean isImplicitTagging() {
248             return true;
249           }
250 
251           @Override public String toIndentedString(String indent) {
252                 return "version : "
253                     + getVersion().toIndentedString(indent);
254               }
255         });
256 
257     builder.add(new SequenceComponent() {
258           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 2);
259 
260           @Override public boolean isExplicitlySet() {
261             return getSessionID() != null;
262           }
263 
264           @Override public boolean hasDefaultValue() {
265             return false;
266           }
267 
268           @Override public boolean isOptional() {
269             return false;
270           }
271 
272           @Override public Asn1Object getComponentValue() {
273             return getSessionID();
274           }
275 
276           @Override public void setToNewInstance() {
277             setSessionIDToNewInstance();
278           }
279 
280           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
281             return tag == null ? SessionID.getPossibleFirstTags() : ImmutableList.of(tag);
282           }
283 
284           @Override
285           public Asn1Tag getTag() {
286             return tag;
287           }
288 
289           @Override
290           public boolean isImplicitTagging() {
291             return true;
292           }
293 
294           @Override public String toIndentedString(String indent) {
295                 return "sessionID : "
296                     + getSessionID().toIndentedString(indent);
297               }
298         });
299 
300     builder.add(new SequenceComponent() {
301           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 3);
302 
303           @Override public boolean isExplicitlySet() {
304             return getMessage() != null;
305           }
306 
307           @Override public boolean hasDefaultValue() {
308             return false;
309           }
310 
311           @Override public boolean isOptional() {
312             return false;
313           }
314 
315           @Override public Asn1Object getComponentValue() {
316             return getMessage();
317           }
318 
319           @Override public void setToNewInstance() {
320             setMessageToNewInstance();
321           }
322 
323           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
324             return tag == null ? UlpMessage.getPossibleFirstTags() : ImmutableList.of(tag);
325           }
326 
327           @Override
328           public Asn1Tag getTag() {
329             return tag;
330           }
331 
332           @Override
333           public boolean isImplicitTagging() {
334             return true;
335           }
336 
337           @Override public String toIndentedString(String indent) {
338                 return "message : "
339                     + getMessage().toIndentedString(indent);
340               }
341         });
342 
343     return builder.build();
344   }
345 
346   @Override public Iterable<? extends SequenceComponent>
getExtensionComponents()347                                                     getExtensionComponents() {
348     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
349 
350       return builder.build();
351     }
352 
353 
354 /*
355  */
356 
357 
358 //
359 
360 /**
361  */
362 public static class lengthType extends Asn1Integer {
363   //
364 
365   private static final Asn1Tag TAG_lengthType
366       = Asn1Tag.fromClassAndNumber(-1, -1);
367 
lengthType()368   public lengthType() {
369     super();
370     setValueRange("0", "65535");
371 
372   }
373 
374   @Override
375   @Nullable
getTag()376   protected Asn1Tag getTag() {
377     return TAG_lengthType;
378   }
379 
380   @Override
isTagImplicit()381   protected boolean isTagImplicit() {
382     return true;
383   }
384 
getPossibleFirstTags()385   public static Collection<Asn1Tag> getPossibleFirstTags() {
386     if (TAG_lengthType != null) {
387       return ImmutableList.of(TAG_lengthType);
388     } else {
389       return Asn1Integer.getPossibleFirstTags();
390     }
391   }
392 
393   /**
394    * Creates a new lengthType from encoded stream.
395    */
fromPerUnaligned(byte[] encodedBytes)396   public static lengthType fromPerUnaligned(byte[] encodedBytes) {
397     lengthType result = new lengthType();
398     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
399     return result;
400   }
401 
402   /**
403    * Creates a new lengthType from encoded stream.
404    */
fromPerAligned(byte[] encodedBytes)405   public static lengthType fromPerAligned(byte[] encodedBytes) {
406     lengthType result = new lengthType();
407     result.decodePerAligned(new BitStreamReader(encodedBytes));
408     return result;
409   }
410 
encodePerUnaligned()411   @Override public Iterable<BitStream> encodePerUnaligned() {
412     return super.encodePerUnaligned();
413   }
414 
encodePerAligned()415   @Override public Iterable<BitStream> encodePerAligned() {
416     return super.encodePerAligned();
417   }
418 
decodePerUnaligned(BitStreamReader reader)419   @Override public void decodePerUnaligned(BitStreamReader reader) {
420     super.decodePerUnaligned(reader);
421   }
422 
decodePerAligned(BitStreamReader reader)423   @Override public void decodePerAligned(BitStreamReader reader) {
424     super.decodePerAligned(reader);
425   }
426 
toString()427   @Override public String toString() {
428     return toIndentedString("");
429   }
430 
toIndentedString(String indent)431   public String toIndentedString(String indent) {
432     return "lengthType = " + getInteger() + ";\n";
433   }
434 }
435 
436 
437 
438 
439 
440 
441 
442 
443 
444 
445 
encodePerUnaligned()446   @Override public Iterable<BitStream> encodePerUnaligned() {
447     return super.encodePerUnaligned();
448   }
449 
encodePerAligned()450   @Override public Iterable<BitStream> encodePerAligned() {
451     return super.encodePerAligned();
452   }
453 
decodePerUnaligned(BitStreamReader reader)454   @Override public void decodePerUnaligned(BitStreamReader reader) {
455     super.decodePerUnaligned(reader);
456   }
457 
decodePerAligned(BitStreamReader reader)458   @Override public void decodePerAligned(BitStreamReader reader) {
459     super.decodePerAligned(reader);
460   }
461 
toString()462   @Override public String toString() {
463     return toIndentedString("");
464   }
465 
toIndentedString(String indent)466   public String toIndentedString(String indent) {
467     StringBuilder builder = new StringBuilder();
468     builder.append("ULP_PDU = {\n");
469     final String internalIndent = indent + "  ";
470     for (SequenceComponent component : getComponents()) {
471       if (component.isExplicitlySet()) {
472         builder.append(internalIndent)
473             .append(component.toIndentedString(internalIndent));
474       }
475     }
476     if (isExtensible()) {
477       builder.append(internalIndent).append("...\n");
478       for (SequenceComponent component : getExtensionComponents()) {
479         if (component.isExplicitlySet()) {
480           builder.append(internalIndent)
481               .append(component.toIndentedString(internalIndent));
482         }
483       }
484     }
485     builder.append(indent).append("};\n");
486     return builder.toString();
487   }
488 }
489