@Override public byte[] encode() throws IOException { int len = encodingLength(); ByteBuffer byteBuffer = ByteBuffer.allocate(len); encode(byteBuffer); byteBuffer.flip(); return byteBuffer.array(); }
@Override public byte[] encode() throws IOException { int len = encodingLength(); ByteBuffer byteBuffer = ByteBuffer.allocate(len); encode(byteBuffer); byteBuffer.flip(); return byteBuffer.array(); }
@Override protected int encodingBodyLength() throws IOException { Asn1Encodeable value = (Asn1Encodeable) getValue(); if (isImplicit()) { return value.encodingBodyLength(); } else { return value.encodingLength(); } }
@Override public int encodingLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue != null) { if (!isBlindlyDecoded) { if (decodeInfo.isTagged()) { TaggingOption taggingOption = decodeInfo.getTaggingOption(); return theValue.taggedEncodingLength(taggingOption); } else { return theValue.encodingLength(); } } else { return theValue.encodingLength(); } } return super.encodingLength(); }
@Override protected int encodingBodyLength() throws IOException { Asn1Encodeable value = (Asn1Encodeable) getValue(); if (isImplicit()) { return value.encodingBodyLength(); } else { return value.encodingLength(); } }
@Override public int encodingLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue != null) { if (!isBlindlyDecoded) { if (decodeInfo.isTagged()) { TaggingOption taggingOption = decodeInfo.getTaggingOption(); return theValue.taggedEncodingLength(taggingOption); } else { return theValue.encodingLength(); } } else { return theValue.encodingLength(); } } return super.encodingLength(); }
@Override protected int encodingBodyLength() throws IOException { int allLen = 0; int fieldLen; for (int i = 0; i < fields.length; ++i) { Asn1Encodeable field = (Asn1Encodeable) fields[i]; if (field != null) { if (fieldInfos[i].isTagged()) { TaggingOption taggingOption = fieldInfos[i].getTaggingOption(); fieldLen = field.taggedEncodingLength(taggingOption); } else { fieldLen = field.encodingLength(); } allLen += fieldLen; } } return allLen; }
@Override protected int encodingBodyLength() throws IOException { int allLen = 0; int fieldLen; for (int i = 0; i < fields.length; ++i) { Asn1Encodeable field = (Asn1Encodeable) fields[i]; if (field != null) { if (fieldInfos[i].isTagged()) { TaggingOption taggingOption = fieldInfos[i].getTaggingOption(); fieldLen = field.taggedEncodingLength(taggingOption); } else { fieldLen = field.encodingLength(); } allLen += fieldLen; } } return allLen; }
protected int taggedEncodingLength(TaggingOption taggingOption) { int taggingTagNo = taggingOption.getTagNo(); int taggingBodyLen = taggingOption.isImplicit() ? getBodyLength() : encodingLength(); int taggingEncodingLen = Asn1Util.lengthOfTagLength(taggingTagNo) + Asn1Util.lengthOfBodyLength(taggingBodyLen) + taggingBodyLen; return taggingEncodingLen; }
protected int taggedEncodingLength(TaggingOption taggingOption) { int taggingTagNo = taggingOption.getTagNo(); int taggingBodyLen = taggingOption.isImplicit() ? getBodyLength() : encodingLength(); int taggingEncodingLen = Asn1Util.lengthOfTagLength(taggingTagNo) + Asn1Util.lengthOfBodyLength(taggingBodyLen) + taggingBodyLen; return taggingEncodingLen; }
@Override public int encodingLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue != null) { if (chosenField.isTagged()) { TaggingOption taggingOption = chosenField.getTaggingOption(); return theValue.taggedEncodingLength(taggingOption); } else { return theValue.encodingLength(); } } return super.encodingLength(); }
@Override public int encodingLength() { Asn1Encodeable theValue = (Asn1Encodeable) getValue(); if (theValue != null) { if (chosenField.isTagged()) { TaggingOption taggingOption = chosenField.getTaggingOption(); return theValue.taggedEncodingLength(taggingOption); } else { return theValue.encodingLength(); } } return super.encodingLength(); }
@Override public void taggedEncode(ByteBuffer buffer, TaggingOption taggingOption) throws IOException { Tag taggingTag = taggingOption.getTag(!isPrimitive()); Asn1Util.encodeTag(buffer, taggingTag); int taggingBodyLen = taggingOption.isImplicit() ? encodingBodyLength() : encodingLength(); Asn1Util.encodeLength(buffer, taggingBodyLen); if (taggingOption.isImplicit()) { encodeBody(buffer); } else { encode(buffer); } }
@Override public void taggedEncode(ByteBuffer buffer, TaggingOption taggingOption) throws IOException { Tag taggingTag = taggingOption.getTag(!isPrimitive()); Asn1Util.encodeTag(buffer, taggingTag); int taggingBodyLen = taggingOption.isImplicit() ? encodingBodyLength() : encodingLength(); Asn1Util.encodeLength(buffer, taggingBodyLen); if (taggingOption.isImplicit()) { encodeBody(buffer); } else { encode(buffer); } }