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