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.base;
18 
19 /**
20  * Tag class of an ASN.1 type.
21  */
22 public enum Asn1TagClass {
23   UNIVERSAL(0),
24   APPLICATION(1),
25   CONTEXT(2),
26   PRIVATE(3);
27 
28   private final int value;
29 
Asn1TagClass(int value)30   private Asn1TagClass(int value) {
31     this.value = value;
32   }
33 
fromValue(int tagClass)34   public static Asn1TagClass fromValue(int tagClass) {
35     switch (tagClass) {
36       case 0: return UNIVERSAL;
37       case 1: return APPLICATION;
38       case 2: return CONTEXT;
39       case 3: return PRIVATE;
40       default:
41         throw new IllegalArgumentException("Invalid tag class: " + tagClass);
42     }
43   }
44 
getValue()45   public int getValue() {
46     return value;
47   }
48 }
49