当前位置: 首页>>代码示例>>Java>>正文


Java EAttribute.setEType方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.EAttribute.setEType方法的典型用法代码示例。如果您正苦于以下问题:Java EAttribute.setEType方法的具体用法?Java EAttribute.setEType怎么用?Java EAttribute.setEType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.EAttribute的用法示例。


在下文中一共展示了EAttribute.setEType方法的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());
				
			}
		}
	}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:52,代码来源:OCCIExtension2Ecore.java

示例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;
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:45,代码来源:OCCIExtension2Ecore.java


注:本文中的org.eclipse.emf.ecore.EAttribute.setEType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。