org.eclipse.emf.ocl.types.impl
Class TypeUtil

java.lang.Object
  extended byorg.eclipse.emf.ocl.types.impl.TypeUtil

public class TypeUtil
extends java.lang.Object

Static utilities for introspecting OCL types.


Method Summary
static org.eclipse.emf.ecore.EClassifier commonSuperType(org.eclipse.emf.ecore.EClassifier type1, org.eclipse.emf.ecore.EClassifier type2)
          Get the common supertype of two types.
static org.eclipse.emf.ecore.EOperation defineOperation(org.eclipse.emf.ecore.EClassifier owner, java.lang.String name, org.eclipse.emf.common.util.EList params, org.eclipse.emf.ecore.EClassifier type)
           
static org.eclipse.emf.ecore.EStructuralFeature defineProperty(org.eclipse.emf.ecore.EClassifier owner, Variable variable)
           
static org.eclipse.emf.ecore.EOperation findOperationMatching(org.eclipse.emf.ecore.EClassifier owner, java.lang.String name, org.eclipse.emf.common.util.EList args)
          Find the operation in the specified classifier
static org.eclipse.emf.ecore.EClass findSignalMatching(org.eclipse.emf.ecore.EClassifier receiver, org.eclipse.emf.common.util.EList signals, java.lang.String name, org.eclipse.emf.common.util.EList args)
          Find a matching signal in the specified list.
static org.eclipse.emf.ecore.EClassifier getOCLCollectionType(org.eclipse.emf.ecore.EClassifier type, boolean isOrdered, boolean isUnique)
          Obtains the appropriate OCL collection type for an EClassifier, according to the collection's orderedness and uniqueness.
static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.EClassifier type)
          Obtains the appropriate OCL type for an EClassifier, if it corresponds to an OCL primitive type.
static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.ETypedElement typedElement)
          Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness.
static org.eclipse.emf.common.util.EList getOperations(org.eclipse.emf.ecore.EClassifier owner)
          Obtains all of the OCL operations applicable to the specified owner type.
static org.eclipse.emf.common.util.EList getProperties(org.eclipse.emf.ecore.EClassifier owner)
           
static int getRelationship(org.eclipse.emf.ecore.EClassifier type1, org.eclipse.emf.ecore.EClassifier type2)
          Computes the relationship between two types.
static org.eclipse.emf.ecore.EClassifier getResultType(org.eclipse.emf.ecore.EClassifier owner, org.eclipse.emf.ecore.EOperation oper)
           
static boolean isMany(org.eclipse.emf.ecore.ETypedElement typedElement)
          Custom is-many determination to assume that XSD unspecified multiplicities are many.
static void resolveAdditionalFeatures(org.eclipse.emf.ecore.EClassifier owner, Environment env)
           
static org.eclipse.emf.ecore.EOperation resolveGenericSignature(org.eclipse.emf.ecore.EClassifier owner, org.eclipse.emf.ecore.EOperation oper)
           
static org.eclipse.emf.ecore.EClassifier resolveType(Environment env, org.eclipse.emf.ecore.EClassifier type)
          Resolves the specified type against the model-based types defined by the specified environment's type resolver, for consistency with the environment (especially for persistence).
static boolean type1AsType2(org.eclipse.emf.ecore.EClassifier type1, org.eclipse.emf.ecore.EClassifier type2)
           
static int typeCompare(org.eclipse.emf.ecore.EClassifier type1, org.eclipse.emf.ecore.EClassifier type2)
          Compare 2 types.
static void undefineAdditionalFeatures(org.eclipse.emf.ecore.EClassifier owner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findOperationMatching

public static org.eclipse.emf.ecore.EOperation findOperationMatching(org.eclipse.emf.ecore.EClassifier owner,
                                                                     java.lang.String name,
                                                                     org.eclipse.emf.common.util.EList args)
Find the operation in the specified classifier

Parameters:
owner - EClassifier owning operations
name - name of operation
args - list of arguments to match against the operation signature
Returns:
the matching operation, or null if not found

findSignalMatching

public static org.eclipse.emf.ecore.EClass findSignalMatching(org.eclipse.emf.ecore.EClassifier receiver,
                                                              org.eclipse.emf.common.util.EList signals,
                                                              java.lang.String name,
                                                              org.eclipse.emf.common.util.EList args)
Find a matching signal in the specified list.

Parameters:
receiver - the type that receives the signal
signals - the signals to search
name - name of signal to find
args - list of arguments to match against the signal signature
Returns:
the matching signal, or null if not found

getOperations

public static org.eclipse.emf.common.util.EList getOperations(org.eclipse.emf.ecore.EClassifier owner)
Obtains all of the OCL operations applicable to the specified owner type.

Parameters:
owner - the operation owner type
Returns:
an unmodifiable list of its operations

getProperties

public static org.eclipse.emf.common.util.EList getProperties(org.eclipse.emf.ecore.EClassifier owner)

resolveGenericSignature

public static org.eclipse.emf.ecore.EOperation resolveGenericSignature(org.eclipse.emf.ecore.EClassifier owner,
                                                                       org.eclipse.emf.ecore.EOperation oper)

getResultType

public static org.eclipse.emf.ecore.EClassifier getResultType(org.eclipse.emf.ecore.EClassifier owner,
                                                              org.eclipse.emf.ecore.EOperation oper)

type1AsType2

public static boolean type1AsType2(org.eclipse.emf.ecore.EClassifier type1,
                                   org.eclipse.emf.ecore.EClassifier type2)
                            throws SemanticException
Throws:
SemanticException

typeCompare

public static int typeCompare(org.eclipse.emf.ecore.EClassifier type1,
                              org.eclipse.emf.ecore.EClassifier type2)
Compare 2 types. Returns 0 if types are exactly equal, -1 if type1 conforms to type2 (type1 is a subtype of type2) 1 if type2 conforms to type1 (type2 is a subtype of type1) Throws an IllegalArgumentException if there is no type conformance.

Parameters:
type1 - - EClassifier
type2 - - EClassifier
Returns:
the ordering key

commonSuperType

public static org.eclipse.emf.ecore.EClassifier commonSuperType(org.eclipse.emf.ecore.EClassifier type1,
                                                                org.eclipse.emf.ecore.EClassifier type2)
                                                         throws SemanticException
Get the common supertype of two types.

Parameters:
type1 -
type2 -
Returns:
the common supertype
Throws:
SemanticException

getRelationship

public static int getRelationship(org.eclipse.emf.ecore.EClassifier type1,
                                  org.eclipse.emf.ecore.EClassifier type2)
Computes the relationship between two types.

Parameters:
type1 - a type
type2 - another type
Returns:
either #UNRELATED_TYPE, #STRICT_SUBTYPE, #STRICT_SUPERTYPE, or #SAME_TYPE according to the relationship between the types

getOCLType

public static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.ETypedElement typedElement)
Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness. The mapping is as follows:

Parameters:
typedElement - the ECore typed element to get the OCL type for
Returns:
the corresponding OCL type
See Also:
TypeUtil.getOCLType(EClassifier), TypeUtil.getOCLCollectionType(EClassifier, boolean, boolean)

getOCLType

public static org.eclipse.emf.ecore.EClassifier getOCLType(org.eclipse.emf.ecore.EClassifier type)
Obtains the appropriate OCL type for an EClassifier, if it corresponds to an OCL primitive type.

Parameters:
type - the type to convert to an OCL type
Returns:
the corresponding OCL type

getOCLCollectionType

public static org.eclipse.emf.ecore.EClassifier getOCLCollectionType(org.eclipse.emf.ecore.EClassifier type,
                                                                     boolean isOrdered,
                                                                     boolean isUnique)
Obtains the appropriate OCL collection type for an EClassifier, according to the collection's orderedness and uniqueness. The mapping is as follows:

Note that the collection's element type is mapped to an OCL primitive type where possible.

Parameters:
type - the type to get the corresponding OCL collection type for
isOrdered - whether the OCL type should be ordered
isUnique - whether the OCL type should be unique
Returns:
the corresponding OCL type
See Also:
TypeUtil.getOCLType(EClassifier)

isMany

public static boolean isMany(org.eclipse.emf.ecore.ETypedElement typedElement)
Custom is-many determination to assume that XSD unspecified multiplicities are many.

Parameters:
typedElement - a typed element
Returns:
whether it is not definitely a scalar

resolveType

public static org.eclipse.emf.ecore.EClassifier resolveType(Environment env,
                                                            org.eclipse.emf.ecore.EClassifier type)
Resolves the specified type against the model-based types defined by the specified environment's type resolver, for consistency with the environment (especially for persistence).

Parameters:
env - the parser environment
type - the type to resolve
Returns:
the environment's corresponding type

defineProperty

public static org.eclipse.emf.ecore.EStructuralFeature defineProperty(org.eclipse.emf.ecore.EClassifier owner,
                                                                      Variable variable)

defineOperation

public static org.eclipse.emf.ecore.EOperation defineOperation(org.eclipse.emf.ecore.EClassifier owner,
                                                               java.lang.String name,
                                                               org.eclipse.emf.common.util.EList params,
                                                               org.eclipse.emf.ecore.EClassifier type)

undefineAdditionalFeatures

public static void undefineAdditionalFeatures(org.eclipse.emf.ecore.EClassifier owner)

resolveAdditionalFeatures

public static void resolveAdditionalFeatures(org.eclipse.emf.ecore.EClassifier owner,
                                             Environment env)

Copyright 2002, 2006 IBM Corporation and others.
All Rights Reserved.