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