public abstract class AbstractTypeChecker<C,O,P,PM> extends Object implements TypeChecker<C,O,P>
Implementation of the TypeChecker interface which offers the default
implementation for the type checking system. This class encapsulates the
behaviour of the 1.2 release's TypeUtil class, in an extensible unit.
This class is not intended to be extended by clients. They should extend
AbstractTypeResolver instead, so that TypeChecker can be
successfully adapted by AbstractEnvironment. However, if an already
implemented TypeResolver wants to exploit the type checking system
extensibility, it may extend this class.
See Environment for generic parameters description
AbstractTypeResolver,
TypeUtil| Constructor and Description |
|---|
AbstractTypeChecker(Environment<?,C,O,P,?,PM,?,?,?,?,?,?> env)
Initializes me with my environment.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkMutuallyComparable(Object problemObject,
C type1,
C type2,
int opcode)
Checks whether two types are mutually comparable in the determination of
the applicability of = and <> operations.
|
protected CollectionKind |
commonSuperType(CollectionKind kind1,
CollectionKind kind2)
Common-supertype helper method for collection kinds
|
C |
commonSuperType(Object problemObject,
C type1,
C type2)
Get the common supertype of two types.
|
boolean |
compatibleTypeMatch(C type1,
C type2)
Compare two types.
|
boolean |
exactTypeMatch(C type1,
C type2)
Compare two types.
|
P |
findAttribute(C owner,
String name)
Finds the most specific (re)definition of an attribute in the specified
classifier.
|
O |
findOperationMatching(C owner,
String name,
List<? extends TypedElement<C>> args)
Finds an operation by signature in the specified classifier.
|
C |
findSignalMatching(C receiver,
List<C> signals,
String name,
List<? extends TypedElement<C>> args)
Find a matching signal in the specified list.
|
List<P> |
getAttributes(C owner)
Obtains all of the OCL attributes applicable to the specified owner type,
including any that were defined in the OCL environment as additional
attributes.
|
protected Environment<?,C,O,P,?,PM,?,?,?,?,?,?> |
getEnvironment()
Obtains my OCL parsing environment.
|
protected OCLFactory |
getOCLFactory()
Obtains the OCL factory that I use to instantiate the OCL Abstract
Syntax.
|
List<O> |
getOperations(C owner)
Obtains all of the OCL operations applicable to the specified owner type,
including any that were defined in the OCL environment as additional
operations.
|
C |
getPropertyType(C owner,
P property)
Gets the type of a property, accounting for the fact that we may be
navigating to it from an association class (in which the member ends of
an association always have multiplicity 1) or not.
|
int |
getRelationship(C type1,
C type2)
Queries the relationship, according to generalizations, of two types.
|
protected int |
getRelationship(CollectionKind kind1,
CollectionKind kind2)
Get-relationship helper comparing collection kinds.
|
C |
getResultType(Object problemObject,
C owner,
O operation,
List<? extends TypedElement<C>> args)
Obtains the effective result type of the specified operation, which may
or may not have parameters type by generic type variables.
|
protected UMLReflection<?,C,O,P,?,PM,?,?,?,?> |
getUMLReflection()
Obtains the UML introspector that I use to access the subject model.
|
boolean |
isStandardLibraryFeature(C owner,
Object feature)
Queries whether the specified feature (operation or attribute), as
applied to a particular owner classifier, is defined by the
standard library or not (in which case it would, presumably, be
user-defined).
|
boolean |
matchArgs(C owner,
List<?> paramsOrProperties,
List<? extends TypedElement<C>> args)
Compares an actual argument list against the signature of an operation or
a signal.
|
protected abstract C |
resolve(C type)
Resolves the specified template of a demand-created type to one that is
already defined in the current environment, or else a new one or even the
given type (which would usually then be added to the environment).
|
protected abstract CollectionType<C,O> |
resolveCollectionType(CollectionKind kind,
C elementType)
Resolves the specified collection type to a collection type already
available in the current environment, or else a new one.
|
O |
resolveGenericSignature(C owner,
O oper)
Resolves the signature of a generic operation (where it has parameters of
type and/or T or T2) against the source type of the
operation, as appropriate.
|
protected C |
resolveGenericType(C owner,
C paramType,
C argType)
Resolves the generic type of an operation parameter (where it is
T or T2) against the source type of the operation or
the type of the actual argument, as appropriate.
|
protected abstract TupleType<O,P> |
resolveTupleType(<any> parts)
Resolves the specified signature of tuple parts to a tuple type already
available in the current environment, or else a new one.
|
public AbstractTypeChecker(Environment<?,C,O,P,?,PM,?,?,?,?,?,?> env)
env - my environmentprotected Environment<?,C,O,P,?,PM,?,?,?,?,?,?> getEnvironment()
protected UMLReflection<?,C,O,P,?,PM,?,?,?,?> getUMLReflection()
protected OCLFactory getOCLFactory()
public int getRelationship(C type1, C type2)
TypeCheckerUMLReflection.getRelationship(Object, Object)
method does not.getRelationship in interface TypeChecker<C,O,P>type1 - a typetype2 - another typeUMLReflection
interfaceUMLReflection.getRelationship(Object, Object)protected int getRelationship(CollectionKind kind1, CollectionKind kind2)
public C getResultType(Object problemObject, C owner, O operation, List<? extends TypedElement<C>> args)
TypeCheckergetResultType in interface TypeChecker<C,O,P>problemObject - the context object on which to report any problem that we may
find in computing the result type. Usually this is some
abstract or concrete syntax tree nodeowner - the owner of the operation (type on which the operation is
called)operation - the operation signatureargs - the arguments of the operation call, which are expressions or
variablespublic C getPropertyType(C owner, P property)
TypeCheckergetPropertyType in interface TypeChecker<C,O,P>owner - the source of the navigation of the property, which may be an
association class (the interesting scenario)property - the property to navigatepublic C commonSuperType(Object problemObject, C type1, C type2)
UMLReflection.getCommonSuperType(Object, Object) method does not.commonSuperType in interface TypeChecker<C,O,P>type1 - a typetype2 - another typeproblemObject - the object which could have problems.UMLReflection.getCommonSuperType(Object, Object)protected CollectionKind commonSuperType(CollectionKind kind1, CollectionKind kind2)
public boolean checkMutuallyComparable(Object problemObject, C type1, C type2, int opcode)
TypeCheckercheckMutuallyComparable in interface TypeChecker<C,O,P>problemObject - the object which could have problems.type1 - a typetype2 - another typeopcode - the operation codepublic boolean exactTypeMatch(C type1, C type2)
TypeCheckerexactTypeMatch in interface TypeChecker<C,O,P>type1 - a typetype2 - another typepublic boolean compatibleTypeMatch(C type1, C type2)
TypeCheckercompatibleTypeMatch in interface TypeChecker<C,O,P>type1 - a typetype2 - another typepublic List<O> getOperations(C owner)
TypeCheckergetOperations in interface TypeChecker<C,O,P>owner - the operation owner typepublic P findAttribute(C owner, String name)
findAttribute in interface TypeChecker<C,O,P>owner - the classifier to searchname - the name of the operationnull if not foundpublic List<P> getAttributes(C owner)
TypeCheckergetAttributes in interface TypeChecker<C,O,P>owner - the attribute owner typepublic O resolveGenericSignature(C owner, O oper)
TypeCheckerresolveGenericSignature in interface TypeChecker<C,O,P>owner - the operation source typeoper - the generic operationprotected C resolveGenericType(C owner, C paramType, C argType)
env - the OCL environmentowner - the operation source typeparamType - the operation parameter typeargType - the actual operation argument typepublic boolean matchArgs(C owner, List<?> paramsOrProperties, List<? extends TypedElement<C>> args)
TypeCheckermatchArgs in interface TypeChecker<C,O,P>owner - the type that owns the operationparamsOrProperties - the operation parameters or signal attributes to match against
the argumentsargs - a list of OCLExpressions or Variablespublic C findSignalMatching(C receiver, List<C> signals, String name, List<? extends TypedElement<C>> args)
TypeCheckerfindSignalMatching in interface TypeChecker<C,O,P>receiver - the type that receives the signalsignals - the signals to searchname - name of signal to findargs - list of arguments to match against the signal signaturenull if not foundpublic O findOperationMatching(C owner, String name, List<? extends TypedElement<C>> args)
TypeCheckerfindOperationMatching in interface TypeChecker<C,O,P>owner - the classifier to searchname - the name of the operationargs - a list of arguments to match against the operation signature,
as either expressions or variablesnull if not foundpublic boolean isStandardLibraryFeature(C owner, Object feature)
TypeCheckerisStandardLibraryFeature in interface TypeChecker<C,O,P>owner - a classifier on which a feature is to be accessedfeature - the feature to be accessedprotected abstract TupleType<O,P> resolveTupleType(<any> parts)
parts - specification of the tuple type signatureprotected abstract CollectionType<C,O> resolveCollectionType(CollectionKind kind, C elementType)
kind - the kind of collection type to obtainelementType - the element type of the requisite collection typeprotected abstract C resolve(C type)
type - the template/prototype/example of a type to resolve in the
current environmentCopyright © 2015 Open eHealth Foundation. All rights reserved.