Home | History | Annotate | Download | only in x509
      1 package org.bouncycastle.x509;
      2 
      3 import java.util.ArrayList;
      4 import java.util.Collection;
      5 
      6 /**
      7  * This class contains a collection for collection based <code>X509Store</code>s.
      8  *
      9  * @see org.bouncycastle.x509.X509Store
     10  *
     11  */
     12 public class X509CollectionStoreParameters
     13     implements X509StoreParameters
     14 {
     15     private Collection collection;
     16 
     17     /**
     18      * Constructor.
     19      * <p>
     20      * The collection is copied.
     21      * </p>
     22      *
     23      * @param collection
     24      *            The collection containing X.509 object types.
     25      * @throws NullPointerException if <code>collection</code> is <code>null</code>.
     26      */
     27     public X509CollectionStoreParameters(Collection collection)
     28     {
     29         if (collection == null)
     30         {
     31             throw new NullPointerException("collection cannot be null");
     32         }
     33         this.collection = collection;
     34     }
     35 
     36     /**
     37      * Returns a shallow clone. The returned contents are not copied, so adding
     38      * or removing objects will effect this.
     39      *
     40      * @return a shallow clone.
     41      */
     42     public Object clone()
     43     {
     44         return new X509CollectionStoreParameters(collection);
     45     }
     46 
     47     /**
     48      * Returns a copy of the <code>Collection</code>.
     49      *
     50      * @return The <code>Collection</code>. Is never <code>null</code>.
     51      */
     52     public Collection getCollection()
     53     {
     54         return new ArrayList(collection);
     55     }
     56 
     57     /**
     58      * Returns a formatted string describing the parameters.
     59      *
     60      * @return a formatted string describing the parameters
     61      */
     62     public String toString()
     63     {
     64         StringBuffer sb = new StringBuffer();
     65         sb.append("X509CollectionStoreParameters: [\n");
     66         sb.append("  collection: " + collection + "\n");
     67         sb.append("]");
     68         return sb.toString();
     69     }
     70 }
     71