Пример #1
0
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }

    if (!(o instanceof ASN1Encodable)) {
      return false;
    }

    ASN1Encodable other = (ASN1Encodable) o;

    return this.toASN1Primitive().equals(other.toASN1Primitive());
  }
Пример #2
0
 public void writeObject(ASN1Encodable obj) throws IOException {
   if (obj != null) {
     obj.toASN1Primitive().encode(this);
   } else {
     throw new IOException("null object detected");
   }
 }
  @Override
  public Object getObjectToEncode(Object object) {
    if (object instanceof ChosenValue) {
      ChosenValue chosen = (ChosenValue) object;
      return chosen.getValue();
    }

    if (object instanceof ASN1Encodable) {
      Object[] value = new Object[1];
      ((ASN1Encodable) object).encodeValues(value);
      return getObjectToEncode(value[0]);
    }

    return ((Object[]) object)[1];
  }
  @Override
  public int getIndex(Object object) {
    if (object instanceof ChosenValue) {
      ChosenValue chosen = (ChosenValue) object;
      return chosen.getIndex();
    }

    if (object instanceof ASN1Encodable) {
      Object[] value = new Object[1];
      ((ASN1Encodable) object).encodeValues(value);
      return getIndex(value[0]);
    }

    Object[] values = (Object[]) object;
    return ((Integer) values[0]).intValue();
  }