de.tuberlin.cs.cis.ocl.example.check
Class StateModel

java.lang.Object
  |
  +--de.tuberlin.cs.cis.ocl.example.check.StateModel
All Implemented Interfaces:
ClassifierDescriptor, TypeFacade

public class StateModel
extends java.lang.Object
implements TypeFacade, ClassifierDescriptor

Implements an arbitrary model whose types uses a state machine as defined in OCL 1.5 - 6.5.10 Predefined properties on All Objects. The types of this model are featureless.

Author:
fchabar
See Also:
OCL 1.5 Standard

Constructor Summary
StateModel()
           
 
Method Summary
 TypedAssociation getAssociation(java.lang.String assocName, Type[] qualifiers)
          Resolves and returns the specified association qualifiable by the specified qualifier parameters on this type.
 TypedProperty getAttribute(java.lang.String attrName, boolean classScoped)
          Resolves and returns the specified attribute on this type.
 ClassifierDescriptor getClassifier(java.lang.String qualifiedName)
          Returns the type described by its name (primarily through its qualified name).
 java.lang.String getName()
          Returns the name of the type.
 Classifier getOclSupertype()
          Returns the predefined OCL 1.5 supertype of this type.
 TypedProperty getOperation(java.lang.String operationName, ClassifierDescriptor[] params, boolean classScoped)
          Resolves and returns the specified operation on this type.
 boolean isStateDefined(java.lang.String state)
          Returns true if the specified state is defined on the statemachine attached to this type.
 boolean isSubtypeOf(ClassifierDescriptor modelType)
          Returns true if this type is a subtype of the specified type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.tuberlin.cs.cis.ocl.model.check.ClassifierDescriptor
equals
 

Constructor Detail

StateModel

public StateModel()
Method Detail

getClassifier

public ClassifierDescriptor getClassifier(java.lang.String qualifiedName)
                                   throws UndefinedTypeException
Description copied from interface: TypeFacade
Returns the type described by its name (primarily through its qualified name). This method is called each time the context checker has to resolve a type from the model. The name of the type is directly derived from OCL- constraints. The OCL Type Checker tries to resolve the type both: qualified and unqualified. A type may be a classifier or especially an enumeration type.

Specified by:
getClassifier in interface TypeFacade
Parameters:
qualifiedName - The name of the model type to resolve. Namespaces of qualified names are seperated through '::'. A utility class to transform qualified names into java.util.Lists or to change the seperator (to be specific '.') is provided QualifiedName.
Returns:
The type specified through the qualified name.
Throws:
UndefinedTypeException - if the type is undefined in the model.

getAttribute

public TypedProperty getAttribute(java.lang.String attrName,
                                  boolean classScoped)
                           throws UndefinedFeatureException
Description copied from interface: ClassifierDescriptor
Resolves and returns the specified attribute on this type. The attribute is specified via its name.

Specified by:
getAttribute in interface ClassifierDescriptor
Parameters:
attrName - the name of the attribute
classScoped - true if the attribute is called on the classifier itself.
Returns:
the attribute on this type.
Throws:
UndefinedFeatureException - if the attribute is not defined on this type.

getName

public java.lang.String getName()
Description copied from interface: ClassifierDescriptor
Returns the name of the type. The name is mainly used for feedback purposes. It is recommanded to specify the name qualified.

Specified by:
getName in interface ClassifierDescriptor
Returns:
the name of the type.

getOclSupertype

public Classifier getOclSupertype()
Description copied from interface: ClassifierDescriptor
Returns the predefined OCL 1.5 supertype of this type. Within the OCL 1.5 context, the type OclAny is the supertype of all types in the model. Thus each subtype of OclAny and OclAny itself can be the predefined supertype of this type (that is Boolean, Integer, Real, String, Enumeration and OclState; the type OclExpression is not supported). The declaration of the predefined supertype will then be used to continue the conformance hierarchy within OCL.

Note: Virtually the predefined supertype is used to import each model type into the OCL context. Especially the model primitive types should extend its natural supertype in order to use the OCL-functionality in its full extents.

Example (from OCL 1.5 - 6.2.2 Example Class Diagram): context Company inv:
  self.numberOfEmployees > 50

1) The UML-Type Integer does not extend the predefined type Integer: The expression self.numberOfEmployees would result in an UML-Integer. Sinse neither the UML-Integer nor its supertype OclAny define the Operation >(UML-Integer, OCL-Integer), the expression would be undefined.

2) The UML-Type Integer extends the predefined type Integer: The same expression would result in an UML-Integer that inherits the operation >(OCL-Integer, OCL-Integer). Sinse the UML-Integer would be a subtype of OCL-Integer, the operation would result in the expected OCL-Boolean.

Specified by:
getOclSupertype in interface ClassifierDescriptor
Returns:
the predefined supertype of this model type in order to import the model type into the OCL context.

getOperation

public TypedProperty getOperation(java.lang.String operationName,
                                  ClassifierDescriptor[] params,
                                  boolean classScoped)
                           throws UndefinedFeatureException
Description copied from interface: ClassifierDescriptor
Resolves and returns the specified operation on this type. The operation is specified via its name, its paremeter and if its classifier scoped or not. The identity and equality of operations can be determined through the model implementor. It is assumed that the model is self-contained. Thus the parmeters will all be model classifier.

Specified by:
getOperation in interface ClassifierDescriptor
Parameters:
operationName - the name of the operation.
params - the parameters of the operation.
classScoped - true if the operation is called on the classifier itself.
Returns:
the specified operation.
Throws:
UndefinedFeatureException - if the operation could not be resolved on this type.

isStateDefined

public boolean isStateDefined(java.lang.String state)
Description copied from interface: ClassifierDescriptor
Returns true if the specified state is defined on the statemachine attached to this type. The state will be used for the predefined Operation oclInState(OclState). The argument state will be represented as a String. The form of the String is described in the Standard itself.

Specified by:
isStateDefined in interface ClassifierDescriptor
Parameters:
state - a state of this type's statemachine.
Returns:
true if this type has at least one statemachine attached to itself which defines the specified state, false otherwise.

isSubtypeOf

public boolean isSubtypeOf(ClassifierDescriptor modelType)
Description copied from interface: ClassifierDescriptor
Returns true if this type is a subtype of the specified type. This relation will be used to build up a type conformance hierarchy within OCL, which will be used in either the type check (for example in oclAsType(OclType)) - and evaluation process (for example in oclIsKindOf(OclType)).

Specified by:
isSubtypeOf in interface ClassifierDescriptor
Parameters:
modelType - a possible supertype of the model.
Returns:
true if this type is a suptype of the specified type, otherwise false.

getAssociation

public TypedAssociation getAssociation(java.lang.String assocName,
                                       Type[] qualifiers)
                                throws UndefinedFeatureException
Description copied from interface: ClassifierDescriptor
Resolves and returns the specified association qualifiable by the specified qualifier parameters on this type. The association is specified via its role-name. The qualifiers can be used denotationally so that the type can also be predefined (for example an integer). If the qualifier is a model type the qualifiers will be instances of de.tuberlin.cs.cis.ocl.type.ModelType.

Specified by:
getAssociation in interface ClassifierDescriptor
Parameters:
assocName - the role-name of the association/navigation.
Returns:
the specified association
UndefinedFeatureException
See Also:
ModelType.isDescribedBy(ClassifierDescriptor)