/** * create a sequence containing a vector of objects. */ protected ASN1Set( ASN1Encodable[] array, boolean doSort) { for (int i = 0; i != array.length; i++) { set.addElement(array[i]); } if (doSort) { this.sort(); } }
/** * Create a SET containing an array of objects. * @param array an array of objects to make up the SET. * @param doSort true if should be sorted DER style, false otherwise. */ protected ASN1Set( ASN1Encodable[] array, boolean doSort) { for (int i = 0; i != array.length; i++) { set.addElement(array[i]); } if (doSort) { this.sort(); } }
/** * create a sequence containing a vector of objects. */ protected ASN1Set( ASN1EncodableVector v, boolean doSort) { for (int i = 0; i != v.size(); i++) { set.addElement(v.get(i)); } if (doSort) { this.sort(); } }
ASN1Primitive toDERObject() { if (isSorted) { ASN1Set derSet = new DERSet(); derSet.set = this.set; return derSet; } else { Vector v = new Vector(); for (int i = 0; i != set.size(); i++) { v.addElement(set.elementAt(i)); } ASN1Set derSet = new DERSet(); derSet.set = v; derSet.sort(); return derSet; } }
/** * Create a SET containing a vector of objects. * @param v a vector of objects to make up the SET. * @param doSort true if should be sorted DER style, false otherwise. */ protected ASN1Set( ASN1EncodableVector v, boolean doSort) { for (int i = 0; i != v.size(); i++) { set.addElement(v.get(i)); } if (doSort) { this.sort(); } }
/** * Change current SET object to be encoded as {@link DERSet}. * This is part of Distinguished Encoding Rules form serialization. */ ASN1Primitive toDERObject() { if (isSorted) { ASN1Set derSet = new DERSet(); derSet.set = this.set; return derSet; } else { Vector v = new Vector(); for (int i = 0; i != set.size(); i++) { v.addElement(set.elementAt(i)); } ASN1Set derSet = new DERSet(); derSet.set = v; derSet.sort(); return derSet; } }