| /* |
| * Copyright (C) 2017 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package android.location.cts.asn1.supl2.ulp_components; |
| |
| /* |
| */ |
| |
| |
| // |
| // |
| import android.location.cts.asn1.base.Asn1Null; |
| import android.location.cts.asn1.base.Asn1Object; |
| import android.location.cts.asn1.base.Asn1OctetString; |
| import android.location.cts.asn1.base.Asn1Sequence; |
| import android.location.cts.asn1.base.Asn1Tag; |
| import android.location.cts.asn1.base.BitStream; |
| import android.location.cts.asn1.base.BitStreamReader; |
| import android.location.cts.asn1.base.SequenceComponent; |
| import com.google.common.collect.ImmutableList; |
| import java.util.Collection; |
| import javax.annotation.Nullable; |
| |
| |
| /** |
| */ |
| public class SlpSessionID extends Asn1Sequence { |
| // |
| |
| private static final Asn1Tag TAG_SlpSessionID |
| = Asn1Tag.fromClassAndNumber(-1, -1); |
| |
| public SlpSessionID() { |
| super(); |
| } |
| |
| @Override |
| @Nullable |
| protected Asn1Tag getTag() { |
| return TAG_SlpSessionID; |
| } |
| |
| @Override |
| protected boolean isTagImplicit() { |
| return true; |
| } |
| |
| public static Collection<Asn1Tag> getPossibleFirstTags() { |
| if (TAG_SlpSessionID != null) { |
| return ImmutableList.of(TAG_SlpSessionID); |
| } else { |
| return Asn1Sequence.getPossibleFirstTags(); |
| } |
| } |
| |
| /** |
| * Creates a new SlpSessionID from encoded stream. |
| */ |
| public static SlpSessionID fromPerUnaligned(byte[] encodedBytes) { |
| SlpSessionID result = new SlpSessionID(); |
| result.decodePerUnaligned(new BitStreamReader(encodedBytes)); |
| return result; |
| } |
| |
| /** |
| * Creates a new SlpSessionID from encoded stream. |
| */ |
| public static SlpSessionID fromPerAligned(byte[] encodedBytes) { |
| SlpSessionID result = new SlpSessionID(); |
| result.decodePerAligned(new BitStreamReader(encodedBytes)); |
| return result; |
| } |
| |
| |
| |
| @Override protected boolean isExtensible() { |
| return false; |
| } |
| |
| @Override public boolean containsExtensionValues() { |
| for (SequenceComponent extensionComponent : getExtensionComponents()) { |
| if (extensionComponent.isExplicitlySet()) return true; |
| } |
| return false; |
| } |
| |
| |
| private SlpSessionID.sessionIDType sessionID_; |
| public SlpSessionID.sessionIDType getSessionID() { |
| return sessionID_; |
| } |
| /** |
| * @throws ClassCastException if value is not a SlpSessionID.sessionIDType |
| */ |
| public void setSessionID(Asn1Object value) { |
| this.sessionID_ = (SlpSessionID.sessionIDType) value; |
| } |
| public SlpSessionID.sessionIDType setSessionIDToNewInstance() { |
| sessionID_ = new SlpSessionID.sessionIDType(); |
| return sessionID_; |
| } |
| |
| private SLPAddress slpId_; |
| public SLPAddress getSlpId() { |
| return slpId_; |
| } |
| /** |
| * @throws ClassCastException if value is not a SLPAddress |
| */ |
| public void setSlpId(Asn1Object value) { |
| this.slpId_ = (SLPAddress) value; |
| } |
| public SLPAddress setSlpIdToNewInstance() { |
| slpId_ = new SLPAddress(); |
| return slpId_; |
| } |
| |
| |
| |
| |
| |
| |
| @Override public Iterable<? extends SequenceComponent> getComponents() { |
| ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder(); |
| |
| builder.add(new SequenceComponent() { |
| Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 0); |
| |
| @Override public boolean isExplicitlySet() { |
| return getSessionID() != null; |
| } |
| |
| @Override public boolean hasDefaultValue() { |
| return false; |
| } |
| |
| @Override public boolean isOptional() { |
| return false; |
| } |
| |
| @Override public Asn1Object getComponentValue() { |
| return getSessionID(); |
| } |
| |
| @Override public void setToNewInstance() { |
| setSessionIDToNewInstance(); |
| } |
| |
| @Override public Collection<Asn1Tag> getPossibleFirstTags() { |
| return tag == null ? SlpSessionID.sessionIDType.getPossibleFirstTags() : ImmutableList.of(tag); |
| } |
| |
| @Override |
| public Asn1Tag getTag() { |
| return tag; |
| } |
| |
| @Override |
| public boolean isImplicitTagging() { |
| return true; |
| } |
| |
| @Override public String toIndentedString(String indent) { |
| return "sessionID : " |
| + getSessionID().toIndentedString(indent); |
| } |
| }); |
| |
| builder.add(new SequenceComponent() { |
| Asn1Tag tag = Asn1Tag.fromClassAndNumber(2, 1); |
| |
| @Override public boolean isExplicitlySet() { |
| return getSlpId() != null; |
| } |
| |
| @Override public boolean hasDefaultValue() { |
| return false; |
| } |
| |
| @Override public boolean isOptional() { |
| return false; |
| } |
| |
| @Override public Asn1Object getComponentValue() { |
| return getSlpId(); |
| } |
| |
| @Override public void setToNewInstance() { |
| setSlpIdToNewInstance(); |
| } |
| |
| @Override public Collection<Asn1Tag> getPossibleFirstTags() { |
| return tag == null ? SLPAddress.getPossibleFirstTags() : ImmutableList.of(tag); |
| } |
| |
| @Override |
| public Asn1Tag getTag() { |
| return tag; |
| } |
| |
| @Override |
| public boolean isImplicitTagging() { |
| return true; |
| } |
| |
| @Override public String toIndentedString(String indent) { |
| return "slpId : " |
| + getSlpId().toIndentedString(indent); |
| } |
| }); |
| |
| return builder.build(); |
| } |
| |
| @Override public Iterable<? extends SequenceComponent> |
| getExtensionComponents() { |
| ImmutableList.Builder<SequenceComponent> builder = ImmutableList.builder(); |
| |
| return builder.build(); |
| } |
| |
| |
| /* |
| */ |
| |
| |
| // |
| |
| /** |
| */ |
| public static class sessionIDType extends Asn1OctetString { |
| // |
| |
| private static final Asn1Tag TAG_sessionIDType |
| = Asn1Tag.fromClassAndNumber(-1, -1); |
| |
| public sessionIDType() { |
| super(); |
| setMinSize(4); |
| setMaxSize(4); |
| |
| } |
| |
| @Override |
| @Nullable |
| protected Asn1Tag getTag() { |
| return TAG_sessionIDType; |
| } |
| |
| @Override |
| protected boolean isTagImplicit() { |
| return true; |
| } |
| |
| public static Collection<Asn1Tag> getPossibleFirstTags() { |
| if (TAG_sessionIDType != null) { |
| return ImmutableList.of(TAG_sessionIDType); |
| } else { |
| return Asn1OctetString.getPossibleFirstTags(); |
| } |
| } |
| |
| /** |
| * Creates a new sessionIDType from encoded stream. |
| */ |
| public static sessionIDType fromPerUnaligned(byte[] encodedBytes) { |
| sessionIDType result = new sessionIDType(); |
| result.decodePerUnaligned(new BitStreamReader(encodedBytes)); |
| return result; |
| } |
| |
| /** |
| * Creates a new sessionIDType from encoded stream. |
| */ |
| public static sessionIDType fromPerAligned(byte[] encodedBytes) { |
| sessionIDType result = new sessionIDType(); |
| result.decodePerAligned(new BitStreamReader(encodedBytes)); |
| return result; |
| } |
| |
| @Override public Iterable<BitStream> encodePerUnaligned() { |
| return super.encodePerUnaligned(); |
| } |
| |
| @Override public Iterable<BitStream> encodePerAligned() { |
| return super.encodePerAligned(); |
| } |
| |
| @Override public void decodePerUnaligned(BitStreamReader reader) { |
| super.decodePerUnaligned(reader); |
| } |
| |
| @Override public void decodePerAligned(BitStreamReader reader) { |
| super.decodePerAligned(reader); |
| } |
| |
| @Override protected String getTypeName() { |
| return "sessionIDType"; |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| @Override public Iterable<BitStream> encodePerUnaligned() { |
| return super.encodePerUnaligned(); |
| } |
| |
| @Override public Iterable<BitStream> encodePerAligned() { |
| return super.encodePerAligned(); |
| } |
| |
| @Override public void decodePerUnaligned(BitStreamReader reader) { |
| super.decodePerUnaligned(reader); |
| } |
| |
| @Override public void decodePerAligned(BitStreamReader reader) { |
| super.decodePerAligned(reader); |
| } |
| |
| @Override public String toString() { |
| return toIndentedString(""); |
| } |
| |
| public String toIndentedString(String indent) { |
| StringBuilder builder = new StringBuilder(); |
| builder.append("SlpSessionID = {\n"); |
| final String internalIndent = indent + " "; |
| for (SequenceComponent component : getComponents()) { |
| if (component.isExplicitlySet()) { |
| builder.append(internalIndent) |
| .append(component.toIndentedString(internalIndent)); |
| } |
| } |
| if (isExtensible()) { |
| builder.append(internalIndent).append("...\n"); |
| for (SequenceComponent component : getExtensionComponents()) { |
| if (component.isExplicitlySet()) { |
| builder.append(internalIndent) |
| .append(component.toIndentedString(internalIndent)); |
| } |
| } |
| } |
| builder.append(indent).append("};\n"); |
| return builder.toString(); |
| } |
| } |