本文整理匯總了Java中org.eclipse.emf.ecore.EAttribute.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java EAttribute.setName方法的具體用法?Java EAttribute.setName怎麽用?Java EAttribute.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EAttribute
的用法示例。
在下文中一共展示了EAttribute.setName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: completeRecordTypeFeatures
import org.eclipse.emf.ecore.EAttribute; //導入方法依賴的package包/類
private void completeRecordTypeFeatures(RecordType recordType, EClass type) {
for (RecordField rf : recordType.getRecordFields()) {
// if the type of the recordField is different to arraytype or a recordtype
// it will be translated into a EMF attribute
if (!(rf.getType() instanceof RecordType || rf.getType() instanceof ArrayType)) {
EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
type.getEStructuralFeatures().add(attribute);
attribute.setName(rf.getName());
attribute.setLowerBound(1);
attribute.setEType(getMappedType(rf.getType()));
// Set the default value of the Ecore attribute.
String defaultValue = rf.getDefault();
if (defaultValue != null && !defaultValue.isEmpty()) {
attribute.setDefaultValue(defaultValue);
}
// The Ecore attribute is required when the OCCI attribute is required.
if (attribute.isRequired()) {
attribute.setLowerBound(1);
}
attachInfo(attribute, rf.getDescription());
} else {
// otherwise, il will be translated into an EMF reference
EReference reference = EcoreFactory.eINSTANCE.createEReference();
type.getEStructuralFeatures().add(reference);
reference.setName(rf.getName());
// The Ecore attribute is required when the OCCI attribute is required.
if (rf.isRequired()) {
reference.setLowerBound(1);
}
reference.setUpperBound(1);
reference.setEType(getMappedType(rf.getType()));
reference.setContainment(true);
// Set the default value of the Ecore attribute.
// Default values for EMF EReference is not supported
// see https://www.eclipse.org/forums/index.php?t=msg&th=131049&goto=406266&#msg_406266
// String defaultValue = rf.getDefault();
// if (defaultValue != null && !defaultValue.isEmpty()) {
// reference.setDefaultValue(defaultValue);
// }
attachInfo(reference, rf.getDescription());
}
}
}
示例2: convertAttribute
import org.eclipse.emf.ecore.EAttribute; //導入方法依賴的package包/類
/**
* Convert an OCCI attribute to an Ecore attribute.
*
* @param attribute
* the OCCI attribute to convert.
* @return the resulting Ecore attribute.
*/
protected EStructuralFeature convertAttribute(Attribute attribute) {
if(attribute.getType() instanceof BasicType || attribute.getType() instanceof EnumerationType) {
// Create an Ecore attribute.
EAttribute eAttr = EcoreFactory.eINSTANCE.createEAttribute();
// Set the name of the Ecore attribute.
eAttr.setName(Occi2Ecore.convertOcciAttributeName2EcoreAttributeName(attribute.getName()));
// Set the type of the Ecore attribute.
eAttr.setEType(getMappedType(attribute.getType()));
// Set the default value of the Ecore attribute.
String defaultValue = attribute.getDefault();
if (defaultValue != null && !defaultValue.isEmpty()) {
eAttr.setDefaultValue(defaultValue);
}
// The Ecore attribute is required when the OCCI attribute is required.
if (attribute.isRequired()) {
eAttr.setLowerBound(1);
}
attachInfo(eAttr, attribute.getDescription());
return eAttr;
}
else {
// Create an Ecore reference.
EReference eRef = EcoreFactory.eINSTANCE.createEReference();
// Set the name of the Ecore reference.
eRef.setName(Occi2Ecore.convertOcciAttributeName2EcoreAttributeName(attribute.getName()));
// Set the type of the Ecore reference.
eRef.setEType(getMappedType(attribute.getType()));
// Set the containment of the Ecore reference to true.
eRef.setContainment(true);
// The Ecore reference is required when the OCCI attribute is required.
if (attribute.isRequired()) {
eRef.setLowerBound(1);
}
attachInfo(eRef, attribute.getDescription());
return eRef;
}
}