use of org.eclipse.wst.dtd.core.internal.emf.DTDDefaultKind in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method finishAttribute.
// Stuff for populating attribute
public void finishAttribute(DTDAttribute dtdattr, AttNode attdef) {
boolean parseError = false;
if (attdef.name.startsWith("%")) {
// $NON-NLS-1$
String peName = attdef.name.trim();
DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
if (en != null) {
dtdattr.setAttributeNameReferencedEntity(en);
}
}
dtdattr.setName(attdef.name);
int attrType = attdef.getDeclaredType();
if (attrType == AttNode.PEREFERENCE && attdef.type != null) {
String peName = attdef.type.trim();
DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
if (en != null) {
dtdattr.setAttributeTypeReferencedEntity(en);
// hack,
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
// so
// we
// can
// get
// back
// the
// default
// value
} else
// set default type
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
} else {
switch(attrType) {
case AttNode.CDATA:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
break;
case AttNode.ENTITIES:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITIES());
break;
case AttNode.ENTITY:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITY());
break;
case AttNode.ID:
// check for duplicate ID attribute
if (hasIDAttribute(dtdattr)) {
/*String errMsg = DTDCoreMessages._ERROR_DUP_ID_ATTRIBUTE_1; //$NON-NLS-1$
errMsg += attdef.name + DTDCoreMessages._UI_ERRORPART_DUP_ID_ATTRIBUTE_2; //$NON-NLS-1$*/
// dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
// dtdattr.getDTDElement().getDTDFile().setParseError(true);
parseError = true;
}
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ID());
break;
case AttNode.IDREF:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREF());
break;
case AttNode.IDREFS:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREFS());
break;
case AttNode.ENUMERATION:
setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NAME_TOKEN_GROUP));
break;
case AttNode.NOTATION:
setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NOTATION_GROUP));
break;
case AttNode.NMTOKEN:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKEN());
break;
case AttNode.NMTOKENS:
setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKENS());
break;
default:
}
}
int attrDefault = attdef.getDefaultType();
int defaultKind = DTDDefaultKind.IMPLIED;
switch(attrDefault) {
case AttNode.FIXED:
defaultKind = DTDDefaultKind.FIXED;
break;
case AttNode.IMPLIED:
defaultKind = DTDDefaultKind.IMPLIED;
break;
case AttNode.REQUIRED:
defaultKind = DTDDefaultKind.REQUIRED;
break;
case AttNode.NOFIXED:
defaultKind = DTDDefaultKind.NOFIXED;
break;
default:
}
DTDDefaultKind defaultKindObj = DTDDefaultKind.get(defaultKind);
dtdattr.setDefaultKind(defaultKindObj);
if (parseError) {
return;
}
String defaultValue = attdef.defaultValue;
if (defaultValue != null) {
if (attrType == AttNode.ENUMERATION || attrType == AttNode.NOTATION) {
if (!isDefaultEnumValueValid(attdef, defaultValue)) {
// dtdattr.getDTDElement().getDTDFile().setParseError(true);
return;
}
}
dtdattr.setDefaultValueString(defaultValue);
}
// System.out.println("DTDAttr - toMof getDefaultValueString " +
// getDefaultValueString());
// System.out.println("DTDAttr - toMof getDefaultValue: " +
// getDefaultValue());
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDDefaultKind in project webtools.sourceediting by eclipse.
the class DTDAttributeImpl method setDefaultKind.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setDefaultKind(DTDDefaultKind newDefaultKind) {
DTDDefaultKind oldDefaultKind = defaultKind;
defaultKind = newDefaultKind == null ? DEFAULT_KIND_EDEFAULT : newDefaultKind;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DTDPackage.DTD_ATTRIBUTE__DEFAULT_KIND, oldDefaultKind, defaultKind));
}
Aggregations