Home | History | Annotate | Download | only in supl_start
      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.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.ulp_components.LocationId;
     33 import android.location.cts.asn1.supl2.ulp_components.QoP;
     34 import android.location.cts.asn1.supl2.ulp_version_2_message_extensions.Ver2_SUPL_START_extension;
     35 import com.google.common.collect.ImmutableList;
     36 import java.util.Collection;
     37 import javax.annotation.Nullable;
     38 
     39 
     40 /**
     41 */
     42 public  class SUPLSTART extends Asn1Sequence {
     43   //
     44 
     45   private static final Asn1Tag TAG_SUPLSTART
     46       = Asn1Tag.fromClassAndNumber(-1, -1);
     47 
     48   public SUPLSTART() {
     49     super();
     50   }
     51 
     52   @Override
     53   @Nullable
     54   protected Asn1Tag getTag() {
     55     return TAG_SUPLSTART;
     56   }
     57 
     58   @Override
     59   protected boolean isTagImplicit() {
     60     return true;
     61   }
     62 
     63   public static Collection<Asn1Tag> getPossibleFirstTags() {
     64     if (TAG_SUPLSTART != null) {
     65       return ImmutableList.of(TAG_SUPLSTART);
     66     } else {
     67       return Asn1Sequence.getPossibleFirstTags();
     68     }
     69   }
     70 
     71   /**
     72    * Creates a new SUPLSTART from encoded stream.
     73    */
     74   public static SUPLSTART fromPerUnaligned(byte[] encodedBytes) {
     75     SUPLSTART result = new SUPLSTART();
     76     result.decodePerUnaligned(new BitStreamReader(encodedBytes));
     77     return result;
     78   }
     79 
     80   /**
     81    * Creates a new SUPLSTART from encoded stream.
     82    */
     83   public static SUPLSTART fromPerAligned(byte[] encodedBytes) {
     84     SUPLSTART result = new SUPLSTART();
     85     result.decodePerAligned(new BitStreamReader(encodedBytes));
     86     return result;
     87   }
     88 
     89 
     90 
     91   @Override protected boolean isExtensible() {
     92     return true;
     93   }
     94 
     95   @Override public boolean containsExtensionValues() {
     96     for (SequenceComponent extensionComponent : getExtensionComponents()) {
     97       if (extensionComponent.isExplicitlySet()) return true;
     98     }
     99     return false;
    100   }
    101 
    102 
    103   private SETCapabilities sETCapabilities_;
    104   public SETCapabilities getSETCapabilities() {
    105     return sETCapabilities_;
    106   }
    107   /**
    108    * @throws ClassCastException if value is not a SETCapabilities
    109    */
    110   public void setSETCapabilities(Asn1Object value) {
    111     this.sETCapabilities_ = (SETCapabilities) value;
    112   }
    113   public SETCapabilities setSETCapabilitiesToNewInstance() {
    114     sETCapabilities_ = new SETCapabilities();
    115     return sETCapabilities_;
    116   }
    117 
    118   private LocationId locationId_;
    119   public LocationId getLocationId() {
    120     return locationId_;
    121   }
    122   /**
    123    * @throws ClassCastException if value is not a LocationId
    124    */
    125   public void setLocationId(Asn1Object value) {
    126     this.locationId_ = (LocationId) value;
    127   }
    128   public LocationId setLocationIdToNewInstance() {
    129     locationId_ = new LocationId();
    130     return locationId_;
    131   }
    132 
    133   private QoP qoP_;
    134   public QoP getQoP() {
    135     return qoP_;
    136   }
    137   /**
    138    * @throws ClassCastException if value is not a QoP
    139    */
    140   public void setQoP(Asn1Object value) {
    141     this.qoP_ = (QoP) value;
    142   }
    143   public QoP setQoPToNewInstance() {
    144     qoP_ = new QoP();
    145     return qoP_;
    146   }
    147 
    148 
    149 
    150   private Ver2_SUPL_START_extension  extensionVer2_SUPL_START_extension;
    151   public Ver2_SUPL_START_extension getExtensionVer2_SUPL_START_extension() {
    152     return extensionVer2_SUPL_START_extension;
    153   }
    154   /**
    155    * @throws ClassCastException if value is not a Ver2_SUPL_START_extension
    156    */
    157   public void setExtensionVer2_SUPL_START_extension(Asn1Object value) {
    158     extensionVer2_SUPL_START_extension = (Ver2_SUPL_START_extension) value;
    159   }
    160   public void setExtensionVer2_SUPL_START_extensionToNewInstance() {
    161     extensionVer2_SUPL_START_extension = new Ver2_SUPL_START_extension();
    162   }
    163 
    164 
    165 
    166 
    167   @Override public Iterable<? extends SequenceComponent> getComponents() {
    168     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    169 
    170     builder.add(new SequenceComponent() {
    171           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0);
    172 
    173           @Override public boolean isExplicitlySet() {
    174             return getSETCapabilities() != null;
    175           }
    176 
    177           @Override public boolean hasDefaultValue() {
    178             return false;
    179           }
    180 
    181           @Override public boolean isOptional() {
    182             return false;
    183           }
    184 
    185           @Override public Asn1Object getComponentValue() {
    186             return getSETCapabilities();
    187           }
    188 
    189           @Override public void setToNewInstance() {
    190             setSETCapabilitiesToNewInstance();
    191           }
    192 
    193           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    194             return tag == null ? SETCapabilities.getPossibleFirstTags() : ImmutableList.of(tag);
    195           }
    196 
    197           @Override
    198           public Asn1Tag getTag() {
    199             return tag;
    200           }
    201 
    202           @Override
    203           public boolean isImplicitTagging() {
    204             return true;
    205           }
    206 
    207           @Override public String toIndentedString(String indent) {
    208                 return "sETCapabilities : "
    209                     + getSETCapabilities().toIndentedString(indent);
    210               }
    211         });
    212 
    213     builder.add(new SequenceComponent() {
    214           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1);
    215 
    216           @Override public boolean isExplicitlySet() {
    217             return getLocationId() != null;
    218           }
    219 
    220           @Override public boolean hasDefaultValue() {
    221             return false;
    222           }
    223 
    224           @Override public boolean isOptional() {
    225             return false;
    226           }
    227 
    228           @Override public Asn1Object getComponentValue() {
    229             return getLocationId();
    230           }
    231 
    232           @Override public void setToNewInstance() {
    233             setLocationIdToNewInstance();
    234           }
    235 
    236           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    237             return tag == null ? LocationId.getPossibleFirstTags() : ImmutableList.of(tag);
    238           }
    239 
    240           @Override
    241           public Asn1Tag getTag() {
    242             return tag;
    243           }
    244 
    245           @Override
    246           public boolean isImplicitTagging() {
    247             return true;
    248           }
    249 
    250           @Override public String toIndentedString(String indent) {
    251                 return "locationId : "
    252                     + getLocationId().toIndentedString(indent);
    253               }
    254         });
    255 
    256     builder.add(new SequenceComponent() {
    257           Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 2);
    258 
    259           @Override public boolean isExplicitlySet() {
    260             return getQoP() != null;
    261           }
    262 
    263           @Override public boolean hasDefaultValue() {
    264             return false;
    265           }
    266 
    267           @Override public boolean isOptional() {
    268             return true;
    269           }
    270 
    271           @Override public Asn1Object getComponentValue() {
    272             return getQoP();
    273           }
    274 
    275           @Override public void setToNewInstance() {
    276             setQoPToNewInstance();
    277           }
    278 
    279           @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    280             return tag == null ? QoP.getPossibleFirstTags() : ImmutableList.of(tag);
    281           }
    282 
    283           @Override
    284           public Asn1Tag getTag() {
    285             return tag;
    286           }
    287 
    288           @Override
    289           public boolean isImplicitTagging() {
    290             return true;
    291           }
    292 
    293           @Override public String toIndentedString(String indent) {
    294                 return "qoP : "
    295                     + getQoP().toIndentedString(indent);
    296               }
    297         });
    298 
    299     return builder.build();
    300   }
    301 
    302   @Override public Iterable<? extends SequenceComponent>
    303                                                     getExtensionComponents() {
    304     ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder();
    305 
    306       builder.add(new SequenceComponent() {
    307             @Override public boolean isExplicitlySet() {
    308               return getExtensionVer2_SUPL_START_extension() != null;
    309             }
    310 
    311             @Override public boolean hasDefaultValue() {
    312               return false;
    313             }
    314 
    315             @Override public boolean isOptional() {
    316               return true;
    317             }
    318 
    319             @Override public Asn1Object getComponentValue() {
    320               return getExtensionVer2_SUPL_START_extension();
    321             }
    322 
    323             @Override public void setToNewInstance() {
    324               setExtensionVer2_SUPL_START_extensionToNewInstance();
    325             }
    326 
    327             @Override public Collection<Asn1Tag> getPossibleFirstTags() {
    328               throw new UnsupportedOperationException(
    329                   "BER decoding not supported for extension elements");
    330             }
    331 
    332             @Override
    333             public Asn1Tag getTag() {
    334               throw new UnsupportedOperationException(
    335                   "BER is not supported for extension elements");
    336             }
    337 
    338             @Override
    339             public boolean isImplicitTagging() {
    340               throw new UnsupportedOperationException(
    341                   "BER is not supported for extension elements");
    342             }
    343 
    344             @Override public String toIndentedString(String indent) {
    345               return "ver2_SUPL_START_extension : "
    346                   + getExtensionVer2_SUPL_START_extension().toIndentedString(indent);
    347             }
    348       });
    349 
    350       return builder.build();
    351     }
    352 
    353 
    354 
    355 
    356 
    357 
    358 
    359 
    360 
    361 
    362 
    363 
    364 
    365   @Override public Iterable<BitStream> encodePerUnaligned() {
    366     return super.encodePerUnaligned();
    367   }
    368 
    369   @Override public Iterable<BitStream> encodePerAligned() {
    370     return super.encodePerAligned();
    371   }
    372 
    373   @Override public void decodePerUnaligned(BitStreamReader reader) {
    374     super.decodePerUnaligned(reader);
    375   }
    376 
    377   @Override public void decodePerAligned(BitStreamReader reader) {
    378     super.decodePerAligned(reader);
    379   }
    380 
    381   @Override public String toString() {
    382     return toIndentedString("");
    383   }
    384 
    385   public String toIndentedString(String indent) {
    386     StringBuilder builder = new StringBuilder();
    387     builder.append("SUPLSTART = {\n");
    388     final String internalIndent = indent + "  ";
    389     for (SequenceComponent component : getComponents()) {
    390       if (component.isExplicitlySet()) {
    391         builder.append(internalIndent)
    392             .append(component.toIndentedString(internalIndent));
    393       }
    394     }
    395     if (isExtensible()) {
    396       builder.append(internalIndent).append("...\n");
    397       for (SequenceComponent component : getExtensionComponents()) {
    398         if (component.isExplicitlySet()) {
    399           builder.append(internalIndent)
    400               .append(component.toIndentedString(internalIndent));
    401         }
    402       }
    403     }
    404     builder.append(indent).append("};\n");
    405     return builder.toString();
    406   }
    407 }
    408