コード例 #1
0
 /**
  * Get the attribute array value of this attribute. Null, is also possible.
  *
  * @return The attribute array value of this attribute or null.
  * @preconditions
  * @postconditions
  */
 public GenericTemplate getAttributeArrayValue() {
   if (template_ == null) {
     if (ckAttribute_.pValue != null && ((CK_ATTRIBUTE[]) ckAttribute_.pValue).length > 0) {
       CK_ATTRIBUTE[] attributesArray = (CK_ATTRIBUTE[]) ckAttribute_.pValue;
       GenericTemplate template = new GenericTemplate();
       for (int i = 0; i < attributesArray.length; i++) {
         Long type = new Long(attributesArray[i].type);
         Class implementation = (Class) Attribute.getAttributeClass(type);
         Attribute attribute;
         if (implementation == null) {
           attribute = new Attribute(type);
           attribute.setCkAttribute(attributesArray[i]);
         } else {
           try {
             attribute = (Attribute) implementation.newInstance();
             attribute.setCkAttribute(attributesArray[i]);
             attribute.setPresent(true);
             template.addAttribute(attribute);
           } catch (Exception ex) {
             System.err.println(
                 "Error when trying to create a "
                     + implementation
                     + " instance for "
                     + type
                     + ": "
                     + ex.getMessage());
             System.err.flush();
             System.exit(1);
           }
         }
       }
       return template;
     } else {
       return null;
     }
   } else {
     return template_;
   }
 }