fr.tpt.aadl.annex.behavior.utils
Class AadlBaUtils

java.lang.Object
  extended by fr.tpt.aadl.annex.behavior.utils.AadlBaUtils

public class AadlBaUtils
extends java.lang.Object

A collection of static utils methods.


Field Summary
static java.lang.String STRING_NAME_SEPARATOR
          String separator for a component reference name.
 
Constructor Summary
AadlBaUtils()
           
 
Method Summary
static boolean compareBehaviorTransitionPriority(BehaviorTransition bt1, BehaviorTransition bt2)
          Compares behavior transition priorities.
static
<T extends BehaviorNamedElement>
T
compareNamedElementList(java.lang.String name, org.eclipse.emf.common.util.EList<T> lbne)
          Compare a given name to a given list of behavior named elements.
static org.osate.aadl2.Classifier componentPrototypeResolver(org.osate.aadl2.ComponentPrototype prototype, org.osate.aadl2.ComponentClassifier baParentContainer)
          Resolves the given component prototype by returning the binded classifier or if there is no binded classifier, the constraining classifier.
static java.util.Comparator<BehaviorTime> createBehaviorTimeComparator()
          Create a behavior time comparator.
static org.osate.aadl2.ClassifierValue getBaseType(org.osate.aadl2.Classifier component)
          Returns the last value of the base type property of the given component or null if the base type property is not set.
static BehaviorFeatureType getBehaviorAnnexFeatureType(BehaviorElement el)
          Analyze the given behavior annex feature and returns its type.
static org.osate.aadl2.Classifier getClassifier(org.osate.aadl2.Element el, org.osate.aadl2.ComponentClassifier baParentContainer)
          Returns the given Element object's classifier.
static FeatureType getCompPrototypeType(org.osate.aadl2.ComponentPrototypeBinding cpb)
          Translates the given ComponentPrototypeBinding object into a FeatureType enumeration.
static java.lang.String getDataAccessRight(Target tar)
          If the given Target object is a DataAccessHolder object or a DataComponentReference object which first element is a DataAccessHolder object, it returns the data access right or null if the default data access right is not set.
static org.osate.aadl2.DataClassifier getDataClassifier(Value v)
          Returns the DataClassifier of the element binded to the given Value object.
static DataRepresentation getDataRepresentation(BehaviorPropertyConstant pc)
          Returns the data representation associated to the given BehaviorPropertyConstant object

Note : getDataRepresentation(PropertyType) to see restrictions.
static DataRepresentation getDataRepresentation(BehaviorPropertyValue pv)
          Returns the data representation associated to the given BehaviorPropertyValue object

Note : getDataRepresentation(PropertyType) to see restrictions.
static DataRepresentation getDataRepresentation(BehaviorVariable bv)
          Returns the data representation of the given BehaviorVariable object or DataRepresentation.UNKNOWN if Data_Model::Data_Representation property is not set or if the BehaviorVariable object represents a data structure.
static DataRepresentation getDataRepresentation(org.osate.aadl2.DataClassifier c)
          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.
static DataRepresentation getDataRepresentation(org.osate.aadl2.PropertyType type)
          Returns the data representation associated to the given PropertyType object.
static DataRepresentation getDataRepresentation(Value v)
          Returns the data representation associated to the given Value object.
static DataRepresentation getDataRepresentation(ValueConstant v)
          Returns the data representation associated to the given ValueConstant object

Note : getDataRepresentation(PropertyType) to see restrictions on property constant and value.
static DataRepresentation getDataRepresentation(ValueVariable v)
          Returns the data representation of the given ValueVariable object or DataRepresentation.UNKNOWN if Data_Model::Data_Representation property is not set or if the ValueVariable object represents a data structure.
static org.osate.aadl2.DirectionType getDirectionType(Target tar)
          Returns the direction type of the object binded to the given Target or null if the binded object is not an instance of :
_ DirectedFeature.
static FeatureType getFeatPrototypeType(org.osate.aadl2.FeaturePrototypeBinding fpb)
          Translates the given FeaturePrototypeBinding object into a FeatureType enumeration.
static FeatureType getFeatureType(org.osate.aadl2.Element el)
          Analyze the given AADL Osate element and return its enumeration type.
static java.lang.String getName(org.osate.aadl2.ModeTransitionTrigger mtt)
          Returns the name of the given ModeTransitionTrigger object.
static fr.tpt.aadl.annex.behavior.analyzers.TypeHolder getTypeHolder(org.osate.aadl2.Element el)
          Returns the TypeHolder (data representation and component's DataClassifier if any) of the given Element object.
static java.lang.String identifierListToString(org.eclipse.emf.common.util.EList<BehaviorState> bsl, java.lang.String separator)
          Constructs a string base on the name of the given behavior states list, separated by the given separator symbol.
static Value isOnlyOneValue(ValueExpression ve)
          If the given value expression is composed of an single value, it returns this value otherwise null.
static boolean isSameTarget(Target tar0, Target tar1)
          Compare the given Target objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_NAME_SEPARATOR

public static final java.lang.String STRING_NAME_SEPARATOR
String separator for a component reference name.

See Also:
Constant Field Values
Constructor Detail

AadlBaUtils

public AadlBaUtils()
Method Detail

getDataRepresentation

public static DataRepresentation getDataRepresentation(org.osate.aadl2.DataClassifier c)
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.

Parameters:
c - the given data classifier
Returns:
the data representation or DataRepresentation.UNKNOWN

getDataRepresentation

public static DataRepresentation getDataRepresentation(BehaviorVariable bv)
Returns the data representation of the given BehaviorVariable object or DataRepresentation.UNKNOWN if Data_Model::Data_Representation property is not set or if the BehaviorVariable object represents a data structure.

Parameters:
bv - the given BehaviorVariable object
Returns:
the data representation or DataRepresentation.UNKNOWN

getDataRepresentation

public static DataRepresentation getDataRepresentation(org.osate.aadl2.PropertyType type)
Returns the data representation associated to the given PropertyType object.

Note : this method doesn't support the following property types :
_ ClassifierType
_ EnumerationType
_ NumberType
_ RangeType
_ RecordType
_ ReferenceType
_ UnitsType

Parameters:
type - the given PropertyType object.
Returns:
the data representation associated to the given PropertyType object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getDataRepresentation

public static DataRepresentation getDataRepresentation(BehaviorPropertyConstant pc)
Returns the data representation associated to the given BehaviorPropertyConstant object

Note : getDataRepresentation(PropertyType) to see restrictions.

Parameters:
pc - the given BehaviorPropertyConstant object
Returns:
the data representation associated to the given BehaviorPropertyConstant object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getDataRepresentation

public static DataRepresentation getDataRepresentation(BehaviorPropertyValue pv)
Returns the data representation associated to the given BehaviorPropertyValue object

Note : getDataRepresentation(PropertyType) to see restrictions.

Parameters:
pv - the given BehaviorPropertyValue object
Returns:
the data representation associated to the given BehaviorPropertyValue object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getDataRepresentation

public static DataRepresentation getDataRepresentation(ValueConstant v)
Returns the data representation associated to the given ValueConstant object

Note : getDataRepresentation(PropertyType) to see restrictions on property constant and value.

Parameters:
v - the given ValueConstant object
Returns:
the data representation associated to the given ValueConstant object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getDataRepresentation

public static DataRepresentation getDataRepresentation(ValueVariable v)
Returns the data representation of the given ValueVariable object or DataRepresentation.UNKNOWN if Data_Model::Data_Representation property is not set or if the ValueVariable object represents a data structure.

Parameters:
v - the given ValueVariable object
Returns:
the data representation or DataRepresentation.UNKNOWN

getDataRepresentation

public static DataRepresentation getDataRepresentation(Value v)
Returns the data representation associated to the given Value object. or DataRepresentation.UNKNOWN if Data_Model::Data_Representation property is not set or if the Value object represents a data structure.

Note : getDataRepresentation(PropertyType) to see restrictions on property constant and value.

Parameters:
v - the given Value object
Returns:
the data representation associated to the given Value object or DataRepresentation.UNKNOWN
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

identifierListToString

public static java.lang.String identifierListToString(org.eclipse.emf.common.util.EList<BehaviorState> bsl,
                                                      java.lang.String separator)
Constructs a string base on the name of the given behavior states list, separated by the given separator symbol.

Parameters:
bsl - the given behavior states list
separator - the name separator symbol
Returns:
the string build on the given behavior state's names and given separator

getClassifier

public static org.osate.aadl2.Classifier getClassifier(org.osate.aadl2.Element el,
                                                       org.osate.aadl2.ComponentClassifier baParentContainer)
Returns the given Element object's classifier. If the Element object is a prototype, it will try to resolve it as follow: returns the data prototype binded classifier at first otherwise the constraining classifier. It returns null if the prototype is not defined.

This method support instances of:

_Feature (port, data access, subprogram access, parameter, etc.)
_Subcomponent (data subcomponent, subprogram subcomponent, etc.)
_BehaviorVariable
_IterativeVariable (for/forall's iterative variable)
_Prototype (all excepted FeatureGroupPrototype)
_PrototypeBinding (all excepted FeatureGroupPrototypeBinding)
_ClassifierValue (struct or union data subcomponent)

If the given Element object is not one of those types, an UnsupportedOperationException is thrown.

Parameters:
el - the given Element object
baParentContainer - the ba's parent component.
Returns:
the given element's classifier or null if the prototype is not defined
Throws:
java.lang.UnsupportedOperationException - for unsupported element object types.

componentPrototypeResolver

public static org.osate.aadl2.Classifier componentPrototypeResolver(org.osate.aadl2.ComponentPrototype prototype,
                                                                    org.osate.aadl2.ComponentClassifier baParentContainer)
Resolves the given component prototype by returning the binded classifier or if there is no binded classifier, the constraining classifier. It returns null if the given component prototype is not defined.

Parameters:
prototype - the given component prototype
baParentContainer - the ba's parent component
Returns:
the binded classifier at first then the constraining classifier or null

getDataClassifier

public static org.osate.aadl2.DataClassifier getDataClassifier(Value v)
Returns the DataClassifier of the element binded to the given Value object. A target instance can be given to this method as Target instance can be cast into ValueVariable reference.

Notes:


_ ValueVariable : getClassifier(Element, ComponentClassifier) to see the restrictions.
_ ValueConstant : only BehaviorEnumerationLiteral has a data classifier. the others value constants return null.

Parameters:
v - the given Value object
Returns:
the binded component's DataClassifier object or null for the ValueConstant objects (excepted BehaviorEnumerationLiteral object)
Throws:
java.lang.UnsupportedOperationException - for unsupported binded object types.

getTypeHolder

public static fr.tpt.aadl.annex.behavior.analyzers.TypeHolder getTypeHolder(org.osate.aadl2.Element el)
                                                                     throws DimensionException
Returns the TypeHolder (data representation and component's DataClassifier if any) of the given Element object.

For now, only the following objects are supported:

_ IterativeVariable
_ DataClassifier
_ Target
_ Value

Parameters:
el - the given Element object.
Returns:
the type holder of the given Element object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types or Element instances.
DimensionException - in any case of array dimension overflow.

compareNamedElementList

public static <T extends BehaviorNamedElement> T compareNamedElementList(java.lang.String name,
                                                                         org.eclipse.emf.common.util.EList<T> lbne)
Compare a given name to a given list of behavior named elements. The matching is base on behavior named element's name (case insensitive).

Parameters:
bne - the given name
lbne - the given list of behavior named elements
Returns:
the first behavior named element form the given list which has the same name as the given name. null otherwise

isSameTarget

public static boolean isSameTarget(Target tar0,
                                   Target tar1)
Compare the given Target objects.

This comparator is base on name and not on object's hash number, meaning that two different Target instances with the same name are considered as equals. This comparator doesn't support array indexes comparison, meaning that two target instances with the same name and different array indexes are considered as equals.

Parameters:
tar0 - the first name
tar1 - the second name
Returns:
true if the given Target objects are the same. Otherwise returns false

createBehaviorTimeComparator

public static java.util.Comparator<BehaviorTime> createBehaviorTimeComparator()
Create a behavior time comparator.

This comparator supports time units (from AADL property set Time_Units) comparison. For example, comparing 60 sec and 1 min returns 0.

It only supports behavior time objects with integer constant literal. Otherwise it throws a ClassCastException.

Returns:
a behavior time comparator
Throws:
java.lang.UnsupportedOperationException - if behavior time objects are not integer constant literal

getFeatureType

public static FeatureType getFeatureType(org.osate.aadl2.Element el)
Analyze the given AADL Osate element and return its enumeration type. It's an improved version of Osate2 org.osate.parser.AadlSemanticCheckSwitch#getFeatureType

Parameters:
el - the given AADL Osate element
Returns:
the given AADL Osate element's type
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getBehaviorAnnexFeatureType

public static BehaviorFeatureType getBehaviorAnnexFeatureType(BehaviorElement el)
Analyze the given behavior annex feature and returns its type.

Parameters:
el - the given behavior annex feature
Returns:
the given behavior annex feature's type
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

isOnlyOneValue

public static Value isOnlyOneValue(ValueExpression ve)
If the given value expression is composed of an single value, it returns this value otherwise null. Recursive method.

Parameters:
ve - the given value expression
Returns:
the value or null

getCompPrototypeType

public static FeatureType getCompPrototypeType(org.osate.aadl2.ComponentPrototypeBinding cpb)
Translates the given ComponentPrototypeBinding object into a FeatureType enumeration.

Parameters:
fpb - the given ComponentPrototypeBinding
Returns:
the translation in FeatureType object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getFeatPrototypeType

public static FeatureType getFeatPrototypeType(org.osate.aadl2.FeaturePrototypeBinding fpb)
Translates the given FeaturePrototypeBinding object into a FeatureType enumeration.

Parameters:
fpb - the given FeaturePrototypeBinding
Returns:
the translation in FeatureType object
Throws:
java.lang.UnsupportedOperationException - for the unsupported types

getBaseType

public static org.osate.aadl2.ClassifierValue getBaseType(org.osate.aadl2.Classifier component)
Returns the last value of the base type property of the given component or null if the base type property is not set.

Parameters:
component - the given component
Returns:
the last value of the base type property or null

getDirectionType

public static org.osate.aadl2.DirectionType getDirectionType(Target tar)
Returns the direction type of the object binded to the given Target or null if the binded object is not an instance of :
_ DirectedFeature.
_ Data subcomponent.
_ Local variable.
(see getDirectionType(org.osate.aadl2.Element)).

Notes: _ Behavior variable always returns DirectionType.IN_OUT as behavior variable is a valid Target and ValueVariable. _ Iterative variable always returns DirectionType.IN as iterative variables is a valid value variable but not a target. _ Data subcomponent always returns DirectionType.IN_OUT as data subcomponent is valid Target and ValueVariable.

Parameters:
tar - the given Target
Returns:
the direction type or null

getDataAccessRight

public static java.lang.String getDataAccessRight(Target tar)
If the given Target object is a DataAccessHolder object or a DataComponentReference object which first element is a DataAccessHolder object, it returns the data access right or null if the default data access right is not set. Else it returns null.

Parameters:
tar - the given Target object
Returns:
the data access right or null
See Also:
Aadl2Utils.getAccessRight

getName

public static java.lang.String getName(org.osate.aadl2.ModeTransitionTrigger mtt)
Returns the name of the given ModeTransitionTrigger object.

Parameters:
mtt - the given ModeTransitionTrigger object
Returns:
a name

compareBehaviorTransitionPriority

public static boolean compareBehaviorTransitionPriority(BehaviorTransition bt1,
                                                        BehaviorTransition bt2)
Compares behavior transition priorities. Returns true if bt1 priority is > bt2 or bt2 has otherwise execution condition and bt1 hasn't. Otherwise returns false.

Parameters:
bt1 - a behavior transition
bt2 - an other behavior transition
Returns:
true if bt1 priority is > bt2 or bt2 has otherwise execution condition and bt1 hasn't. Otherwise false.