code: public void encode(DerOutputStream out) throws IOException {
          DerOutputStream tmp = new DerOutputStream();
          name.encode(tmp);
          int nameType = name.getType();
          if (nameType == GeneralNameInterface.NAME_ANY ||
              nameType == GeneralNameInterface.NAME_X400 ||
              nameType == GeneralNameInterface.NAME_EDI) {
  
              // implicit, constructed form
              out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
                                true, (byte)nameType), tmp);
          } else if (nameType == GeneralNameInterface.NAME_DIRECTORY) {
              // explicit, constructed form since underlying tag is CHOICE
              // (see X.680 section 30.6, part c)
              out.write(DerValue.createTag(DerValue.TAG_CONTEXT,
                                           true, (byte)nameType), tmp);
          } else {
              // implicit, primitive form
              out.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT,
                                false, (byte)nameType), tmp);
          }
      }
docs: Encode the name to the specified DerOutputStream.
  
  @param out the DerOutputStream to encode the the GeneralName to.
  @exception IOException on encoding errors.