Пример #1
0
 /**
  * Get a string representation of the value of this attribute.
  *
  * @return A string representation of the value of this attribute.
  * @preconditions
  * @postconditions (result <> null)
  */
 protected String getValueString() {
   String valueString = "";
   if (template_ == null) template_ = getAttributeArrayValue();
   if (template_ == null) {
     valueString = "<NULL_PTR>";
   } else {
     String indent = Constants.INDENT + Constants.INDENT + Constants.INDENT;
     valueString += template_.toString(true, true, indent);
   }
   return valueString;
 }
Пример #2
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_;
   }
 }
Пример #3
0
 /**
  * The overriding of this method should ensure that the objects of this class work correctly in a
  * hashtable.
  *
  * @return The hash code of this object.
  * @preconditions
  * @postconditions
  */
 public int hashCode() {
   if (template_ == null) template_ = getAttributeArrayValue();
   return template_.hashCode();
 }