use of org.eclipse.wst.dtd.core.internal.emf.DTDBasicType in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method hasIDAttribute.
public boolean hasIDAttribute(DTDAttribute dtdattr) {
boolean hasID = false;
DTDElement element = dtdattr.getDTDElement();
EList attrs = element.getDTDAttribute();
Iterator i = attrs.iterator();
while (i.hasNext()) {
DTDAttribute attr = (DTDAttribute) i.next();
DTDType dType = attr.getDTDType();
if (dType instanceof DTDBasicType) {
if (((DTDBasicType) dType).getKind().getValue() == DTDBasicTypeKind.ID) {
hasID = true;
break;
}
}
}
return hasID;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDBasicType in project webtools.sourceediting by eclipse.
the class DTDAttributeImpl method unparse.
public String unparse() {
StringBuffer result = new StringBuffer(128);
result.append(getName());
StringBuffer value = new StringBuffer();
switch(getDefaultKind().getValue()) {
case DTDDefaultKind.IMPLIED:
// $NON-NLS-1$
value.append("#IMPLIED");
break;
case DTDDefaultKind.REQUIRED:
// $NON-NLS-1$
value.append("#REQUIRED");
break;
case DTDDefaultKind.FIXED:
String type = getDTDType().toString();
if (!(type.equals(DTDType.ID) || type.equals(DTDType.IDREF) || type.equals(DTDType.ENUM_NAME_TOKEN_GROUP) || type.equals(DTDType.IDREFS))) {
// $NON-NLS-1$ //$NON-NLS-2$
value.append("#FIXED \"").append(getDefaultValueString()).append("\"");
}
break;
case DTDDefaultKind.NOFIXED:
String defaultValue = getDefaultValueString();
if (defaultValue != null)
// $NON-NLS-1$ //$NON-NLS-2$
value.append("\"").append(defaultValue).append("\"");
break;
}
// Get the attribute type
DTDEntity typeEnt = getAttributeTypeReferencedEntity();
if (typeEnt != null) {
// $NON-NLS-1$ //$NON-NLS-2$
result.append(" %" + typeEnt.getName() + "; ").append(value);
} else {
DTDType dtdType = getDTDType();
if (dtdType instanceof DTDBasicType) {
switch(((DTDBasicType) dtdType).getKind().getValue()) {
case DTDBasicTypeKind.CDATA:
// $NON-NLS-1$
result.append(" CDATA ").append(value);
break;
case DTDBasicTypeKind.ID:
// $NON-NLS-1$
result.append(" ID ").append(value);
break;
case DTDBasicTypeKind.IDREF:
// $NON-NLS-1$
result.append(" IDREF ").append(value);
break;
case DTDBasicTypeKind.IDREFS:
// $NON-NLS-1$
result.append(" IDREFS ").append(value);
break;
case DTDBasicTypeKind.ENTITY:
// $NON-NLS-1$
result.append(" ENTITY ").append(value);
break;
case DTDBasicTypeKind.ENTITIES:
// $NON-NLS-1$
result.append(" ENTITIES ").append(value);
break;
case DTDBasicTypeKind.NMTOKEN:
// $NON-NLS-1$
result.append(" NMTOKEN ").append(value);
break;
case DTDBasicTypeKind.NMTOKENS:
// $NON-NLS-1$
result.append(" NMTOKENS ").append(value);
break;
}
} else if (dtdType instanceof DTDEnumerationType) {
// $NON-NLS-1$
result.append(" ").append(buildEnumString((DTDEnumerationType) dtdType)).append(value);
}
}
return result.toString();
}
Aggregations