1
package org.bouncycastle.cms;
3
import java.util.ArrayList;
4
import java.util.Collection;
5
import java.util.HashMap;
6
import java.util.Iterator;
10
public class RecipientInformationStore
12
private final List all; //ArrayList[RecipientInformation]
13
private final Map table = new HashMap(); // HashMap[RecipientID, ArrayList[RecipientInformation]]
15
public RecipientInformationStore(
16
Collection recipientInfos)
18
Iterator it = recipientInfos.iterator();
22
RecipientInformation recipientInformation = (RecipientInformation)it.next();
23
RecipientId rid = recipientInformation.getRID();
25
List list = (ArrayList)table.get(rid);
28
list = new ArrayList(1);
32
list.add(recipientInformation);
35
this.all = new ArrayList(recipientInfos);
39
* Return the first RecipientInformation object that matches the
40
* passed in selector. Null if there are no matches.
42
* @param selector to identify a recipient
43
* @return a single RecipientInformation object. Null if none matches.
45
public RecipientInformation get(
48
List list = (ArrayList)table.get(selector);
50
return list == null ? null : (RecipientInformation) list.get(0);
54
* Return the number of recipients in the collection.
56
* @return number of recipients identified.
64
* Return all recipients in the collection
66
* @return a collection of recipients.
68
public Collection getRecipients()
70
return new ArrayList(all);
74
* Return possible empty collection with recipients matching the passed in RecipientId
76
* @param selector a recipient id to select against.
77
* @return a collection of RecipientInformation objects.
79
public Collection getRecipients(
82
List list = (ArrayList)table.get(selector);
84
return list == null ? new ArrayList() : new ArrayList(list);