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.supl_start;
18 
19 /*
20  */
21 
22 
23 //
24 //
25 import android.location.cts.asn1.base.Asn1Enumerated;
26 import android.location.cts.asn1.base.Asn1Tag;
27 import android.location.cts.asn1.base.BitStream;
28 import android.location.cts.asn1.base.BitStreamReader;
29 import com.google.common.collect.ImmutableList;
30 import java.util.Collection;
31 import javax.annotation.Nullable;
32 
33 
34 /**
35  */
36 public  class PrefMethod extends Asn1Enumerated {
37   public enum Value implements Asn1Enumerated.Value {
38     agpsSETassistedPreferred(0),
39     agpsSETBasedPreferred(1),
40     noPreference(2),
41     ;
42 
Value(int i)43     Value(int i) {
44       value = i;
45     }
46 
47     private int value;
getAssignedValue()48     public int getAssignedValue() {
49       return value;
50     }
51 
isExtensionValue()52     @Override public boolean isExtensionValue() {
53       return false;
54     }
55   }
56 
57   public enum ExtensionValue implements Asn1Enumerated.Value {
58     ;
59 
ExtensionValue(int i)60     ExtensionValue(int i) {
61       value = i;
62     }
63 
64     private int value;
getAssignedValue()65     @Override public int getAssignedValue() {
66       return value;
67     }
68 
isExtensionValue()69     @Override public boolean isExtensionValue() {
70       return true;
71     }
72   }
73 
74 
75 
76   private static final Asn1Tag TAG_PrefMethod
77       = Asn1Tag.fromClassAndNumber(-1, -1);
78 
PrefMethod()79   public PrefMethod() {
80     super();
81   }
82 
83   @Override
84   @Nullable
getTag()85   protected Asn1Tag getTag() {
86     return TAG_PrefMethod;
87   }
88 
89   @Override
isTagImplicit()90   protected boolean isTagImplicit() {
91     return true;
92   }
93 
getPossibleFirstTags()94   public static Collection<Asn1Tag> getPossibleFirstTags() {
95     if (TAG_PrefMethod != null) {
96       return ImmutableList.of(TAG_PrefMethod);
97     } else {
98       return Asn1Enumerated.getPossibleFirstTags();
99     }
100   }
101 
isExtensible()102   @Override protected boolean isExtensible() {
103     return false;
104   }
105 
lookupValue(int ordinal)106   @Override protected Asn1Enumerated.Value lookupValue(int ordinal) {
107     return Value.values()[ordinal];
108   }
109 
lookupExtensionValue(int ordinal)110   @Override protected Asn1Enumerated.Value lookupExtensionValue(int ordinal) {
111     return ExtensionValue.values()[ordinal];
112   }
113 
getValueCount()114   @Override protected int getValueCount() {
115     return Value.values().length;
116   }
117 
118   /**
119    * Creates a new PrefMethod from encoded stream.
120    */
fromPerUnaligned(byte[] encodedBytes)121   public static PrefMethod fromPerUnaligned(byte[] encodedBytes) {
122     PrefMethod result = new PrefMethod();
123     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
124     return result;
125   }
126 
127   /**
128    * Creates a new PrefMethod from encoded stream.
129    */
fromPerAligned(byte[] encodedBytes)130   public static PrefMethod fromPerAligned(byte[] encodedBytes) {
131     PrefMethod result = new PrefMethod();
132     result.decodePerAligned(new BitStreamReader(encodedBytes));
133     return result;
134   }
135 
encodePerUnaligned()136   @Override public Iterable<BitStream> encodePerUnaligned() {
137     return super.encodePerUnaligned();
138   }
139 
encodePerAligned()140   @Override public Iterable<BitStream> encodePerAligned() {
141     return super.encodePerAligned();
142   }
143 
decodePerUnaligned(BitStreamReader reader)144   @Override public void decodePerUnaligned(BitStreamReader reader) {
145     super.decodePerUnaligned(reader);
146   }
147 
decodePerAligned(BitStreamReader reader)148   @Override public void decodePerAligned(BitStreamReader reader) {
149     super.decodePerAligned(reader);
150   }
151 
toString()152   @Override public String toString() {
153     return toIndentedString("");
154   }
155 
toIndentedString(String indent)156   public String toIndentedString(String indent) {
157     return "PrefMethod = " + getValue() + ";\n";
158   }
159 }
160