Home | History | Annotate | Download | only in supl_auth_req
      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_auth_req;
     18 
     19 /*
     20  */
     21 
     22 
     23 //
     24 //
     25 import android.location.cts.asn1.base.Asn1Null;
     26 import android.location.cts.asn1.base.Asn1Object;
     27 import android.location.cts.asn1.base.Asn1Sequence;
     28 import android.location.cts.asn1.base.Asn1Tag;
     29 import android.location.cts.asn1.base.BitStream;
     30 import android.location.cts.asn1.base.BitStreamReader;
     31 import android.location.cts.asn1.base.SequenceComponent;
     32 import android.location.cts.asn1.supl2.supl_start.SETCapabilities;
     33 import android.location.cts.asn1.supl2.ulp_components.Ver;
     34 import com.google.common.collect.ImmutableList;
     35 import java.util.Collection;
     36 import javax.annotation.Nullable;
     37 
     38 
     39 /**
     40 */
     41 public  class SUPLAUTHREQ extends Asn1Sequence {
     42   //
     43 
     44   private static final Asn1Tag TAG_SUPLAUTHREQ
     45       = Asn1Tag.fromClassAndNumber(-1, -1);
     46 
     47   public SUPLAUTHREQ() {
     48     super();
     49   }
     50 
     51   @Override
     52   @Nullable
     53   protected Asn1Tag getTag() {
     54     return TAG_SUPLAUTHREQ;
     55   }
     56 
     57   @Override
     58   protected boolean isTagImplicit() {
     59     return true;
     60   }
     61 
     62   public static Collection<Asn1Tag> getPossibleFirstTags() {
     63     if (TAG_SUPLAUTHREQ != null) {
     64       return ImmutableList.of(TAG_SUPLAUTHREQ);
     65     } else {
     66       return Asn1Sequence.getPossibleFirstTags();
     67     }
     68   }
     69 
     70   /**
     71    * Creates a new SUPLAUTHREQ from encoded stream.
     72    */
     73   public static SUPLAUTHREQ fromPerUnaligned(byte[] encodedBytes) {
     74     SUPLAUTHREQ result = new SUPLAUTHREQ();
     75     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
     76     return result;
     77   }
     78 
     79   /**
     80    * Creates a new SUPLAUTHREQ from encoded stream.
     81    */
     82   public static SUPLAUTHREQ fromPerAligned(byte[] encodedBytes) {
     83     SUPLAUTHREQ result = new SUPLAUTHREQ();
     84     result.decodePerAligned(new BitStreamReader(encodedBytes));
     85     return result;
     86   }
     87 
     88 
     89 
     90   @Override protected boolean isExtensible() {
     91     return true;
     92   }
     93 
     94   @Override public boolean containsExtensionValues() {
     95     for (SequenceComponent extensionComponent : getExtensionComponents()) {
     96       if (extensionComponent.isExplicitlySet()) return true;
     97     }
     98     return false;
     99   }
    100 
    101 
    102   private Ver ver_;
    103   public Ver getVer() {
    104     return ver_;
    105   }
    106   /**
    107    * @throws ClassCastException if value is not a Ver
    108    */
    109   public void setVer(Asn1Object value) {
    110     this.ver_ = (Ver) value;
    111   }
    112   public Ver setVerToNewInstance() {
    113     ver_ = new Ver();
    114     return ver_;
    115   }
    116 
    117   private SETCapabilities sETCapabilities_;
    118   public SETCapabilities getSETCapabilities() {
    119     return sETCapabilities_;
    120   }
    121   /**
    122    * @throws ClassCastException if value is not a SETCapabilities
    123    */
    124   public void setSETCapabilities(Asn1Object value) {
    125     this.sETCapabilities_ = (SETCapabilities) value;
    126   }
    127   public SETCapabilities setSETCapabilitiesToNewInstance() {
    128     sETCapabilities_ = new SETCapabilities();
    129     return sETCapabilities_;
    130   }
    131 
    132 
    133 
    134 
    135 
    136 
    137   @Override public Iterable<? extends SequenceComponent> getComponents() {
    138     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    139 
    140     builder.add(new SequenceComponent() {
    141           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0);
    142 
    143           @Override public boolean isExplicitlySet() {
    144             return getVer() != null;
    145           }
    146 
    147           @Override public boolean hasDefaultValue() {
    148             return false;
    149           }
    150 
    151           @Override public boolean isOptional() {
    152             return true;
    153           }
    154 
    155           @Override public Asn1Object getComponentValue() {
    156             return getVer();
    157           }
    158 
    159           @Override public void setToNewInstance() {
    160             setVerToNewInstance();
    161           }
    162 
    163           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    164             return tag == null ? Ver.getPossibleFirstTags() : ImmutableList.of(tag);
    165           }
    166 
    167           @Override
    168           public Asn1Tag getTag() {
    169             return tag;
    170           }
    171 
    172           @Override
    173           public boolean isImplicitTagging() {
    174             return true;
    175           }
    176 
    177           @Override public String toIndentedString(String indent) {
    178                 return "ver : "
    179                     + getVer().toIndentedString(indent);
    180               }
    181         });
    182 
    183     builder.add(new SequenceComponent() {
    184           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1);
    185 
    186           @Override public boolean isExplicitlySet() {
    187             return getSETCapabilities() != null;
    188           }
    189 
    190           @Override public boolean hasDefaultValue() {
    191             return false;
    192           }
    193 
    194           @Override public boolean isOptional() {
    195             return true;
    196           }
    197 
    198           @Override public Asn1Object getComponentValue() {
    199             return getSETCapabilities();
    200           }
    201 
    202           @Override public void setToNewInstance() {
    203             setSETCapabilitiesToNewInstance();
    204           }
    205 
    206           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    207             return tag == null ? SETCapabilities.getPossibleFirstTags() : ImmutableList.of(tag);
    208           }
    209 
    210           @Override
    211           public Asn1Tag getTag() {
    212             return tag;
    213           }
    214 
    215           @Override
    216           public boolean isImplicitTagging() {
    217             return true;
    218           }
    219 
    220           @Override public String toIndentedString(String indent) {
    221                 return "sETCapabilities : "
    222                     + getSETCapabilities().toIndentedString(indent);
    223               }
    224         });
    225 
    226     return builder.build();
    227   }
    228 
    229   @Override public Iterable<? extends SequenceComponent>
    230                                                     getExtensionComponents() {
    231     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    232 
    233       return builder.build();
    234     }
    235 
    236 
    237 
    238 
    239 
    240 
    241 
    242 
    243 
    244   @Override public Iterable<BitStream> encodePerUnaligned() {
    245     return super.encodePerUnaligned();
    246   }
    247 
    248   @Override public Iterable<BitStream> encodePerAligned() {
    249     return super.encodePerAligned();
    250   }
    251 
    252   @Override public void decodePerUnaligned(BitStreamReader reader) {
    253     super.decodePerUnaligned(reader);
    254   }
    255 
    256   @Override public void decodePerAligned(BitStreamReader reader) {
    257     super.decodePerAligned(reader);
    258   }
    259 
    260   @Override public String toString() {
    261     return toIndentedString("");
    262   }
    263 
    264   public String toIndentedString(String indent) {
    265     StringBuilder builder = new StringBuilder();
    266     builder.append("SUPLAUTHREQ = {\n");
    267     final String internalIndent = indent + "  ";
    268     for (SequenceComponent component : getComponents()) {
    269       if (component.isExplicitlySet()) {
    270         builder.append(internalIndent)
    271             .append(component.toIndentedString(internalIndent));
    272       }
    273     }
    274     if (isExtensible()) {
    275       builder.append(internalIndent).append("...\n");
    276       for (SequenceComponent component : getExtensionComponents()) {
    277         if (component.isExplicitlySet()) {
    278           builder.append(internalIndent)
    279               .append(component.toIndentedString(internalIndent));
    280         }
    281       }
    282     }
    283     builder.append(indent).append("};\n");
    284     return builder.toString();
    285   }
    286 }
    287