FileDocCategorySizeDatePackage
RecipientInformationStore.javaAPI DocBouncy Castle Crypto API 1.41 (Java 1.5)3459Wed Oct 01 10:55:28 BST 2008org.bouncycastle.cms

RecipientInformationStore

public class RecipientInformationStore extends Object

Fields Summary
private Map
table
Constructors Summary
public RecipientInformationStore(Collection recipientInfos)


     
          
    
        Iterator    it = recipientInfos.iterator();

        while (it.hasNext())
        {
            RecipientInformation   recipientInformation = (RecipientInformation)it.next();
            RecipientId            rid = recipientInformation.getRID();

            if (table.get(rid) == null)
            {
                table.put(rid, recipientInformation);
            }
            else
            {
                Object o = table.get(rid);

                if (o instanceof List)
                {
                    ((List)o).add(recipientInformation);
                }
                else
                {
                    List l = new ArrayList();

                    l.add(o);
                    l.add(recipientInformation);

                    table.put(rid, l);
                }
            }
        }
    
Methods Summary
public RecipientInformationget(RecipientId selector)
Return the first RecipientInformation object that matches the passed in selector. Null if there are no matches.

param
selector to identify a recipient
return
a single RecipientInformation object. Null if none matches.

        Object o = table.get(selector);

        if (o instanceof List)
        {
            return (RecipientInformation)((List)o).get(0);
        }
        else
        {
            return (RecipientInformation)o;
        }
    
public java.util.CollectiongetRecipients()
Return all recipients in the collection

return
a collection of recipients.

        List        list = new ArrayList(table.size());
        Iterator    it = table.values().iterator();

        while (it.hasNext())
        {
            Object o = it.next();

            if (o instanceof List)
            {
                list.addAll((List)o);
            }
            else
            {
                list.add(o);
            }
        }

        return list;
    
public java.util.CollectiongetRecipients(RecipientId selector)
Return possible empty collection with recipients matching the passed in RecipientId

param
selector a recipient id to select against.
return
a collection of RecipientInformation objects.

        Object o = table.get(selector);

        if (o instanceof List)
        {
            return new ArrayList((List)o);
        }
        else if (o != null)
        {
            return Collections.singletonList(o);
        }

        return new ArrayList();
    
public intsize()
Return the number of recipients in the collection.

return
number of recipients identified.

        Iterator    it = table.values().iterator();
        int         count = 0;

        while (it.hasNext())
        {
            Object o = it.next();

            if (o instanceof List)
            {
                count += ((List)o).size();
            }
            else
            {
                count++;
            }
        }

        return count;