if (DER.CONSTRUCTED_VALUE.equals (object.getValue ())) { out.write (object.getEncoded ()); return object.getLength (); }
  public static int write(OutputStream out, DERValue object)     throws IOException  {    out.write(object.getExternalTag());    Object value = object.getValue();    if (value == null)      {        writeLength(out, 0);        return 0;      }    if (value instanceof Boolean)      return writeBoolean(out, (Boolean) value);    else if (value instanceof BigInteger)      return writeInteger(out, (BigInteger) value);    else if (value instanceof Date)      return writeDate(out, object.getExternalTag(), (Date) value);    else if (value instanceof String)      return writeString(out, object.getExternalTag(), (String) value);    else if (value instanceof List)      return writeSequence(out, (List) value);    else if (value instanceof Set)      return writeSet(out, (Set) value);    else if (value instanceof BitString)      return writeBitString(out, (BitString) value);    else if (value instanceof OID)      return writeOID(out, (OID) value);    else if (value instanceof byte[])      {        writeLength(out, ((byte[]) value).length);        out.write((byte[]) value);        return ((byte[]) value).length;      }    else if (value instanceof DERValue)      {        ByteArrayOutputStream bout = new ByteArrayOutputStream();        write(bout, (DERValue) value);        byte[] buf = bout.toByteArray();        writeLength(out, buf.length);        out.write(buf);        return buf.length;      }    else      throw new DEREncodingException("cannot encode " + value.getClass().getName());  }