A plug-in typically needs to get the values from specific properties, and thus
the author of the
plug-in knows ahead of time the property type of the property, whether the propertys values
should be lists, and whether the value should depend on the mode. Section 5.8.4 Getting
Property Values describes the general property retrieval methods, but OSATE provides
many other, easier-to-use methods that take advantage of this prior knowledge. Section
5.4.1 Getting the Property Declaration and Driving the Analysis introduces the method
PropertyHolder.getSimplePropertyValue which gets a non-list property value whose
value does not depend upon modes. There are three versions of this method:
- getSimplePropertyValue(PropertyDefinition
pd) returns a PropertyValue
object, or null if the property value is not present, is a list, or depends on modes.
- getSimplePropertyValue(String
name) looks up the property value of the named
predeclared property. That is, the property definition of the given name is searched
for in the Aadl_Properties and Aadl_Project property sets. An
IllegalArgumentException is thrown if the named property cannot be found.
Otherwise, returns a PropertyValue object, or null if the property value is not
present, is a list, or depends on modes.
- getSimplePropertyValue(String
propertySet, String name) looks up the
property value of the named property. The named property is searched for in the
named property set. An IllegalArgumentException is thrown if the named
property cannot be found. Otherwise, returns a PropertyValue object, or null if
the
property value is not present, is a list, or depends on modes.
A non-modal list-valued property value can be retrieved using the method
PropertyHolder.getPropertyValueList(PropertyDefinition) which returns a
java.util.List of PropertyValue objects, or null if the property value is not present
or
depends on modes.
Method PropertyHolder.isModalPropertyValue(PropertyDefinition pd) can
be used to
see if a particular property value depends on modes.
While these methods make it easy to get a property value without worrying about
modes, they
still require the programmer to cast the returned PropertyValue back to expected property
type. The class PropertyUtils in package edu.cmu.sei.aadl.model.properties addresses
this problem with a suite static helper methods that return a particular type of property value,
and perform common manipulations to the returned value. As above, all the methods assume
the property value is non-list and non-modal. Those that can, return null in these cases;
those
that cannot return null because they do not return an object type return a caller-provided
default value. If the retrieved property value is not of the expect type, the methods throw a
ClassCastException. Those that take UnitLiterals throw an IllegalArgumentException
if the literal is not from the type of the given property. The methods in PropertyUtils
are
shown in the following table.
Operation
|
Method
|
Get a Boolean property value
|
boolean
getBooleanValue(PropertyHolder ph,
PropertyDefinition pd, boolean defaultVal)
|
Get
an enumeration property
value
|
EnumLiteral
getEnumLiteral(PropertyHolder ph,
PropertyDefinition pd)
|
Get a string property value
|
String
getStringValue(PropertyHolder ph,
PropertyDefinition pd)
|
Get an unscaled integer value
|
long
getIntegerValue(PropertyHolder ph,
PropertyHolder pd, long defaultVal)
|
Get an unscaled real value4
|
double
getRealValue(PropertyHolder ph,
PropertyHolder pd, double defaultVal)
|
Get
a number value scaled to
given unit.
|
double
getScaledNumberValue(PropertyHolder ph,
PropertyDefinition pd, UnitLiteral unit,
double defaultVal)
|
Get
the lower bound of a
range value scaled to a given
unit
|
double
getScaledRangeMinimum(PropertyHolder ph,
PropertyDefinition pd, UnitLiteral unit,
double defaultVal)
|
Get
the upper bound of a
range value scaled to a given
unit
|
double
getScaledRangeMaximum(PropertyHolder ph,
PropertyDefinition pd, UnitLiteral unit,
double defaultVal)
|
Get
the delta of a range value
scaled to a given unit
|
double
getScaledRangeDelta(PropertyHolder ph,
PropertyDefinition pd, UnitLiteral unit,
double defaultVal)
|
Get
the instantiated
component referenced by a
reference value
|
ComponentInstance
getComponentInstanceReference(InstanceObject io,
PropertyDefinition pd)
|