use of org.eclipse.emf.ecore.EAttribute in project benchmarx by eMoflon.
the class ChangeRecorder method WriteFullElement.
private void WriteFullElement(EObject element, String type) {
buffer.append("\t\t<");
buffer.append(type);
buffer.append(" xsi:type=\"");
EClass eClass = element.eClass();
EPackage ePackage = (EPackage) eClass.eContainer();
buffer.append(ePackage.getNsPrefix());
buffer.append(":");
buffer.append(eClass.getName());
buffer.append("\" xmlns:");
buffer.append(ePackage.getNsPrefix());
buffer.append("=\"");
buffer.append(ePackage.getNsURI());
buffer.append("\"");
for (EAttribute att : eClass.getEAllAttributes()) {
if (element.eIsSet(att)) {
Object value = element.eGet(att);
WriteAttribute(att.getName(), toCompatibleString(value));
}
}
buffer.append(" />\n");
this.RegisterNewElement(element, this.changeCounter, type);
}
use of org.eclipse.emf.ecore.EAttribute in project openhab1-addons by openhab.
the class ConfigurationHandler method checkTfType.
/**
* Checks if the {@code deviceType} is known by the {@link Ecosystem}.
*
* @param ohId The name of the device found in openhab.cfg as {@code String}.
* @param deviceType The device type found in openhab.cfg as {@code String}.
* @throws ConfigurationException
*/
private void checkTfType(String ohId, String deviceType) throws ConfigurationException {
ModelPackage modelPackage = ModelPackage.eINSTANCE;
boolean deviceFound = false;
for (EClassifier eClassifier : modelPackage.getEClassifiers()) {
if (eClassifier instanceof EClass) {
EList<EAttribute> attributes = ((EClass) eClassifier).getEAllAttributes();
for (EAttribute attribute : attributes) {
if (attribute.getName().equals("deviceType")) {
if (attribute.getDefaultValueLiteral().equals(deviceType)) {
deviceFound = true;
break;
}
}
}
}
}
if (!deviceFound) {
throw new ConfigurationException(ohId, "unknown device type: " + deviceType);
}
}
Aggregations