@Override public void decode(Asn1ParseResult parseResult) throws IOException { if (chosenField == null) { matchAndSetValue(parseResult.tag()); } decodeBody(parseResult); }
protected byte[] getChoiceValueAsOctets(EnumType index) { Asn1OctetString value = getChoiceValueAs(index, Asn1OctetString.class); if (value != null) { return value.getValue(); } return null; }
@Override protected int encodingBodyLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue == null) { return 0; } return -1; // Indicate error, shouldn't be here. }
@Override protected void decodeBody(Asn1ParseResult parseResult) throws IOException { if (chosenField == null) { matchAndSetValue(parseResult.tag()); } if (chosenField == null) { throw new IOException("Unexpected item, not in choices: " + parseResult.simpleInfo()); } Asn1Type fieldValue = getValue(); if (parseResult.isContextSpecific()) { Asn1Binder.bindWithTagging(parseResult, fieldValue, chosenField.getTaggingOption()); } else { Asn1Binder.bind(parseResult, fieldValue); } }
@Override public void decode(ByteBuffer content) throws IOException { chosenField = null; setValue(null); super.decode(content); }
public Asn1Choice(Asn1FieldInfo[] fieldInfos) { super(UniversalTag.CHOICE); this.fieldInfos = fieldInfos; this.tags = new Tag[fieldInfos.length]; initTags(); }
protected void setChoiceValueAsOctets(EnumType index, byte[] bytes) { Asn1OctetString value = new Asn1OctetString(bytes); setChoiceValue(index, value); }
} else if (fieldValue instanceof Asn1Choice) { Asn1Choice aChoice = (Asn1Choice) fieldValue; if (aChoice.matchAndSetValue(parseItem.tag())) { foundPos = i; break; Asn1Choice aChoice = (Asn1Choice) (fields[i] = fieldInfo .createFieldValue()); if (aChoice.matchAndSetValue(parseItem.tag())) { foundPos = i; break;
@Override protected void decodeBody(Asn1ParseResult parseResult) throws IOException { if (chosenField == null) { matchAndSetValue(parseResult.tag()); } if (chosenField == null) { throw new IOException("Unexpected item, not in choices: " + parseResult.simpleInfo()); } Asn1Type fieldValue = getValue(); if (parseResult.isContextSpecific()) { Asn1Binder.bindWithTagging(parseResult, fieldValue, chosenField.getTaggingOption()); } else { Asn1Binder.bind(parseResult, fieldValue); } }
@Override public void decode(ByteBuffer content) throws IOException { chosenField = null; setValue(null); super.decode(content); }
public Asn1Choice(Asn1FieldInfo[] fieldInfos) { super(UniversalTag.CHOICE); this.fieldInfos = fieldInfos; this.tags = new Tag[fieldInfos.length]; initTags(); }
protected void setChoiceValueAsOctets(EnumType index, byte[] bytes) { Asn1OctetString value = new Asn1OctetString(bytes); setChoiceValue(index, value); }
} else if (fieldValue instanceof Asn1Choice) { Asn1Choice aChoice = (Asn1Choice) fieldValue; if (aChoice.matchAndSetValue(parseItem.tag())) { foundPos = i; break; Asn1Choice aChoice = (Asn1Choice) (fields[i] = fieldInfo .createFieldValue()); if (aChoice.matchAndSetValue(parseItem.tag())) { foundPos = i; break;
@Override protected int encodingBodyLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue == null) { return 0; } return -1; // Indicate error, shouldn't be here. }
@Override public void decode(Asn1ParseResult parseResult) throws IOException { if (chosenField == null) { matchAndSetValue(parseResult.tag()); } decodeBody(parseResult); }
protected void setChoiceValue(EnumType index, Asn1Type value) { if (fieldInfos[index.getValue()].getIndex() != index) { throw new IllegalArgumentException("Incorrect choice option to set"); } this.chosenField = fieldInfos[index.getValue()]; setValue(value); }
protected byte[] getChoiceValueAsOctets(EnumType index) { Asn1OctetString value = getChoiceValueAs(index, Asn1OctetString.class); if (value != null) { return value.getValue(); } return null; }
protected <T extends Asn1Type> T getChoiceValueAs(EnumType index, Class<T> t) { if (chosenField == null || getValue() == null) { return null; } if (chosenField != null && index != chosenField.getIndex()) { throw new IllegalArgumentException("Incorrect chosen value requested"); } return (T) getValue(); }
protected void setChoiceValue(EnumType index, Asn1Type value) { if (fieldInfos[index.getValue()].getIndex() != index) { throw new IllegalArgumentException("Incorrect choice option to set"); } this.chosenField = fieldInfos[index.getValue()]; setValue(value); }
protected <T extends Asn1Type> T getChoiceValueAs(EnumType index, Class<T> t) { if (chosenField == null || getValue() == null) { return null; } if (chosenField != null && index != chosenField.getIndex()) { throw new IllegalArgumentException("Incorrect chosen value requested"); } return (T) getValue(); }