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


Java Classifier.getAttributes方法代码示例

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


在下文中一共展示了Classifier.getAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClassNode

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
/**
 * Creates a ClassNode based on the EMF-UML model-element and layout
 * information provided
 * 
 * 
 * @param clazz
 *            the EMF-UML model-element which holds informations of this
 *            diagram element
 * @param id
 *            the layout id of this element
 */
public ClassNode(Classifier clazz, String id) {
	/*
	 * position = layout.getPosition(); width = layout.getWidth(); height =
	 * layout.getHeight(); id = layout.getName();
	 */
	this.id = id;
	name = clazz.getName();
	attributes = new ArrayList<Attribute>();
	// creating attributes
	for (Property attr : clazz.getAttributes()) {
		if (attr.getAssociation() == null) {
			attributes.add(new Attribute(attr));
		}
	}

	operations = new ArrayList<MemberOperation>();
	// creating operations
	for (Operation op : clazz.getOperations()) {
		operations.add(new MemberOperation(op));
	}

	if (clazz.isAbstract()) {
		type = CDNodeType.ABSTRACT_CLASS;
	} else {
		type = CDNodeType.CLASS;
	}
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:39,代码来源:ClassNode.java

示例2: createPropertiesDefinition

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public static String createPropertiesDefinition(Classifier classifier) throws Exception {		
	EPackage _package = EcoreFactory.eINSTANCE.createEPackage();
	EClass propertyDefinition = EcoreFactory.eINSTANCE.createEClass();
	GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
	ExtendedMetaData extendedMetaData = genModel.getExtendedMetaData();
	
	List<EStructuralFeature> features = new ArrayList<EStructuralFeature>();
	String propertiesDefinition = "";
	
	for(Property property : classifier.getAttributes()) {
		// consider attributes only if they aren't members of an association
		if(property.getAssociation() == null) {
			EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
			attribute.setName(property.getName());
			attribute.setUnsettable(true);
			
			// create an EEnum in case of enumeration
			if(property.getType() instanceof Enumeration) {
				Enumeration enumeration = (Enumeration) property.getType(); 
				EEnum eenumeration = EcoreFactory.eINSTANCE.createEEnum();
				eenumeration.setName(enumeration.getName());
				
				int literalValue = 0;
				for(EnumerationLiteral literal : enumeration.getOwnedLiterals()) {
					EEnumLiteral eliteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
					eliteral.setName(literal.getName());
					eliteral.setValue(literalValue);
					literalValue++;
					eenumeration.getELiterals().add(eliteral);
				}
				
				_package.getEClassifiers().add(eenumeration);
				attribute.setEType(eenumeration);
			}
			else {
				attribute.setEType(XMLTypePackage.eINSTANCE.getString());
			}
			propertyDefinition.getEStructuralFeatures().add(attribute);
			extendedMetaData.setFeatureKind(attribute, ExtendedMetaData.ELEMENT_FEATURE);
			features.add(attribute);
		}
	}
	
	if(!features.isEmpty()) {
		// first step: create an Ecore metamodel		
		URI uri = URI.createFileURI(new File(Path + classifier.getName() + Ecore_Model_Fragment).getAbsolutePath());
		Resource resource = Resource_Set.createResource(uri);

		_package.setName(classifier.getName() + "Properties");
		_package.setNsPrefix(classifier.getName() + "Properties");
		_package.setNsURI("http://" + classifier.getName() + "Properties");
		resource.getContents().add(_package);
		propertyDefinition.setName("Properties");
		_package.getEClassifiers().add(propertyDefinition);
		
		// second step: derive the GenModel from the metamodel
		genModel.setComplianceLevel(GenJDKLevel.JDK70_LITERAL);		 
		genModel.setModelDirectory("");
		genModel.setModelName(_package.getName());
		genModel.initialize(Collections.singleton(_package));
			
		// third step: export the XSD from the GenModel			
		XSDExporter modelExporter = new XSDExporter();
		modelExporter.setGenModel(genModel);
		modelExporter.getEPackages().add(_package);
		EPackageConvertInfo convertInfo = modelExporter.getEPackageConvertInfo(_package);
		convertInfo.setConvert(true);
		EPackageExportInfo exportInfo = modelExporter.getEPackageExportInfo(_package);
		exportInfo.setArtifactLocation(Path + classifier.getName() + Xsd_Model_Fragment);
		modelExporter.export(null); 
		
		// the name of the properties definition; it allows node types to reference it
		propertiesDefinition = classifier.getName() + "Properties";
	}
	return propertiesDefinition;
}
 
开发者ID:alexander-bergmayr,项目名称:caml2tosca,代码行数:77,代码来源:ToscaUtil.java

示例3: createAttributeDataModelList

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
/**
 * 1) Attribute 데이터 모델 리스트를 생성합니다.
 * 
 * @param cls
 * @return List<DataModel>
 */
public List<DataModel> createAttributeDataModelList(Classifier cls) {
    List<DataModel> attributeModelList = new ArrayList<DataModel>();
    DataModel attributeModel;
    String qualifiedTypeName = UICoreConstant.EMPTY_STRING;

    if (!cls.getAttributes().isEmpty()) {
        for (Property property : cls.getAttributes()) {
            attributeModel = new DataModel();

            setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_NAME, property.getName());
            setDataModel(attributeModel,
                UICoreConstant.REPORT__ATTRIBUTE_DOCUMENTATION,
                getCommentToString(property.getOwnedComments()));
            setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_VISIBILITY, property.getVisibility()
                .toString());

            if (property.getType() != null) {
                StringBuffer stringBuffer = new StringBuffer();

                boolean isPrimitives = false;
                qualifiedTypeName = property.getType().getQualifiedName();
                if (null != qualifiedTypeName) {
                    for (int i = 0; i < UICoreConstant.PROJECT_CONSTANTS__CORE_LIBRARY_NAMES.length; i++) {
                        if (qualifiedTypeName.startsWith(UICoreConstant.PROJECT_CONSTANTS__CORE_LIBRARY_NAMES[i])) {
                            isPrimitives = true;
                            stringBuffer.append(property.getType().getName());
                            break;
                        }
                    }
                    if (!isPrimitives) {
                        // stringBuffer.append(UICoreConstant.REPORT__OPEN_PARENTHESIS);
                        stringBuffer.append(MDDCommonUtil.getMappedName(qualifiedTypeName));
                        // stringBuffer.append(UICoreConstant.REPORT__CLOSE_PARENTHESIS);
                    }
                    setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_TYPE, stringBuffer.toString());
                } else {
                    setDataModel(attributeModel,
                        UICoreConstant.REPORT__ATTRIBUTE_TYPE,
                        UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING);
                }
            } else {
                setDataModel(attributeModel,
                    UICoreConstant.REPORT__ATTRIBUTE_TYPE,
                    UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING);
            }

            setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_DEFAULT_VALUE, property.getDefault());

            attributeModelList.add(attributeModel);
        }
    }
    // else {
    // attributeModel = new DataModel();
    // setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_NAME,
    // UMLMessage.LABEL_NO_APPLICABLE);
    //           
    // attributeModelList.add(attributeModel);
    // }

    return attributeModelList;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:68,代码来源:UsecaseRealizationContentManager.java

示例4: createAttributeDataModelList

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
/**
 * 
 * 
 * @param objClassifier
 * @return Object
 */
private Object createAttributeDataModelList(Classifier objClassifier) {
    List<DataModel> attributeModelList = new ArrayList<DataModel>();
    DataModel attributeModel;
    String qualifiedTypeName = UICoreConstant.EMPTY_STRING;

    if (!objClassifier.getAttributes().isEmpty()) {
        for (Property property : objClassifier.getAttributes()) {
            attributeModel = new DataModel();

            setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_NAME, property.getName());
            setDataModel(attributeModel,
                UICoreConstant.REPORT__ATTRIBUTE_DOCUMENTATION,
                applyPreference(getCommentToString(property.getOwnedComments())));
            setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_VISIBILITY, property.getVisibility()
                .toString());

            if (property.getType() != null) {
                StringBuffer stringBuffer = new StringBuffer();

                boolean isPrimitives = false;
                qualifiedTypeName = property.getType().getQualifiedName();
                if (null == qualifiedTypeName) {
                    stringBuffer.append(UICoreConstant.EMPTY_STRING);
                } else {
                    for (int i = 0; i < UICoreConstant.PROJECT_CONSTANTS__CORE_LIBRARY_NAMES.length; i++) {
                        if (qualifiedTypeName.startsWith(UICoreConstant.PROJECT_CONSTANTS__CORE_LIBRARY_NAMES[i])) {
                            isPrimitives = true;
                            stringBuffer.append(property.getType().getName());
                            break;
                        }
                    }
                    if (!isPrimitives) {
                        // stringBuffer.append(UICoreConstant.REPORT__OPEN_PARENTHESIS);
                        stringBuffer.append(MDDCommonUtil.getMappedName(qualifiedTypeName));
                        // stringBuffer.append(UICoreConstant.REPORT__CLOSE_PARENTHESIS);
                    }
                }
                setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_TYPE, stringBuffer.toString());
            } else {
                setDataModel(attributeModel,
                    UICoreConstant.REPORT__ATTRIBUTE_TYPE,
                    UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING);
            }

            // 속성의 초기값이 없으면 'N/A' 출력
            String defaultValue = property.getDefault();
            if (defaultValue == null) {
                defaultValue = UICoreConstant.EMPTY_STRING;
            } else {
                defaultValue = defaultValue.trim();
            }
            setDataModel(attributeModel,
                UICoreConstant.REPORT__ATTRIBUTE_DEFAULT_VALUE,
                applyPreferenceNA(defaultValue));

            attributeModelList.add(attributeModel);
        }
    }
    // else {
    // attributeModel = new DataModel();
    // setDataModel(attributeModel, UICoreConstant.REPORT__ATTRIBUTE_NAME,
    // UMLMessage.LABEL_NO_APPLICABLE);
    //           
    // attributeModelList.add(attributeModel);
    // }

    return attributeModelList;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:75,代码来源:ClassifierContentManager.java


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