FileDocCategorySizeDatePackage
AttributeTable.javaAPI DocAndroid 1.5 API4159Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.cms

AttributeTable

public class AttributeTable extends Object

Fields Summary
private Hashtable
attributes
Constructors Summary
public AttributeTable(Hashtable attrs)


     
          
    
        attributes = copyTable(attrs);
    
public AttributeTable(org.bouncycastle.asn1.DEREncodableVector v)

        for (int i = 0; i != v.size(); i++)
        {
            Attribute   a = Attribute.getInstance(v.get(i));

            addAttribute(a.getAttrType(), a);
        }
    
public AttributeTable(org.bouncycastle.asn1.ASN1Set s)

        for (int i = 0; i != s.size(); i++)
        {
            Attribute   a = Attribute.getInstance(s.getObjectAt(i));

            addAttribute(a.getAttrType(), a);
        }
    
Methods Summary
private voidaddAttribute(org.bouncycastle.asn1.DERObjectIdentifier oid, Attribute a)

        Object value = attributes.get(oid);
        
        if (value == null)
        {
            attributes.put(oid, a);
        }
        else
        {
            Vector v;
            
            if (value instanceof Attribute)
            {
                v = new Vector();
                
                v.addElement(value);
                v.addElement(a);
            }
            else
            {
                v = (Vector)value;
            
                v.addElement(a);
            }
            
            attributes.put(oid, v);
        }
    
private java.util.HashtablecopyTable(java.util.Hashtable in)

        Hashtable   out = new Hashtable();
        Enumeration e = in.keys();
        
        while (e.hasMoreElements())
        {
            Object key = e.nextElement();
            
            out.put(key, in.get(key));
        }
        
        return out;
    
public Attributeget(org.bouncycastle.asn1.DERObjectIdentifier oid)
Return the first attribute matching the OBJECT IDENTIFIER oid.

param
oid type of attribute required.
return
first attribute found of type oid.

        Object value = attributes.get(oid);
        
        if (value instanceof Vector)
        {
            return (Attribute)((Vector)value).elementAt(0);
        }
        
        return (Attribute)value;
    
public org.bouncycastle.asn1.ASN1EncodableVectorgetAll(org.bouncycastle.asn1.DERObjectIdentifier oid)
Return all the attributes matching the OBJECT IDENTIFIER oid. The vector will be empty if there are no attributes of the required type present.

param
oid type of attribute required.
return
a vector of all the attributes found of type oid.

        ASN1EncodableVector v = new ASN1EncodableVector();
        
        Object value = attributes.get(oid);
        
        if (value instanceof Vector)
        {
            Enumeration e = ((Vector)value).elements();
            
            while (e.hasMoreElements())
            {
                v.add((Attribute)e.nextElement());
            }
        }
        else if (value != null)
        {
            v.add((Attribute)value);
        }
        
        return v;
    
public org.bouncycastle.asn1.ASN1EncodableVectortoASN1EncodableVector()

        ASN1EncodableVector  v = new ASN1EncodableVector();
        Enumeration          e = attributes.elements();
        
        while (e.hasMoreElements())
        {
            Object value = e.nextElement();
            
            if (value instanceof Vector)
            {
                Enumeration en = ((Vector)value).elements();
                
                while (en.hasMoreElements())
                {
                    v.add(Attribute.getInstance(en.nextElement()));
                }
            }
            else
            {
                v.add(Attribute.getInstance(value));
            }
        }
        
        return v;
    
public java.util.HashtabletoHashtable()

        return copyTable(attributes);