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


Java EEnumLiteral类代码示例

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


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

示例1: readEnum

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
private void readEnum(String val, VirtualObject object, EStructuralFeature structuralFeature) throws DeserializeException, MetaDataException, DatabaseException {
	if (val.equals(".T.")) {
		object.setAttribute(structuralFeature, Boolean.TRUE);
	} else if (val.equals(".F.")) {
		object.setAttribute(structuralFeature, Boolean.FALSE);
	} else if (val.equals(".U.")) {
		object.eUnset(structuralFeature);
	} else {
		if (structuralFeature.getEType() instanceof EEnumImpl) {
			String realEnumValue = val.substring(1, val.length() - 1);
			EEnumLiteral enumValue = (((EEnumImpl) structuralFeature.getEType()).getEEnumLiteral(realEnumValue));
			if (enumValue == null) {
				throw new DeserializeException(lineNumber, "Enum type " + structuralFeature.getEType().getName() + " has no literal value '" + realEnumValue + "'");
			}
			object.setAttribute(structuralFeature, enumValue.getLiteral());
		} else {
			throw new DeserializeException(lineNumber, "Value " + val + " indicates enum type but " + structuralFeature.getEType().getName() + " expected");
		}
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:21,代码来源:IfcStepStreamingDeserializer.java

示例2: getEEnumLiteral

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
public EEnumLiteral getEEnumLiteral(String enumName, String literalName) {
	EClassifier eClassifier = ePackage.getEClassifier(enumName);
	if (eClassifier == null) {
		throw new RuntimeException("Classifier " + enumName + " not found in package " + ePackage.getName());
	}
	if (eClassifier instanceof EEnum) {
		EEnum eEnum = (EEnum)eClassifier;
		EEnumLiteral literal = eEnum.getEEnumLiteral(literalName);
		if (literal == null) {
			throw new RuntimeException("No enum literal " + literalName + " found on " + ePackage.getName() + "." + enumName);
		}
		return literal;
	} else {
		throw new RuntimeException("Classifier " + enumName + " is not of type enum");
	}
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:17,代码来源:PackageMetaData.java

示例3: visitEnum

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
private Enum visitEnum(TypeModel mm, EEnum eEnum) {
    Id enumID = EcoreUtil.idFromClassifier(eEnum);

    if (mm.hasEnum(enumID)) {
        return mm.getEnum(enumID);
    }

    Enum cmEnum = mm.getEnum(enumID, true);

    for (EEnumLiteral eEnumLiteral : eEnum.getELiterals()) {
        Name litName = Name.getName(eEnumLiteral.getName());
        cmEnum.addLiteral(litName);
    }

    return cmEnum;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:EcoreToType.java

示例4: createEnumerationType

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
private EEnum createEnumerationType(EnumerationType type) {
	EEnum eenum = EcoreFactory.eINSTANCE.createEEnum();
	eenum.setName(type.getName());
	int value = 0;
	for (EnumerationLiteral literal : type.getLiterals()) {
		EEnumLiteral eenumliteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
		eenum.getELiterals().add(eenumliteral);
		eenumliteral.setName(literal.getName());
		eenumliteral.setLiteral(literal.getName());
		eenumliteral.setValue(value);
		value++;
		if (literal.getDocumentation() != null) {
			attachInfo(eenumliteral, literal.getDocumentation());
		}
	}
	if (type.getDocumentation() != null) {
		attachInfo(eenum, type.getDocumentation());
	}
	return eenum;
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:21,代码来源:OCCIExtension2Ecore.java

示例5: parsePrimitive

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
private Object parsePrimitive(EClassifier eType, String text) throws DeserializeException {
	if (eType == EcorePackage.eINSTANCE.getEString()) {
		return text;
	} else if (eType == EcorePackage.eINSTANCE.getEInt()) {
		return Integer.parseInt(text);
	} else if (eType == EcorePackage.eINSTANCE.getELong()) {
		return Long.parseLong(text);
	} else if (eType == EcorePackage.eINSTANCE.getEDouble()) {
		return Double.parseDouble(text);
	} else if (eType == EcorePackage.eINSTANCE.getEBoolean()) {
		return Boolean.parseBoolean(text);
	} else if (eType instanceof EEnum) {
		EEnumLiteral eEnumLiteral = ((EEnum) eType).getEEnumLiteral(text.toUpperCase());
		if (eEnumLiteral == null) {
			if (text.equals("unknown")) {
				return null;
			} else {
				throw new DeserializeException("Unknown enum literal " + text + " in enum " + ((EEnum) eType).getName());
			}
		}
		return eEnumLiteral.getInstance();
	} else {
		throw new DeserializeException("Unimplemented primitive type: " + eType.getName());
	}
}
 
开发者ID:opensourceBIM,项目名称:IfcPlugins,代码行数:26,代码来源:IfcXmlDeserializer.java

示例6: testEnum_01

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Test public void testEnum_01() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/1'\n" +
		"Model: enumValue=MyEnum;\n" +
		"enum MyEnum: Value1;";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/1", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
	assertNotNull(eEnum);
	assertEquals(1, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals("Value1", value.getName());
	assertEquals(0, value.getValue());
	assertEquals("Value1", value.getLiteral());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarParserTest.java

示例7: testEnum_02

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Test public void testEnum_02() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/2'\n" +
		"Model: enumValue=MyEnumRule;\n" +
		"enum MyEnumRule returns MyEnum: Value1;";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/2", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
	assertNotNull(eEnum);
	assertEquals(1, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals("Value1", value.getName());
	assertEquals(0, value.getValue());
	assertEquals("Value1", value.getLiteral());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarParserTest.java

示例8: testEnum_03

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Test public void testEnum_03() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/3'\n" +
		"Model: enumValue=MyEnumRule;\n" +
		"enum MyEnumRule returns MyEnum: Value1 = 'value';";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/3", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
	assertNotNull(eEnum);
	assertEquals(1, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals("Value1", value.getName());
	assertEquals(0, value.getValue());
	assertEquals("value", value.getLiteral());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarParserTest.java

示例9: testEnum_07

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Test public void testEnum_07() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/7'\n" +
		"Model: enumValue=MyEnum;\n" +
		"enum MyEnum: Value | Value;";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/7", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
	assertNotNull(eEnum);
	assertEquals(1, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals("Value", value.getName());
	assertEquals(0, value.getValue());
	assertEquals("Value", value.getLiteral());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarParserTest.java

示例10: testEnum_08

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Test public void testEnum_08() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/8'\n" +
		"Model: enumValue=MyEnum;\n" +
		"enum MyEnum: Value | Value = 'foo';";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/8", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("MyEnum");
	assertNotNull(eEnum);
	assertEquals(1, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals("Value", value.getName());
	assertEquals(0, value.getValue());
	assertEquals("Value", value.getLiteral());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:GrammarParserTest.java

示例11: resolveValues

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Override
public List<String> resolveValues(TemplateVariable variable,
		XtextTemplateContext castedContext) {
	String enumerationName = (String) variable.getVariableType()
			.getParams().iterator().next();
	Grammar grammar = getGrammar(castedContext);
	if (grammar == null)
		return Collections.emptyList();
	EEnum enumeration = (EEnum) getEClassifierForGrammar(enumerationName, grammar);
	if (enumeration == null) {
		return Collections.emptyList();
	}
	return Lists.transform(enumeration.getELiterals(), new Function<EEnumLiteral, String>() {
		public String apply(EEnumLiteral enumLiteral) {
			return enumLiteral.getLiteral();
		}
	});
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:EnumTemplateVariableResolver.java

示例12: combine

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
private Object combine(Object previousValue, Object value) {
	if (previousValue instanceof Number && value instanceof Number) {
		return normalize(((Number)previousValue).doubleValue() + ((Number)value).doubleValue());
	} else if (previousValue instanceof Amount && value instanceof Amount) {
		return ((Amount)previousValue).plus(((Amount)value));
	} else if (previousValue instanceof String && value instanceof String) {
		return value;
	} else if (previousValue instanceof EEnumLiteral && value instanceof EEnumLiteral) {
		return value;
	} else if (previousValue instanceof Boolean && value instanceof Boolean) {
		return value;
	} else {
		LogUtil.errorOnce(profileKey+": unrecognized value pair '"+previousValue+"' & '"+value+"'");
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:DynamicProfileDependency.java

示例13: createActivityRandomly

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
protected EActivity createActivityRandomly(EActivityDef def) {
	EActivity activity = PlanFactory.getInstance().createActivity(def, null);
	for (EStructuralFeature feature : def.getEAllStructuralFeatures()) {
		if (!feature.isChangeable()) {
			continue;
		}
		Object value = activity.getData().eGet(feature);
		EClassifier type = feature.getEType();
		if (type instanceof EEnum) {
			EList<EEnumLiteral> literals = ((EEnum)type).getELiterals();
			int index = (int) (Math.random() * literals.size());
			value = literals.get(index);
			if (feature.isMany()) {
				value = Collections.singletonList(value);
			}
		} else if (EcorePackage.Literals.ESTRING == type) {
			value = "String "+Math.random();
		}
		activity.getData().eSet(feature, value);
	}
	return activity;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:TestPlanIORoundTrip.java

示例14: getImage

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
@Override
public Image getImage(Object element) {
	if (element instanceof DynamicActivityGroup) {
		DynamicActivityGroup dag = (DynamicActivityGroup) element;
		Object value = dag.getValue();
		if (value instanceof EEnumLiteral) {
			return null;
		}
		IItemLabelProvider lp = EMFUtils.adapt(value, IItemLabelProvider.class);
		if (lp != null) {
			Object image = lp.getImage(value);
			return ExtendedImageRegistry.getInstance().getImage(image);
		}
		return null;
	}
	return delegate.getImage(element);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:PlanElementRowHeaderEditPart.java

示例15: getValueString

import org.eclipse.emf.ecore.EEnumLiteral; //导入依赖的package包/类
protected String getValueString(Object value) {
	if (value instanceof EEnumLiteral) {
		return ((EEnumLiteral)value).getLiteral();
	} else if (value instanceof EObject) {
		IItemLabelProvider labeler = EMFUtils.adapt(value, IItemLabelProvider.class);
		if (labeler != null) {
			String text = labeler.getText(value);
			if (text != null) {
				return text;
			}
		}
	} else if (NULL_VALUE == value) {
		return "";
	}
	return value.toString();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:GroupingTimelineContentProvider.java


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