本文整理汇总了Java中org.eclipse.emf.ecore.EEnumLiteral.setName方法的典型用法代码示例。如果您正苦于以下问题:Java EEnumLiteral.setName方法的具体用法?Java EEnumLiteral.setName怎么用?Java EEnumLiteral.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EEnumLiteral
的用法示例。
在下文中一共展示了EEnumLiteral.setName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: createEEnumLiteral
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
public EEnumLiteral createEEnumLiteral(EEnum eEnum, String name) {
EEnumLiteral eEnumLiteral = EcoreFactory.eINSTANCE.createEEnumLiteral();
if (eEnum.getELiterals().size() == 0) {
eEnumLiteral.setValue(0);
} else {
int largestValue = Integer.MIN_VALUE;
for (EEnumLiteral existingLiteral : eEnum.getELiterals()) {
if (existingLiteral.getValue() > largestValue) {
largestValue = existingLiteral.getValue();
}
}
eEnumLiteral.setValue(largestValue + 1);
}
eEnum.getELiterals().add(eEnumLiteral);
eEnumLiteral.setName(name);
return eEnumLiteral;
}
示例3: createTristate
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
private void createTristate() {
tristate = eFactory.createEEnum();
tristate.setName("Tristate");
EEnumLiteral trueLiteral = eFactory.createEEnumLiteral();
trueLiteral.setName("TRUE");
trueLiteral.setValue(0);
EEnumLiteral falseLiteral = eFactory.createEEnumLiteral();
falseLiteral.setName("FALSE");
falseLiteral.setValue(1);
EEnumLiteral undefinedLiteral = eFactory.createEEnumLiteral();
undefinedLiteral.setName("UNDEFINED");
undefinedLiteral.setValue(2);
tristate.getELiterals().add(trueLiteral);
tristate.getELiterals().add(falseLiteral);
tristate.getELiterals().add(undefinedLiteral);
schemaPack.getEClassifiers().add(tristate);
}
示例4: visit
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
@Override
public void visit(Enum enum1, String param) {
if (hasElement(enum1)) {
return;
}
EEnum eEnum = g_EcoreFactory.createEEnum();
setElement(enum1, eEnum);
eEnum.setName(enum1.getId()
.getName()
.toString());
EPackage enumPackage = packageFromId(enum1.getId()
.getNamespace());
enumPackage.getEClassifiers()
.add(eEnum);
List<EEnumLiteral> eLiterals = eEnum.getELiterals();
for (Name litName : enum1.getLiterals()) {
EEnumLiteral eEnumLit = g_EcoreFactory.createEEnumLiteral();
eEnumLit.setName(litName.toString());
//eEnumLit.setLiteral(litName.toString());
eLiterals.add(eEnumLit);
}
}
示例5: clone
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
/**
* It makes a shallow copy of an enumerate literal.
* @param literal
*/
private EEnumLiteral clone (EEnumLiteral literal) {
EEnumLiteral copy = EcoreFactory.eINSTANCE.createEEnumLiteral();
copy.setLiteral(literal.getLiteral());
copy.setName (literal.getName());
copy.setValue (literal.getValue());
return copy;
}
示例6: adapt
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
public void adapt(EEnum c) {
for (EEnumLiteral lit : c.getELiterals()) {
if ( UseReservedWords.isReserved(lit.getName()) ) {
lit.setName(UseReservedWords.getReplacement(lit.getName()));
}
}
}
示例7: addEnumerations
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
private void addEnumerations() {
Iterator<DefinedType> typeIter = schema.getTypes().iterator();
while (typeIter.hasNext()) {
DefinedType type = typeIter.next();
if (type instanceof EnumerationType) {
EEnum enumeration = eFactory.createEEnum();
enumeration.setName(type.getName());
EEnumLiteral nullValue = eFactory.createEEnumLiteral();
nullValue.setName("NULL");
nullValue.setLiteral("NULL");
nullValue.setValue(0);
enumeration.getELiterals().add(nullValue);
int counter = 1;
Iterator<String> values = ((EnumerationType) type).getElements().iterator();
while (values.hasNext()) {
String stringVal = values.next();
if (!stringVal.equals("NULL")) {
EEnumLiteral value = eFactory.createEEnumLiteral();
value.setName(stringVal);
value.setLiteral(stringVal);
value.setValue(counter);
counter++;
enumeration.getELiterals().add(value);
}
}
schemaPack.getEClassifiers().add(enumeration);
}
}
}
示例8: deriveEnums
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的package包/类
private void deriveEnums(EnumRule rule) {
EEnum returnType = (EEnum) rule.getType().getClassifier();
if (returnType != null) {
List<EnumLiteralDeclaration> decls = EcoreUtil2.getAllContentsOfType(rule, EnumLiteralDeclaration.class);
for(EnumLiteralDeclaration decl : decls) {
if (decl.getEnumLiteral() == null) {
List<INode> nodes = NodeModelUtils.findNodesForFeature(decl, XtextPackage.Literals.ENUM_LITERAL_DECLARATION__ENUM_LITERAL);
if (!nodes.isEmpty()) {
if (nodes.size() > 1)
throw new IllegalStateException("Unexpected nodes found: " + nodes);
INode node = nodes.get(0);
String text = node.getText();
EEnumLiteral literal = null;
if (rule.getType().getMetamodel() instanceof ReferencedMetamodel) {
literal = returnType.getEEnumLiteral(text);
} else {
EEnumLiteral existing = returnType.getEEnumLiteral(text);
if (existing == null) {
literal = EcoreFactory.eINSTANCE.createEEnumLiteral();
int index = returnType.getELiterals().size();
returnType.getELiterals().add(literal);
literal.setName(text);
literal.setValue(index);
if (decl.getLiteral() != null) {
literal.setLiteral(decl.getLiteral().getValue());
} else {
literal.setLiteral(text);
}
} else {
literal = existing;
}
SourceAdapter.adapt(literal, decl);
}
if (literal == null) {
reportError(new TransformationException(TransformationErrorCode.InvalidFeature, "Enum literal '" + text + "' does not exist.", decl));
} else {
decl.setEnumLiteral(literal);
}
}
}
if (decl.getLiteral() == null && decl.getEnumLiteral() != null) {
Keyword kw = XtextFactory.eINSTANCE.createKeyword();
kw.setValue(decl.getEnumLiteral().getLiteral());
decl.setLiteral(kw);
}
}
}
}
示例9: createPropertiesDefinition
import org.eclipse.emf.ecore.EEnumLiteral; //导入方法依赖的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;
}