use of org.eclipse.emf.ecore.EEnumLiteral in project BIMserver by opensourceBIM.
the class ByteBufferVirtualObject method writeEnum.
private void writeEnum(EStructuralFeature feature, Object value) {
if (value == null) {
ensureCapacity(buffer.position(), 4);
buffer.putInt(-1);
} else {
EEnum eEnum = (EEnum) feature.getEType();
EEnumLiteral eEnumLiteral = eEnum.getEEnumLiteralByLiteral(((Enum<?>) value).toString());
ensureCapacity(buffer.position(), 4);
if (eEnumLiteral != null) {
buffer.putInt(eEnumLiteral.getValue());
} else {
LOGGER.error(((Enum<?>) value).toString() + " not found");
buffer.putInt(-1);
}
}
}
use of org.eclipse.emf.ecore.EEnumLiteral in project BIMserver by opensourceBIM.
the class XSDSchemaReader method createSimpleType.
private void createSimpleType(XSSimpleType simpleType) {
if (simpleType instanceof RestrictionSimpleTypeImpl) {
RestrictionSimpleTypeImpl restrictionSimpleTypeImpl = (RestrictionSimpleTypeImpl) simpleType;
String typeName = restrictionSimpleTypeImpl.getBaseType().getName();
if (typeName.equals("string")) {
EEnum eEnum = ecoreFactory.createEEnum();
eEnum.setName(simpleType.getName());
ePackage.getEClassifiers().add(eEnum);
int i = 0;
for (XSFacet facet : restrictionSimpleTypeImpl.getDeclaredFacets()) {
EEnumLiteral eEnumLiteral = ecoreFactory.createEEnumLiteral();
eEnumLiteral.setValue(i++);
eEnum.getELiterals().add(eEnumLiteral);
eEnumLiteral.setName(facet.getValue().toString().toUpperCase());
}
} else if (typeName.equals("double")) {
EClass eClass = ecoreFactory.createEClass();
eClass.setName(simpleType.getName());
ePackage.getEClassifiers().add(eClass);
} else if (typeName.equals("normalizedString")) {
EClass eClass = ecoreFactory.createEClass();
eClass.setName(simpleType.getName());
ePackage.getEClassifiers().add(eClass);
} else if (typeName.equals("boolean")) {
EClass eClass = ecoreFactory.createEClass();
eClass.setName(simpleType.getName());
ePackage.getEClassifiers().add(eClass);
} else if (typeName.equals("long")) {
EClass eClass = ecoreFactory.createEClass();
eClass.setName(simpleType.getName());
ePackage.getEClassifiers().add(eClass);
} else {
EClass eClass = ecoreFactory.createEClass();
eClass.setName(simpleType.getName());
ePackage.getEClassifiers().add(eClass);
}
} else {
System.out.println(simpleType.getName());
}
}
use of org.eclipse.emf.ecore.EEnumLiteral in project xtext-eclipse by eclipse.
the class EnumTemplateVariableResolver method resolveValues.
@Override
public List<String> resolveValues(TemplateVariable variable, XtextTemplateContext castedContext) {
String enumerationName = 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>() {
@Override
public String apply(EEnumLiteral enumLiteral) {
return enumLiteral.getLiteral();
}
});
}
use of org.eclipse.emf.ecore.EEnumLiteral in project InformationSystem by ObeoNetwork.
the class EcorebindingModelWizardSpec method explore.
/**
* Expore the EPackage and init the BPackage.
* @param ePackage The ecore Package input to read
* @param bPackage The Binding Package to build
*/
private static void explore(EPackage ePackage, BPackage bPackage) {
EList<EClassifier> eClassifiers = ePackage.getEClassifiers();
for (EClassifier eClassifier : eClassifiers) {
if (eClassifier instanceof EClass) {
EClass eClass = (EClass) eClassifier;
// Create BClass
BClass bClass = EcorebindingFactory.eINSTANCE.createBClass();
bClass.setEcoreClass(eClass);
bPackage.getBClasses().add(bClass);
bPackage.getBClassifiers().add(bClass);
explore(eClass, bClass);
} else if (eClassifier instanceof EEnum) {
EEnum eEnum = (EEnum) eClassifier;
// Create BEnum
BEnum bEnum = EcorebindingFactory.eINSTANCE.createBEnum();
bEnum.setEcoreEnum(eEnum);
bEnum.setEcoreDataType(eEnum);
bPackage.getBEnums().add(bEnum);
bPackage.getBClassifiers().add(bEnum);
List<EEnumLiteral> eLiterals = eEnum.getELiterals();
for (EEnumLiteral eLiteral : eLiterals) {
// Create BEnumLiteral
BEnumLiteral bEnumLiteral = EcorebindingFactory.eINSTANCE.createBEnumLiteral();
bEnumLiteral.setBEnum(bEnum);
bEnumLiteral.setEcoreEnumLiteral(eLiteral);
}
} else if (eClassifier instanceof EDataType) {
EDataType eDataType = (EDataType) eClassifier;
// Create BDataType
BDataType bDataType = EcorebindingFactory.eINSTANCE.createBDataType();
bDataType.setEcoreDataType(eDataType);
bPackage.getBDataTypes().add(bDataType);
bPackage.getBClassifiers().add(bDataType);
}
}
List<EPackage> eSubpackages = ePackage.getESubpackages();
for (EPackage subEPackage : eSubpackages) {
// Create BPackage
BPackage subBPackage = EcorebindingFactory.eINSTANCE.createBPackage();
subBPackage.setEcorePackage(subEPackage);
bPackage.getNestedBPackages().add(subBPackage);
explore(subEPackage, subBPackage);
}
}
use of org.eclipse.emf.ecore.EEnumLiteral in project gemoc-studio by eclipse.
the class GEnumLiteralExpressionImpl method setValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setValue(EEnumLiteral newValue) {
EEnumLiteral oldValue = value;
value = newValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GexpressionsPackage.GENUM_LITERAL_EXPRESSION__VALUE, oldValue, value));
}
Aggregations