public String getName() {
   String result = null;
   switch (kind) {
     case KIND_ATTR_TEXT:
       {
         result = "value";
         break;
       }
     case KIND_ELEMENT_ATTR:
       {
         result = attribute.getName();
         break;
       }
     case KIND_ELEMENT_CMATTRIBUTE:
       {
         CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode;
         result = ad.getNodeName();
         break;
       }
     case KIND_ELEMENT_TEXT:
       {
         result = "text value";
         break;
       }
   }
   return result != null ? result : "";
 }
 private boolean isBooleanAttr(Attr attr) {
   if (attr == null) return false;
   CMAttributeDeclaration decl = CMNodeUtil.getAttributeDeclaration(attr);
   if (decl == null) return false;
   CMDataType type = decl.getAttrType();
   if (type == null) return false;
   String values[] = type.getEnumeratedValues();
   if (values == null) return false;
   return (values.length == 1 && values[0].equals(decl.getAttrName()));
 }
 public Command getUpdateValueCommand(String newValue) {
   switch (kind) {
     case KIND_ATTR_TEXT:
     case KIND_ELEMENT_ATTR:
       {
         // note intentional fall-thru!!
         return new UpdateAttributeValueCommand(parent, attribute.getNodeName(), newValue, true);
       }
     case KIND_ELEMENT_CMATTRIBUTE:
       {
         final CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode;
         return new UpdateAttributeValueCommand(parent, ad.getAttrName(), newValue, true);
       }
     case KIND_ELEMENT_TEXT:
       {
         return new UpdateTextValueCommand(parent, newValue);
       }
   }
   return null;
 }
 public void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer) {
   if ((attrDecl == null) || (buffer == null)) {
     return;
   }
   int usage = attrDecl.getUsage();
   if (usage == CMAttributeDeclaration.REQUIRED) {
     buffer.append(" "); // $NON-NLS-1$
     generateRequiredAttribute(null, attrDecl, buffer); // todo pass
     // ownerNode as
     // 1st param
   }
   return;
 }
  public void generateRequiredAttribute(
      Node ownerNode, CMAttributeDeclaration attrDecl, StringBuffer buffer) {
    if ((attrDecl == null) || (buffer == null)) {
      return;
    }

    // attribute name
    String attributeName = getRequiredName(ownerNode, attrDecl);
    CMDataType attrType = attrDecl.getAttrType();
    String defaultValue = null;
    // = sign
    buffer.append(attributeName + "="); // $NON-NLS-1$
    // attribute value
    if (attrType != null) {
      // insert any value that is implied
      if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE)
          && (attrType.getImpliedValue() != null)) {
        defaultValue = attrType.getImpliedValue();
      }
      // otherwise, if an enumerated list of values exists, use the
      // first value
      else if ((attrType.getEnumeratedValues() != null)
          && (attrType.getEnumeratedValues().length > 0)) {
        defaultValue = attrType.getEnumeratedValues()[0];
      }
    }

    char attrQuote = '\"';
    // Found a double quote, wrap the attribute in single quotes
    if (defaultValue != null && defaultValue.indexOf(attrQuote) >= 0) {
      attrQuote = '\'';
    }

    buffer.append(attrQuote);
    buffer.append(((defaultValue != null) ? defaultValue : "")); // $NON-NLS-1$
    buffer.append(attrQuote);
    return;
  }