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


Java Class.getAttribute方法代码示例

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


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

示例1: testFrom0To1

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom0To1() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[0,1];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(0, attr1.getLower());
    assertEquals(1, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(0, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(1, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例2: testFrom1To1ShortForm

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom1To1ShortForm() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[1];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(1, attr1.getLower());
    assertEquals(1, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(1, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(1, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例3: testFrom0ToUnlimitedShortForm

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom0ToUnlimitedShortForm() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[*];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(0, attr1.getLower());
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(0, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例4: testFrom1To1

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom1To1() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[1,1];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(1, attr1.getLower());
    assertEquals(1, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(1, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(1, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例5: testFrom1ToUnlimited

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom1ToUnlimited() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[1,*];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(1, attr1.getLower());
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(1, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例6: testFrom0ToUnlimited

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testFrom0ToUnlimited() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "import base;\n";
    source += "class Class1\n";
    source += "  attribute attr1 : Integer[0,*];\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", UMLPackage.Literals.CLASS, null);
    assertNotNull(class1);
    Property attr1 = class1.getAttribute("attr1", null);
    assertNotNull(attr1);
    assertEquals(0, attr1.getLower());
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, attr1.getUpper());

    ValueSpecification lowerValue = attr1.getLowerValue();
    assertNotNull(lowerValue);
    assertTrue(lowerValue instanceof LiteralInteger);
    assertEquals(0, lowerValue.integerValue());

    ValueSpecification upperValue = attr1.getUpperValue();
    assertNotNull(upperValue);
    assertTrue(upperValue instanceof LiteralUnlimitedNatural);
    assertEquals(LiteralUnlimitedNatural.UNLIMITED, ((LiteralUnlimitedNatural) upperValue).unlimitedValue());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:27,代码来源:MultiplicityTests.java

示例7: testClashBetweenImportedAndLocal

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testClashBetweenImportedAndLocal() throws CoreException {
    String sourcePackage = "";
    sourcePackage += "package somePackage;\n";
    sourcePackage += "class Expression\n";
    sourcePackage += "end;\n";
    sourcePackage += "class Foo\n";
    sourcePackage += "attribute attr1 : Expression;\n";
    sourcePackage += "end;\n";
    sourcePackage += "end.";
    parseAndCheck(sourcePackage);
    Class localExpressionClass = getRepository().findNamedElement("somePackage::Expression",
            UMLPackage.Literals.CLASS, null);
    assertEquals("somePackage::Expression", localExpressionClass.getQualifiedName());
    Class fooClass = getRepository().findNamedElement("somePackage::Foo", UMLPackage.Literals.CLASS, null);
    Class umlExpressionClass = getRepository().findNamedElement("UML::Expression", UMLPackage.Literals.CLASS, null);
    assertNotNull(localExpressionClass);
    assertNotNull(fooClass);
    assertNotNull(umlExpressionClass);
    Property attribute = fooClass.getAttribute("attr1", null);
    assertEquals(localExpressionClass.getQualifiedName(), attribute.getType().getQualifiedName());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:22,代码来源:PackageTests.java

示例8: testDerivedReference

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testDerivedReference() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "class Class1\n";
    source += "  reference myClass2a : Class2[*];\n";
    source += "  reference myClass2b : Class2[*];\n";
    source += "  derived attribute allMyClass2 : Class2[*] := { self.myClass2a.union(self.myClass2b) };\n";
    source += "end;\n";
    source += "class Class2\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class1 = getRepository().findNamedElement("simple::Class1", IRepository.PACKAGE.getClass_(), null);
    Class class2 = getRepository().findNamedElement("simple::Class2", IRepository.PACKAGE.getClass_(), null);
    assertNotNull(class1);
    assertNotNull(class2);
    Property derived = class1.getAttribute("allMyClass2", class2);
    assertTrue(derived.isDerived());
    assertTrue(derived.isMultivalued());
    assertNull(derived.getAssociation());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:22,代码来源:AssociationTests.java

示例9: testAttributeStereotypeApplication

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testAttributeStereotypeApplication() throws CoreException {
    String profileSource = "";
    profileSource += "profile someProfile;\n";
    profileSource += "stereotype my_stereotype extends UML::Property end;\n";
    profileSource += "end.\n";

    String modelSource = "";
    modelSource += "model someModel;\n";
    modelSource += "import base;\n";
    modelSource += "apply someProfile;\n";
    modelSource += "class SomeClass\n";
    modelSource += "  [my_stereotype] attribute someAttribute : Integer;\n";
    modelSource += "end;\n";
    modelSource += "end.\n";
    parseAndCheck(profileSource, modelSource);
    Class class_ = (Class) getRepository().findNamedElement("someModel::SomeClass",
            IRepository.PACKAGE.getClassifier(), null);
    Property attribute = class_.getAttribute("someAttribute", null);
    Stereotype stereotype = (Stereotype) getRepository().findNamedElement("someProfile::my_stereotype",
            IRepository.PACKAGE.getStereotype(), null);
    assertNotNull(stereotype);
    assertTrue(attribute.isStereotypeApplied(stereotype));
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:24,代码来源:StereotypeTests.java

示例10: testConstants

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testConstants() throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "class SomeClass\n";
    source += "static readonly attribute CONST1 : Integer := 10;\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Type integerType = (Type) getRepository()
            .findNamedElement("base::Integer", IRepository.PACKAGE.getType(), null);
    assertNotNull(integerType);
    Class class_ = (Class) getRepository().findNamedElement("someModel::SomeClass",
            IRepository.PACKAGE.getClass_(), null);
    assertNotNull(class_);
    Property property = class_.getAttribute("CONST1", integerType);
    assertNotNull(property);
    assertTrue(property.isReadOnly());
    ValueSpecification defaultValue = property.getDefaultValue();
    assertNotNull(defaultValue);
    assertTrue(MDDExtensionUtils.isBasicValue(defaultValue));
    assertEquals(10L, MDDExtensionUtils.getBasicValue(defaultValue));
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:24,代码来源:ClassifierTests.java

示例11: testAssociationRoleStereotypeApplication

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testAssociationRoleStereotypeApplication() throws CoreException {
    String profileSource = "";
    profileSource += "profile someProfile;\n";
    profileSource += "stereotype my_stereotype extends UML::Property end;\n";
    profileSource += "end.\n";

    String modelSource = "";
    modelSource += "model someModel;\n";
    modelSource += "import base;\n";
    modelSource += "apply someProfile;\n";
    modelSource += "class SomeClass\n";
    modelSource += "  attribute someAttribute : Integer;\n";
    modelSource += "end;\n";
    modelSource += "class AnotherClass\n";
    modelSource += "  attribute anotherAttribute : Integer;\n";
    modelSource += "end;\n";
    modelSource += "association SomeAssoc\n";
    modelSource += "  [my_stereotype] role anotherAttribute : AnotherClass;\n";
    modelSource += "  [my_stereotype] navigable role SomeClass.someAttribute;\n";
    modelSource += "end;\n";
    modelSource += "end.\n";
    IProblem[] problems = parse(profileSource, modelSource);
    assertTrue(problems.length == 1);
    assertTrue(problems[0].getSeverity() == IProblem.Severity.WARNING);
    Class class_ = (Class) getRepository().findNamedElement("someModel::SomeClass",
            IRepository.PACKAGE.getClassifier(), null);
    Property attribute = class_.getAttribute("someAttribute", null);
    Association assoc = (Association) getRepository().findNamedElement("someModel::SomeAssoc",
            IRepository.PACKAGE.getAssociation(), null);
    Stereotype stereotype = (Stereotype) getRepository().findNamedElement("someProfile::my_stereotype",
            IRepository.PACKAGE.getStereotype(), null);
    assertNotNull(stereotype);
    assertNotNull(assoc);
    Property anotherEnd = assoc.getOwnedEnd("anotherAttribute", null);
    assertNotNull(anotherEnd);
    assertTrue(anotherEnd.isStereotypeApplied(stereotype));
    assertFalse(attribute.isStereotypeApplied(stereotype));
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:39,代码来源:StereotypeTests.java


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