use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class PropertyUtils method getScaledRangeDelta.
/**
* Return the delta value of a non-modal range property value scaled to a
* given unit. Returns a given default value if no property value exists.
* Throws an exception if an error occurs.
*
* @param ph The property holder from which to retrieve the property value.
* @param pd The property to retrieve.
* @param unit The unit to scale the value to.
* @param defaultVal The value to return if the property has no value.
* @return The delta of the range value scaled to the given unit.
*/
public static double getScaledRangeDelta(final NamedElement ph, final Property pd, final UnitLiteral unit, final double defaultVal) {
try {
final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
final RangeValue rv = (RangeValue) pv;
return rv.getDeltaValue().getScaledValue(unit);
} catch (PropertyLookupException e) {
return defaultVal;
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getAllowedDispatchProtocol.
public static List<EnumerationLiteral> getAllowedDispatchProtocol(NamedElement ne) {
try {
List<EnumerationLiteral> res = new ArrayList<>();
Property allowedDispatchProtocol = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_DISPATCH_PROTOCOL);
List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(allowedDispatchProtocol);
for (PropertyExpression propertyExpression : propertyValues) {
res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
}
return res;
} catch (PropertyLookupException e) {
return Collections.emptyList();
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getSourceLanguage.
public static List<String> getSourceLanguage(final NamedElement ne) {
try {
List<String> res = new ArrayList<String>();
Property sourceLanguage = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_LANGUAGE);
List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(sourceLanguage);
for (PropertyExpression propertyExpression : propertyValues) {
String v = ((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue()).getName();
res.add(v);
}
return res;
} catch (PropertyLookupException e) {
return null;
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getModelReferences.
public static List<? extends PropertyExpression> getModelReferences(final NamedElement ne) {
try {
Property modelReferences = lookupPropertyDefinition(ne, SEI._NAME, SEI.MODEL_REFERENCES);
List<? extends PropertyExpression> values = ne.getPropertyValueList(modelReferences);
return values;
} catch (PropertyLookupException e) {
return null;
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getSourceText.
public static List<String> getSourceText(final NamedElement ne) {
List<String> res;
res = new ArrayList<String>();
try {
Property st = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_TEXT);
List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(st);
for (PropertyExpression propertyExpression : propertyValues) {
// System.out.println("pe=" + propertyExpression);
StringLiteral sl = (StringLiteral) propertyExpression;
res.add(sl.getValue());
}
return res;
} catch (PropertyLookupException e) {
return null;
}
}
Aggregations