use of org.osate.ba.aadlba.DataRepresentation in project osate2 by osate.
the class AadlBaNameResolver method structOrUnionOrArrayIdResolver.
// Resolves the given identifier within the property Data_Model::Element
// Names of a declared struct or union component (event if element names is
// set). If the given component is not declared as a struct or union, it
// returns false and reports error according to the hasToReport flag.
private boolean structOrUnionOrArrayIdResolver(Identifier id, DataClassifier component, boolean hasToReport) {
boolean result = false;
DataRepresentation rep = AadlBaUtils.getDataRepresentation(component);
if (rep == DataRepresentation.STRUCT || rep == DataRepresentation.UNION) {
EList<PropertyExpression> lpv = PropertyUtils.findPropertyExpression(component, DataModelProperties.ELEMENT_NAMES);
ListValue lv = null;
StringLiteral sl = null;
int index1 = 0;
int index2 = 0;
for1: for (PropertyExpression pe : lpv) {
lv = (ListValue) pe;
for (PropertyExpression pex : lv.getOwnedListElements()) {
sl = (StringLiteral) pex;
if (id.getId().equalsIgnoreCase(sl.getValue())) {
result = true;
break for1;
}
index2++;
}
index1++;
}
// Binds the element name's base type.
if (result) {
EList<PropertyExpression> lpv2 = PropertyUtils.findPropertyExpression(component, DataModelProperties.BASE_TYPE);
ClassifierValue cv;
cv = (ClassifierValue) ((ListValue) lpv2.get(index1)).getOwnedListElements().get(index2);
id.setOsateRef(cv);
}
} else if (rep == DataRepresentation.ARRAY) {
EList<PropertyExpression> lpv = PropertyUtils.findPropertyExpression(component, DataModelProperties.BASE_TYPE);
if (lpv.isEmpty() == false) {
ClassifierValue cv;
cv = (ClassifierValue) ((ListValue) lpv.get(0)).getOwnedListElements().get(0);
result = identifierComponentResolver(id, cv.getClassifier(), hasToReport);
} else {
result = false;
}
}
if (!result && hasToReport) {
reportNameError(id, id.getId());
}
return result;
}
use of org.osate.ba.aadlba.DataRepresentation in project osate2 by osate.
the class AadlBaUtils method getDataRepresentation.
/**
* Returns the last data representation from the property stack of the given data
* classifier or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
* property is not set or if the data classifier represents a data structure.
*
* @param c the given data classifier
* @return the data representation or DataRepresentation.UNKNOWN
*/
public static DataRepresentation getDataRepresentation(DataClassifier c) {
DataRepresentation result = null;
if (c == null) {
result = DataRepresentation.UNKNOWN;
} else {
EList<PropertyExpression> l = PropertyUtils.findPropertyExpression(c, DataModelProperties.DATA_REPRESENTATION);
if (l.size() > 0) {
// Fetches the last enumeration value from the inheritance stack of
// properties.
NamedValue nv = (NamedValue) l.get(l.size() - 1);
String tmp = ((EnumerationLiteral) nv.getNamedValue()).getName();
result = DataRepresentation.getByName(tmp);
if (result == null) {
result = DataRepresentation.UNKNOWN;
}
} else {
result = DataRepresentation.UNKNOWN;
}
}
return result;
}
Aggregations