TOC PREV NEXT INDEX


Encode Method



The generated encode method for BER/DER has the following general form:

   public int encode (Asn1BerEncodeBuffer buffer, boolean explicit);
 

The Asn1BerEncodeBuffer argument specifies the buffer into which the message will be encoded. The explicit argument is primarily for use by the compiler for generating internal calls to handle implicitly tagged elements in constructed types. Users should always set this argument to true.

The encode method returns the length of the encoded component. Unlike the C /C++ version, this return value does no double as a status value as well. Any errors that occur in the encode process are reported by throwing an ASN1C exception. A complete list of these exceptions can be found in the ASN1C Exceptions section.

The general form of a PER encode method is as follows:

   public void encode (Asn1PerEncodeBuffer buffer);
 

In this case, the explicit argument is not required since PER has no tagging. The only required argument is a reference to an encode buffer object. Also note that the return value is void instead of int. No intermediate lengths are returned during the encoding of a PER message. Any errors that occur are reported as an exception; hence there I no need for a return value.

The general form of an XER encode method is as follows:

   public void encode (Asn1XerEncodeBuffer buffer, String elemName);
 

In this case, the buffer reference is to an XER encode buffer and an element name argument is added. The element name is the name of the element that is to bracket the XML encoded value (i.e. <elemName>value</elemName>). The return type is also void as in the PER case because errors are reported through the exception mechanism.


Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX

Copyright © 1997-2004 Objective Systems,Inc.
All Rights Reserved.


This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.