directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <elecha...@gmail.com>
Subject [Kerby] Q about EncodingOption
Date Sun, 01 Feb 2015 13:48:44 GMT
Hi !

just looking at the EncodingOption enum, and I wonder if there is not a
mixture of things in it.

Typically, we have some encoding type like BER/CER/DER, mixed with other
unrelated values (CONSTRUCTED/PRIMITIVE/IMPLICIT/EXPLICIT).

I understand that it's used to gather multiple flags into one enum, but
- it's not clear from a programmer POV
- you can't tranlate that easily without adding many explicit methods in
the enum (isConstructed(), etc...)

I wonder if using a specifig field for each of those flags would not be
better ?

Something like :

public abstract class AbstractAsn1Type<T> implements Asn1Type {
    private boolean pc    // Primitive/constructed
    private boolean lengthType;  // Definite/Undefinite
    private EncodingType encoding;     // BER/CER/DER/XER/PER
    ...

Going farther, we do the encoding/decoding in the ASN1 type instances.
That's ok, but as soon as we have to deal with various type of encoding
(BER/CER...) this cipple the code with if/else/then. What about having a
decoartor for each type of encoding ?

thoughts ?


Mime
View raw message