/** * Adds an attribute to this generic search template. * * @param attribute * The attribute to add to the template. * @preconditions (attribute <> null) * @postconditions */ public void addAttribute(Attribute attribute) { Util.requireNonNull("attribute", attribute); //attributes.addElement(attribute); attributeTable.put(attribute.getType(), attribute); }
/** * Checks, if the given attribute is in this template. More precisely, it * returns true, if there is any attribute in this template for which * attribute.equals(otherAttribute) returns true. * * @param attribute * The attribute to look for. * @return True, if the attribute is in the template. False, otherwise. * @preconditions (attribute <> null) * @postconditions */ public boolean containsAttribute(Attribute attribute) { Util.requireNonNull("attribute", attribute); return attributeTable.containsKey(attribute.getType()); }
/** * Removes the given attribute from the template. More precisely, it removes * the attribute from the template which has the same type as the given * attribute. Notice that type in this context does not refer the the type * of data in the attribute's value. For instance, Attribute.SIGN is a type * of an attribute. * * @param attribute * The attribute to remove. * @return The removed attribute, if the attribute was in the template. * Null, otherwise. * @preconditions (attribute <> null) * @postconditions */ public Attribute removeAttribute(Attribute attribute) { Util.requireNonNull("attribute", attribute); return (Attribute) attributeTable.remove(attribute.getType()); }
/** * Adds all attributes of the given object which have their present flag set * to this generic template. * Notice that this method does not automatically clone the attributes. If * the application needs this, it must clone the argument object before. * * @param object * The object that holds the attributes to add to the template. * @preconditions (object <> null) * @postconditions */ public void addAllPresentAttributes(PKCS11Object object) { Util.requireNonNull("object", object); Enumeration<Attribute> attributeEnumaeration = object.attributeTable.elements(); while (attributeEnumaeration.hasMoreElements()) { Attribute attribute = attributeEnumaeration.nextElement(); if (attribute.isPresent()) { attributeTable.put(attribute.getType(), attribute); } } }