edu.cmu.sei.aadl.model.properties
Interface AadlPropertyValue

All Known Subinterfaces:
ReflectiveAadlPropertyValue
All Known Implementing Classes:
AbstractAadlPropertyValue, BogusPropertyValue, ListPropertyValue, NonExistentPropertyValue, ReflectiveValueWrapper, ScalarPropertyValue, UndefinedByReferencePropertyValue, UndefinedPropertyValue

public interface AadlPropertyValue

Interface encapsulating an actual evaluated property value for a specific property of a specific component in a specific mode. The main purpose of this interface is to deal with the fact that value can be non-existent or undefined, and to deal with the fact that the value may be a list or a scalar.

A property value may not exist if the component for which it was looked up does not exist in the particular mode used to look up the value. In such cases exists() returns false. A property value may be undefined if no value is ever associated with the property. In such cases isNotPresent() returns true. An existent, defined property may be a list, in which case isList() returns true. It is not possible to determine if the value is a list by using the getValue() method because it always returns a list. When isList() is false the list has a length of one. The list returned by getValue() is of PropertyValue objects. The shortcut method getScalarValue() may be used when isList() is false to directly obtain a single PropertyValue object.

The methods preEvaluate(PropertyHolder) and evaluate(PropertyHolder, Map) are used by the property lookup algorithms and should not be used otherwise.

Author:
aarong

Method Summary
 AadlPropertyValue evaluate(PropertyHolder context, java.util.Map modes)
          Evaluate a property value in the given context and with the given mode bindings.
 boolean exists()
          Does the value exist at all?
 java.util.List getDefiningAssociations()
          Get the property associations/property declaration that determines this value.
 PropertyValue getScalarValue()
          Get the scalar value of the property.
 java.util.List getValue()
          Get the value of the property.
 AadlPropertyValue instantiate(ComponentInstance root)
          Update the property value so that it makes sense in an instance model.
 boolean isList()
          Is the value a list value?
 boolean isNotPresent()
          Is the value not present.
 java.util.Set preEvaluate(PropertyHolder context)
          Determine which modes this value may depend on.
 

Method Detail

exists

boolean exists()
Does the value exist at all? A value does not exist if the component does not exist in the particular mode. This is not the same as the value being not present, which indicates that the property value is not set for the component in the given mode.

Returns:
true if the value exists.
See Also:
isNotPresent()

isNotPresent

boolean isNotPresent()
Is the value not present.

Returns:
true if the value is "not present". A non existent property value is not "not present", and thus this returns false if the exists()is false.

isList

boolean isList()
Is the value a list value?

Returns:
true if the value is a list. Returns false if exists()or isNotPresent()is true.

getValue

java.util.List getValue()
Get the value of the property.

Returns:
The value of the property as an immutable list. If the value does not exist or is not present this returns null. If isList()is false then this list is a one-element list, whose first (and only) element is the property value. Otherwise, the returned list is the property value.

getScalarValue

PropertyValue getScalarValue()
Get the scalar value of the property.

Returns:
The scalar value. If the value does not exist or is not present this returns null.
Throws:
java.lang.UnsupportedOperationException - Thrown if isList()is true.

preEvaluate

java.util.Set preEvaluate(PropertyHolder context)
                          throws InvalidModelException
Determine which modes this value may depend on.

Parameters:
context - The element this value comes from.
Returns:
The model elements whose modes influence the value
Throws:
InvalidModelException - Thrown if the property value cannot be pre-evaluated because the model is incomplete or malformed.

evaluate

AadlPropertyValue evaluate(PropertyHolder context,
                           java.util.Map modes)
                           throws InvalidModelException
Evaluate a property value in the given context and with the given mode bindings.

Parameters:
context - The element any property references should be looked up against.
modes - A map from ComponentImpl to Modedefining the mode bindings to use for the evaluation.
Returns:
The evaluated property value.
Throws:
InvalidModelException - Thrown if the property value cannot be evaluated because the model is incomplete or malformed.

instantiate

AadlPropertyValue instantiate(ComponentInstance root)
                              throws InvalidModelException
Update the property value so that it makes sense in an instance model. For example, ReferencePropertyValue objects are replaced with InstanceReferencePropertyValue objects.

Parameters:
root - The component instance to be used as the root of subcomponent paths. (This is also the component whose declared modes may be used in any in modes clauses.)
Returns:
The instantiated property value.
Throws:
InvalidModelException - Thrown if the property value cannot be instantiated because the model is incomplete or malformed.

getDefiningAssociations

java.util.List getDefiningAssociations()
Get the property associations/property declaration that determines this value. This is list of at least length one. It contains zero or more property associations followed by at most one property declaration. Specifically, if the value is not list-valued, then this returns a list of length one, where the element is either the PropertyAssociation that provides the value, or the PropertyDefinition of the property in the case that the value is the default value. If the value is list-valued, then the list represents those property assocations and possibly the property defintiion that contribute to the value of the list. This list may be of non-zero length even when isNotPresent() is true because the value actually be defined to be a reference to another property value and that property value might be undefined.