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


Java Classifier.getAttribute方法代码示例

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


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

示例1: parseSimpleTraversal

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
private Property parseSimpleTraversal(Classifier sourceType, ASimpleAssociationTraversal node) {
    final String openEndName = TextUMLCore.getSourceMiner().getIdentifier(node.getIdentifier());
    Property openEnd = sourceType.getAttribute(openEndName, null);
    Association association;
    if (openEnd == null) {
        EList<Association> associations = sourceType.getAssociations();
        for (Association current : associations)
            if ((openEnd = current.getMemberEnd(openEndName, null)) != null)
                break;
        if (openEnd == null) {
            problemBuilder.addProblem(new UnknownRole(sourceType.getQualifiedName() + NamedElement.SEPARATOR
                    + openEndName), node.getIdentifier());
            throw new AbortedStatementCompilationException();
        }
    }
    association = openEnd.getAssociation();
    if (association == null) {
        problemBuilder.addError(openEndName + " is not an association member end", node.getIdentifier());
        throw new AbortedStatementCompilationException();
    }
    return openEnd;
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:23,代码来源:BehaviorGenerator.java

示例2: findProperty

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public static Property findProperty(Classifier classifier, String attributeIdentifier, boolean ignoreCase,
        boolean recurse, EClass propertyClass) {
    Property found = classifier.getAttribute(attributeIdentifier, null, ignoreCase, propertyClass);
    if (found != null || !recurse)
        return found;
    final EList<TemplateBinding> templateBindings = classifier.getTemplateBindings();
    if (!templateBindings.isEmpty()) {
        for (TemplateBinding templateBinding : templateBindings) {
            TemplateSignature signature = templateBinding.getSignature();
            found = findProperty((Classifier) signature.getTemplate(), attributeIdentifier, ignoreCase, true,
                    propertyClass);
            if (found != null)
                return found;
        }
    }
    for (Generalization generalization : classifier.getGeneralizations())
        if ((found = findProperty(generalization.getGeneral(), attributeIdentifier, ignoreCase, true, propertyClass)) != null)
            return found;
    return null;
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:21,代码来源:FeatureUtils.java

示例3: testBindingOfTemplateWithOperation

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public void testBindingOfTemplateWithOperation() throws CoreException {
    String model = "";
    model += "model test;\n";
    model += "class Zoo\n";
    model += "end;\n";
    model += "class Bar<T>\n";
    model += "  operation op1(a : T);\n";
    model += "end;\n";
    model += "class Foo\n";
    model += "  attribute boz : Bar<Zoo>;\n";
    model += "end;\n";
    model += "end.\n";
    parseAndCheck(model);
    Classifier zooClass = (Classifier) getRepository().findNamedElement("test::Zoo",
            IRepository.PACKAGE.getClassifier(), null);
    assertNotNull(zooClass);
    Classifier fooClass = (Classifier) getRepository().findNamedElement("test::Foo",
            IRepository.PACKAGE.getClassifier(), null);
    assertNotNull(fooClass);
    Property bozProperty = fooClass.getAttribute("boz", null);
    Classifier bozType = (Classifier) bozProperty.getType();
    assertNotNull(bozType);
    Operation boundOp1 = StructuralFeatureUtils.findOperation(getRepository(), bozType, "op1", null);
    assertNotNull(boundOp1);
    assertEquals("T", boundOp1.getOwnedParameter("a", null).getType().getName());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:TemplateTests.java

示例4: testTemplateBindingAsAttributeType

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public void testTemplateBindingAsAttributeType() throws CoreException {
    String model = "";
    model += "model test;\n";
    model += "class Zoo\n";
    model += "end;\n";
    model += "class Bar<T>\n";
    model += "end;\n";
    model += "class Foo\n";
    model += "  attribute attr1 : Bar<Zoo>;\n";
    model += "end;\n";
    model += "end.\n";
    parseAndCheck(model);
    Classifier fooType = (Classifier) getRepository().findNamedElement("test::Foo",
            IRepository.PACKAGE.getClassifier(), null);
    Property fooAttr1 = fooType.getAttribute("attr1", null);
    assertNotNull(fooAttr1);
    checkTemplateBinding((Classifier) fooAttr1.getType(), "test::Bar", "test::Zoo");
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:19,代码来源:TemplateTests.java

示例5: testTemplateDeclarationWithAttribute

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public void testTemplateDeclarationWithAttribute() throws CoreException {
    String model = "";
    model += "model test;\n";
    model += "class Bar<T>\n";
    model += "attribute attr1 : T;\n";
    model += "end;\n";
    model += "end.\n";
    parseAndCheck(model);
    Classifier barClass = (Classifier) getRepository().findNamedElement("test::Bar",
            IRepository.PACKAGE.getClassifier(), null);
    Classifier parameterType = (Classifier) barClass.getOwnedTemplateSignature().getParameters().get(0)
            .getParameteredElement();
    assertNotNull(parameterType);
    Property attribute = barClass.getAttribute("attr1", null);
    assertNotNull(attribute);
    assertSame(parameterType, attribute.getType());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:18,代码来源:TemplateTests.java

示例6: testAttributes

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
private void testAttributes(String classifierKeyword, EClass metaClass) throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "$classifier SomeClassifier\n";
    source += "attribute attrib1 : Integer;\n";
    source += "public attribute attrib2 : Integer;\n";
    source += "private attribute attrib3 : Integer;\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source.replace("$classifier", classifierKeyword));

    Type integerType = (Type) getRepository()
            .findNamedElement("base::Integer", IRepository.PACKAGE.getType(), null);
    assertNotNull(integerType);

    Classifier classifier = (Classifier) getRepository().findNamedElement("someModel::SomeClassifier", metaClass,
            null);
    assertNotNull(classifier);
    Property property = classifier.getAttribute("attrib1", integerType);
    assertNotNull(property);
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:23,代码来源:ClassifierTests.java

示例7: property

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
protected Property property(Classifier cls, String name, String typeName) {
	Property attribute = cls.getAttribute(name, null);
	assertNotNull(attribute);
	assertEquals(typeName, attribute.getType().getName());
	assertEquals(1, attribute.getLower());
	assertEquals(1, attribute.getUpper());
	assertEquals(true, attribute.isNavigable());
	return attribute;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:10,代码来源:UMLExportTestBase.java

示例8: testDerivedAttribute

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public void testDerivedAttribute() throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "class SomeClassifier\n";
    source += "attribute attrib1 : Integer;\n";
    source += "derived attribute attrib2 : Integer := { self.attrib1 * 2 };\n";
    source += "derived attribute attrib3 : Boolean := { self.attrib1 > 0 };\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);

    Type integerType = (Type) getRepository()
            .findNamedElement("base::Integer", IRepository.PACKAGE.getType(), null);
    assertNotNull(integerType);

    Classifier classifier = (Classifier) getRepository().findNamedElement("someModel::SomeClassifier",
            Literals.CLASS, null);

    Property attr1 = classifier.getAttribute("attrib1", null);
    assertFalse(attr1.isDerived());

    Property attr2 = classifier.getAttribute("attrib2", null);
    assertTrue(attr2.isDerived());

    Property attr3 = classifier.getAttribute("attrib3", null);
    assertTrue(attr3.isDerived());

    assertNotNull(attr2.getDefaultValue());
    assertTrue(ActivityUtils.isBehaviorReference(attr2.getDefaultValue()));

    assertNotNull(attr3.getDefaultValue());
    assertTrue(ActivityUtils.isBehaviorReference(attr3.getDefaultValue()));
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:35,代码来源:ClassifierTests.java

示例9: testAttributeInitialization

import org.eclipse.uml2.uml.Classifier; //导入方法依赖的package包/类
public void testAttributeInitialization() throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "enumeration MyEnum literal VALUE1; literal VALUE2; literal VALUE3; end;\n";
    source += "class SomeClassifier\n";
    source += "attribute attrib1 : Integer := 10;\n";
    source += "attribute attrib2 : Boolean := true;\n";
    source += "attribute attrib3 : String := \"foo\";\n";
    source += "attribute attrib4 : MyEnum := VALUE2;\n";
    source += "attribute attrib5 : Date := { Date#today() };\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);

    Type integerType = (Type) getRepository()
            .findNamedElement("base::Integer", IRepository.PACKAGE.getType(), null);
    assertNotNull(integerType);

    Classifier classifier = (Classifier) getRepository().findNamedElement("someModel::SomeClassifier",
            Literals.CLASS, null);

    Property attr1 = classifier.getAttribute("attrib1", null);
    ValueSpecification attr1DefaultValue = attr1.getDefaultValue();
    assertNotNull(attr1DefaultValue);
    assertTrue(MDDExtensionUtils.isBasicValue(attr1DefaultValue));
    assertEquals(10L, MDDExtensionUtils.getBasicValue(attr1DefaultValue));

    Property attr2 = classifier.getAttribute("attrib2", null);
    ValueSpecification attr2DefaultValue = attr2.getDefaultValue();
    assertNotNull(attr2DefaultValue);
    assertTrue(MDDExtensionUtils.isBasicValue(attr2DefaultValue));
    assertEquals(true, MDDExtensionUtils.getBasicValue(attr2DefaultValue));

    Property attr3 = classifier.getAttribute("attrib3", null);
    ValueSpecification attr3DefaultValue = attr3.getDefaultValue();
    assertNotNull(attr3DefaultValue);
    assertTrue(attr3DefaultValue instanceof LiteralString);
    assertEquals("foo", MDDExtensionUtils.getBasicValue(attr3DefaultValue));

    Property attr4 = classifier.getAttribute("attrib4", null);
    ValueSpecification attr4DefaultValue = attr4.getDefaultValue();
    assertNotNull(attr4DefaultValue);
    assertTrue(attr4DefaultValue instanceof InstanceValue);
    assertTrue(((InstanceValue) attr4DefaultValue).getInstance() instanceof EnumerationLiteral);
    assertEquals("VALUE2", ((EnumerationLiteral) ((InstanceValue) attr4DefaultValue).getInstance()).getName());

    Property attr5 = classifier.getAttribute("attrib5", null);
    ValueSpecification attr5DefaultValue = attr5.getDefaultValue();
    assertNotNull(attr5DefaultValue);
    assertTrue(ActivityUtils.isBehaviorReference(attr5DefaultValue));
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:53,代码来源:ClassifierTests.java


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