edu.cmu.sei.aadl.model.properties
Class ModalPropertyValueAccumulatorImpl

java.lang.Object
  extended by edu.cmu.sei.aadl.model.properties.ModalPropertyValueAccumulatorImpl
All Implemented Interfaces:
ModalPropertyValue, ModalPropertyValueAccumulator
Direct Known Subclasses:
DeclarativeMPVA, InstanceMPVA

public abstract class ModalPropertyValueAccumulatorImpl
extends java.lang.Object
implements ModalPropertyValueAccumulator

Author:
aarong

Nested Class Summary
protected static class ModalPropertyValueAccumulatorImpl.DefaultPAWrapper
           
protected  class ModalPropertyValueAccumulatorImpl.ModalAssociations
           
 class ModalPropertyValueAccumulatorImpl.NonExistentPropertyException
           
protected static class ModalPropertyValueAccumulatorImpl.PAWrapper
          Wraps a reference to the PropertyAssociation as used by the ModeAssocNode.
 
Field Summary
static ModeContext NOT_MODAL
          Value for the mode index that indicates the particular association isn't modal.
protected  PropertyHolder propHolder
          The property holder for which the property value is being looked up.
static java.util.List VALUE_UNDEFINED
          Constant for marking a value as undefined.
 
Constructor Summary
ModalPropertyValueAccumulatorImpl(boolean list, PropertyHolder ctx)
          Create a new property value accumulate with the given propHolder.
 
Method Summary
 void addDefaultValue(AadlPropertyValue defValue)
          Accumulate a default value.
 java.util.Set addLocalContainedPropertyAssociations(PropertyHolder target, PropertyHolder container, PropertyDefinition pn)
          Accumulate the associations for the given property as found in the contained property associations of the target's containing component.
 java.util.Set addLocalContainedPropertyAssociations(PropertyHolder target, PropertyHolder container, PropertyDefinition pn, java.util.List targetExistsInModes, ModeContext modeContext)
          Accumulate the associations for the given property as found in the contained property associations of the target's containing component.
 java.util.Set addPropertyAssociations(PropertyHolder ph, PropertyDefinition pn)
          Accumulate the associations for the given property as found in the immediate properties attribute of the given property holder.
 java.util.Set addPropertyAssociations(PropertyHolder ph, PropertyDefinition pn, java.util.List compExistsInModes, ModeContext modeContext)
          Accumulate the associations for the given property as found in the immediate properties attribute of the given property holder.
protected abstract  ModalPropertyValueAccumulatorImpl.ModalAssociations createModalAssociations(PropertyHolder ph)
           
protected abstract  ModalPropertyValueAccumulatorImpl.ModalAssociations createModalAssociations(PropertyHolder ph, java.util.List inModes)
           
protected abstract  ModeContext fixModeContext(ModeContext mc)
          Given a mode context from an element along the lookup path, convert it to be compatible with the context (propHolder) of the current property lookup.
 java.util.Collection getAllModeBindings()
          Get all the mode contexts that are applicable to this value.
 java.util.Collection getAllValues()
          Get all the values the property value could have.
 java.util.Set getModeContexts()
          Get the components whose modes may affect this value.
 ModeContext[] getModeContextsAsArray()
          Get the components whose modes may affect this value.
 AadlPropertyValue getValue()
          Get the property value in the empty mode context.
 AadlPropertyValue getValue(java.util.Map modes)
          Get the property value based on the given mode settings.
 boolean isModal()
          Query if the property value may depend on modes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_UNDEFINED

public static final java.util.List VALUE_UNDEFINED
Constant for marking a value as undefined.


NOT_MODAL

public static final ModeContext NOT_MODAL
Value for the mode index that indicates the particular association isn't modal.


propHolder

protected final PropertyHolder propHolder
The property holder for which the property value is being looked up. We need to hold on to this to use it to look up any property values that it may reference using the value(...) construct.

Constructor Detail

ModalPropertyValueAccumulatorImpl

public ModalPropertyValueAccumulatorImpl(boolean list,
                                         PropertyHolder ctx)
Create a new property value accumulate with the given propHolder.

Parameters:
ctx - The binding propHolder for the property being constructed.
Method Detail

addDefaultValue

public final void addDefaultValue(AadlPropertyValue defValue)
                           throws InvalidModelException
Description copied from interface: ModalPropertyValueAccumulator
Accumulate a default value. The value of the accumulator may not be obtained until this method is called.

Specified by:
addDefaultValue in interface ModalPropertyValueAccumulator
Parameters:
defValue - The default property value.
Throws:
InvalidModelException - Thrown if the default property value cannot be added because the model is incomplete

addPropertyAssociations

public final java.util.Set addPropertyAssociations(PropertyHolder ph,
                                                   PropertyDefinition pn,
                                                   java.util.List compExistsInModes,
                                                   ModeContext modeContext)
                                            throws InvalidModelException
Description copied from interface: ModalPropertyValueAccumulator
Accumulate the associations for the given property as found in the immediate properties attribute of the given property holder.

Specified by:
addPropertyAssociations in interface ModalPropertyValueAccumulator
Parameters:
ph - The property holder whose properties attribute is of interest
pn - The property definition
compExistsInModes - The modes in which the element that the properties are associated with exist. This is a superset of the modes that the property association might exist for. May be null if the properties are not associated with a sub element of a component implementation.
modeContext - An abstraction of the model element whose modes are the domain for this assocation.
Returns:
The set of property associations actually accumulated.
Throws:
InvalidModelException - Thrown if the properties clause of given property holder is incomplete.

addPropertyAssociations

public java.util.Set addPropertyAssociations(PropertyHolder ph,
                                             PropertyDefinition pn)
                                      throws InvalidModelException
Description copied from interface: ModalPropertyValueAccumulator
Accumulate the associations for the given property as found in the immediate properties attribute of the given property holder. This version is specialized for properties of elements that cannot be affected by modes (i.e., features of component types, port group types, modes themselves, and package sections).

Specified by:
addPropertyAssociations in interface ModalPropertyValueAccumulator
Parameters:
ph - The property holder whose properties attribute is of interest
pn - The property definition
Returns:
The set of property associations actually accumulated.
Throws:
InvalidModelException - Thrown if the properties clause of given property holder is incomplete.

addLocalContainedPropertyAssociations

public final java.util.Set addLocalContainedPropertyAssociations(PropertyHolder target,
                                                                 PropertyHolder container,
                                                                 PropertyDefinition pn,
                                                                 java.util.List targetExistsInModes,
                                                                 ModeContext modeContext)
                                                          throws InvalidModelException
Description copied from interface: ModalPropertyValueAccumulator
Accumulate the associations for the given property as found in the contained property associations of the target's containing component. Considers the contained property associations whose applies to list is of length 1, and that element is the target property holder.

Specified by:
addLocalContainedPropertyAssociations in interface ModalPropertyValueAccumulator
Parameters:
target - The property holder whose property values are being looked up
container - The containing component of target, whose contained property associations are of interest.
pn - The property definition
targetExistsInModes - The modes in which target exists. This is a superset of the modes that the property association might exist for. May be null if the properties are not associated with a sub element of a component implementation.
modeContext - An abstraction of the model element whose modes are the domain for this assocation.
Returns:
The set of property associations actually accumulated.
Throws:
InvalidModelException - Thrown if the properties clause of given property holder is incomplete.

addLocalContainedPropertyAssociations

public java.util.Set addLocalContainedPropertyAssociations(PropertyHolder target,
                                                           PropertyHolder container,
                                                           PropertyDefinition pn)
                                                    throws InvalidModelException
Description copied from interface: ModalPropertyValueAccumulator
Accumulate the associations for the given property as found in the contained property associations of the target's containing component. Considers the contained property associations whose applies to list is of length 1, and that element is the target property holder. This version is specialized for properties of elements that cannot be affected by modes (i.e., features of component types, port group types, modes themselves, and package sections).

Specified by:
addLocalContainedPropertyAssociations in interface ModalPropertyValueAccumulator
Parameters:
target - The property holder whose property values are being looked up
container - The containing component of target, whose contained property associations are of interest.
pn - The property definition
Returns:
The set of property associations actually accumulated.
Throws:
InvalidModelException - Thrown if the properties clause of given property holder is incomplete.

createModalAssociations

protected abstract ModalPropertyValueAccumulatorImpl.ModalAssociations createModalAssociations(PropertyHolder ph,
                                                                                               java.util.List inModes)

createModalAssociations

protected abstract ModalPropertyValueAccumulatorImpl.ModalAssociations createModalAssociations(PropertyHolder ph)

fixModeContext

protected abstract ModeContext fixModeContext(ModeContext mc)
Given a mode context from an element along the lookup path, convert it to be compatible with the context (propHolder) of the current property lookup.

Parameters:
mc - The input mode context; non-null.
Returns:
The "fixed" mode context; non-null.

isModal

public final boolean isModal()
Description copied from interface: ModalPropertyValue
Query if the property value may depend on modes. Currently, this is equivalent to checking if the set returned by ModalPropertyValue.getModeContexts() is not empty.

Specified by:
isModal in interface ModalPropertyValue
Returns:
true iff the propery value depends on modes.

getModeContexts

public final java.util.Set getModeContexts()
Description copied from interface: ModalPropertyValue
Get the components whose modes may affect this value.

Specified by:
getModeContexts in interface ModalPropertyValue
Returns:
An immutable set of ModeContext objects.

getModeContextsAsArray

public final ModeContext[] getModeContextsAsArray()
Description copied from interface: ModalPropertyValue
Get the components whose modes may affect this value.

Specified by:
getModeContextsAsArray in interface ModalPropertyValue
Returns:
A fresh array containing the objects.

getValue

public final AadlPropertyValue getValue()
                                 throws InvalidModelException
Description copied from interface: ModalPropertyValue
Get the property value in the empty mode context.

Specified by:
getValue in interface ModalPropertyValue
Returns:
The property value in the given modes.
Throws:
InvalidModelException - thrown if an error in the model prevents the successful lookup of the property value. This exception is primarily of interest to the OSATE implementation which catches it during certain operations to report that the model has errors. (There are a few cases where the error can only be detected by looking up the property value.)

getValue

public final AadlPropertyValue getValue(java.util.Map modes)
                                 throws InvalidModelException
Description copied from interface: ModalPropertyValue
Get the property value based on the given mode settings.

Specified by:
getValue in interface ModalPropertyValue
Parameters:
modes - The mode settings to use as a map from ModeContext objects to Mode objects. The domain of the mapping is given by the ModalPropertyValue.getModeContexts() method.
Returns:
The property value in the given modes.
Throws:
InvalidModelException - thrown if an error in the model prevents the successful lookup of the property value. This exception is primarily of interest to the OSATE implementation which catches it during certain operations to report that the model has errors. (There are a few cases where the error can only be detected by looking up the property value.)

getAllModeBindings

public final java.util.Collection getAllModeBindings()
Description copied from interface: ModalPropertyValue
Get all the mode contexts that are applicable to this value. This is derived from the components returned by ModalPropertyValue.getModeContexts().

Specified by:
getAllModeBindings in interface ModalPropertyValue
Returns:
A collection of Maps, enumerating all the possible combinations of modes that apply to the lookup of the value.

getAllValues

public final java.util.Collection getAllValues()
                                        throws InvalidModelException
Description copied from interface: ModalPropertyValue
Get all the values the property value could have.

Specified by:
getAllValues in interface ModalPropertyValue
Returns:
A collection of ReflectiveAadlPropertyValue objects, one for each valid combination of modes as determined by the mode contexts.
Throws:
InvalidModelException - thrown if an error in the model prevents the successful lookup of the property value. This exception is primarily of interest to the OSATE implementation which catches it during certain operations to report that the model has errors. (There are a few cases where the error can only be detected by looking up the property value.)