The signature for the MDER encode method comes in two forms, shown below:
public void encode(Asn1MderOutputStream buffer, boolean useCachedLength ) throws Asn1Exception, java.io.IOException public void encode(Asn1MderOutputStream buffer ) throws Asn1Exception, java.io.IOException
The buffer argument is an Asn1MderOutputStream object which receives the encoded message. This must be created and initialized before calling any encode method. See the description of this class in the Java Run-Time Classes section for details on how this class is used.
The useCachedLength argument indicates whether the encode method
can rely on cached length information. In some cases, MDER requires pre-calculation of the
length of nested structures and this piece of information is needed twice during encoding
(once when encoding the containing structure and once when encoding the nested structure).
The generated types cache this information during encoding. User code should normally pass
false
for this argument. The generated encoding methods will pass
true
to other encoding methods when appropriate.
As you can see, the encode methods return void; an exception is thrown if an error occurs. All ASN1C Java exceptions are derived from Asn1Exception. See the section on exceptions for a complete list and description of the various exceptions that can be thrown.