use of org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method createDTDEnumeration.
private DTDEnumerationType createDTDEnumeration(DTDAttribute dtdattr, AttNode attdef, int enumKind) {
DTDEnumerationType enumeration = getFactory().createDTDEnumerationType();
DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
enumeration.setKind(groupKind);
dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enumeration);
// Enumeration values
Enumeration tokenIter = attdef.elements();
if (tokenIter != null) {
while (tokenIter.hasMoreElements()) {
String val = (String) tokenIter.nextElement();
EEnumLiteral enumLiteral = createEEnumLiteral();
// enumLiteral.setXMIDocument(dtdattr.getXMIDocument());
// MOF2EMF Port
// enumLiteral.refSetLiteral(val);
enumLiteral.setName(val);
// enumLiteral.setNumber(i++);
enumeration.getEnumLiterals().add(enumLiteral);
}
}
return enumeration;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType 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();
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType in project webtools.sourceediting by eclipse.
the class DTDAttributeImpl method getEnumeratedValues.
public Collection getEnumeratedValues() {
Collection result = new ArrayList();
DTDType type = getDTDType();
if (type instanceof DTDEnumerationType) {
DTDEnumerationType enumType = (DTDEnumerationType) type;
Iterator i = enumType.getEnumLiterals().iterator();
while (i.hasNext()) {
result.add(((EEnumLiteral) i.next()).toString());
}
}
return result;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType in project webtools.sourceediting by eclipse.
the class DTDAttributeImpl method createDTDEnumeration.
public DTDEnumerationType createDTDEnumeration(String[] enumValues, int enumKind) {
DTDEnumerationType enumeration = DTDFactoryImpl.instance().createDTDEnumerationType();
// enum.setID("Enum_" + ((DTDElement)getMOFDomain()).getName() + "_" +
// getName());
DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
enumeration.setKind(groupKind);
// Enumeration values
if (enumValues != null) {
for (int i = 0; i < enumValues.length; i++) {
EcorePackage ePackage = (EcorePackage) EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);
EEnumLiteral enumLiteral = ((EcoreFactory) ePackage.getEFactoryInstance()).createEEnumLiteral();
// MOF2EMF Port
// enumLiteral.refSetLiteral(enumValues[i]);
enumLiteral.setName(enumValues[i]);
// MOF2EMF Port
// enumLiteral.refSetLiteral(i);
enumLiteral.setValue(i);
enumeration.getEnumLiterals().add(enumLiteral);
}
}
getDTDElement().getDTDFile().getDTDEnumerationType().add(enumeration);
return enumeration;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method createDTDEnumeration.
public DTDEnumerationType createDTDEnumeration(DTDAttribute dtdattr, String[] enumValues, int enumKind) {
DTDEnumerationType enumeration = getFactory().createDTDEnumerationType();
DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
enumeration.setKind(groupKind);
// Enumeration values
if (enumValues != null) {
for (int i = 0; i < enumValues.length; i++) {
EEnumLiteral enumLiteral = createEEnumLiteral();
// enumVal.setXMIDocument(dtdattr.getXMIDocument());
// MOF2EMF Port
// enumLiteral.refSetLiteral(enumValues[i]);
enumLiteral.setName(enumValues[i]);
// enumLiteral.setNumber(i);
enumeration.getEnumLiterals().add(enumLiteral);
}
}
dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enumeration);
return enumeration;
}
Aggregations