org.eclipse.ocl.util
Class OCLStandardLibraryUtil

java.lang.Object
  extended by org.eclipse.ocl.util.OCLStandardLibraryUtil

public final class OCLStandardLibraryUtil
extends java.lang.Object

Convenience utilities for working with the types defined by the OCL Standard Library.

See the Environment class for a description of the generic type parameters of this class.

Author:
Christian W. Damus (cdamus)

Field Summary
static java.lang.String PRODUCT_FIRST
          The name of the tuple part carrying elements of the source collection in a product operation.
static java.lang.String PRODUCT_SECOND
          The name of the tuple part carrying elements of the argument collection in a product operation.
 
Method Summary
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createAnyTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the OclAny type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createBagIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the pre-defined iterators of the Bag(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createBagOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Bag(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createBooleanOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Boolean type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createCollectionIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the pre-defined iterators of the Collection(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createCollectionOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Collection(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createIntegerOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Integer type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createMessageTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the OclMessage type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createOrderedSetIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the pre-defined iterators of the OrderedSet(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createOrderedSetOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the OrderedSet(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createRealOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Real type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createSequenceIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the pre-defined iterators of the Sequence(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createSequenceOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Sequence(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createSetIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the pre-defined iterators of the Set(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createSetOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the Set(T) type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createStringOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the String type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createTypeTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the OclType type of the OCL Standard library.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
java.util.List<O>
createUnlimitedNaturalOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
          Utility method creating the operations of the UnlimitedNatural type of the OCL Standard library.
static
<C> java.util.Collection<C>
getAllSupertypes(Environment<?,C,?,?,?,?,?,?,?,?,?,?> env, PredefinedType<?> type)
          Queries all of the supertypes of a pre-defined type.
static int getOclAnyOperationCode(java.lang.String operName)
          Obtains the numeric code of the specified OclAny operaiton.
static int getOperationCode(java.lang.String operName)
          Obtains the numeric code of the specified pre-defined (by OCL) operaiton.
static java.lang.String getOperationName(int opcode)
          Returns the operation name corresponding to the opcode.
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
C
getResultTypeOf(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env, C sourceType, int opcode, java.util.List<? extends TypedElement<C>> args)
          Deprecated. Use the getResultTypeOf(Object, Environment, Object, int, List) method, instead, which doesn't fail on the first problem
static
<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E>
C
getResultTypeOf(java.lang.Object problemObject, Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env, C sourceType, int opcode, java.util.List<? extends TypedElement<C>> args)
          Obtains the result type of the specified operation from the OCL Standard Library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRODUCT_FIRST

public static final java.lang.String PRODUCT_FIRST
The name of the tuple part carrying elements of the source collection in a product operation.

See Also:
Constant Field Values

PRODUCT_SECOND

public static final java.lang.String PRODUCT_SECOND
The name of the tuple part carrying elements of the argument collection in a product operation.

See Also:
Constant Field Values
Method Detail

getOperationCode

public static int getOperationCode(java.lang.String operName)
Obtains the numeric code of the specified pre-defined (by OCL) operaiton.

Parameters:
operName - the operation name
Returns:
the corresponding code (as defined by the PredefinedType interface), or 0 if the operation name is not a pre-defined operation
See Also:
getOperationName(int)

getOclAnyOperationCode

public static int getOclAnyOperationCode(java.lang.String operName)
Obtains the numeric code of the specified OclAny operaiton.

Parameters:
operName - the operation name
Returns:
the corresponding code (as defined by the PredefinedType interface), or 0 if the operation name is not an operation of the OclAny type

getOperationName

public static java.lang.String getOperationName(int opcode)
Returns the operation name corresponding to the opcode.

Parameters:
opcode - an operation code
Returns:
the name corresponding to the opcode, or null if the code is not one defined by the PredefinedType interface
See Also:
getOperationCode(String)

getResultTypeOf

@Deprecated
public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> C getResultTypeOf(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env,
                                                                                C sourceType,
                                                                                int opcode,
                                                                                java.util.List<? extends TypedElement<C>> args)
                         throws SemanticException
Deprecated. Use the getResultTypeOf(Object, Environment, Object, int, List) method, instead, which doesn't fail on the first problem

Obtains the result type of the specified operation from the OCL Standard Library. Many of the OCL Standard Library operations are either generic themselves or defined by generic types, so the return results depend on the argument and source types.

Parameters:
env - an OCL environment (indicating the metamodel binding)
sourceType - the type of the operation source (object on which the operation is called)
opcode - the operation's code
args - the arguments of the operation call, as expressions or variables
Returns:
the result type of the corresponding operation
Throws:
SemanticException - if any of the argument types does not correspond to the source type and/or expected parameter types of the operation
See Also:
getOperationCode(String)

getResultTypeOf

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> C getResultTypeOf(java.lang.Object problemObject,
                                                                     Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env,
                                                                     C sourceType,
                                                                     int opcode,
                                                                     java.util.List<? extends TypedElement<C>> args)
Obtains the result type of the specified operation from the OCL Standard Library. Many of the OCL Standard Library operations are either generic themselves or defined by generic types, so the return results depend on the argument and source types.

Parameters:
env - an OCL environment (indicating the metamodel binding)
sourceType - the type of the operation source (object on which the operation is called)
opcode - the operation's code
args - the arguments of the operation call, as expressions or variables
Returns:
the result type of the corresponding operation, or null after reporting a problem to env if any of the argument types do not correspond to the source type and/or expected parameter types of the operation
See Also:
getOperationCode(String)

createAnyTypeOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createAnyTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the OclAny type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the OclAny.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard OclAny operations

createTypeTypeOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createTypeTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the OclType type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the OclType.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard OclType operations

createMessageTypeOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createMessageTypeOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the OclMessage type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the OclMessage.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard OclMessage operations

createStringOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createStringOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the String type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the String.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard String operations

createRealOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createRealOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Real type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Real.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Real operations

createIntegerOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createIntegerOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Integer type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Integer.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Integer operations

createUnlimitedNaturalOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createUnlimitedNaturalOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the UnlimitedNatural type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Integer.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard UnlimitedNatural operations

createBooleanOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createBooleanOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Boolean type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Boolean.

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Boolean operations

createCollectionOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createCollectionOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Collection(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Collection(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Collection(T) operations

createSetOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createSetOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Set(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Set(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Set(T) operations

createOrderedSetOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createOrderedSetOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the OrderedSet(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the OrderedSet(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard OrderedSet(T) operations

createBagOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createBagOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Bag(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Bag(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Bag(T) operations

createSequenceOperations

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createSequenceOperations(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the operations of the Sequence(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Sequence(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the standard Sequence(T) operations

createCollectionIterators

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createCollectionIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the pre-defined iterators of the Collection(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Collection(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the pre-defined iterators of the Collection(T) type

createSetIterators

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createSetIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the pre-defined iterators of the Set(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Set(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the pre-defined iterators of the Set(T) type

createOrderedSetIterators

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createOrderedSetIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the pre-defined iterators of the OrderedSet(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the OrderedSet(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the pre-defined iterators of the OrderedSet(T) type

createBagIterators

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createBagIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the pre-defined iterators of the Bag(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Bag(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the pre-defined iterators of the Bag(T) type

createSequenceIterators

public static <PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> java.util.List<O> createSequenceIterators(Environment<PK,C,O,P,EL,PM,ST,COA,SSA,CT,CLS,E> env)
Utility method creating the pre-defined iterators of the Sequence(T) type of the OCL Standard library. This is useful for implementors of metamodel bindings (Environments) to initialize their implementations of the Sequence(T).

Parameters:
env - an OCL environment
Returns:
a list of new operations representing the pre-defined iterators of the Sequence(T) type

getAllSupertypes

public static <C> java.util.Collection<C> getAllSupertypes(Environment<?,C,?,?,?,?,?,?,?,?,?,?> env,
                                                           PredefinedType<?> type)
Queries all of the supertypes of a pre-defined type. Note that this is only useful for operations on the OCL standard library types themselves, especially in the case of generic types such as the collection types, OclMessage, and the like. Thus, it helps to find inherited operations and attributes, etc., but not actual type conformance. For example, Set<Fruit> is not returned as a supertype of Set<Apple>. Rather, only Collection<T> is. This method also does not handle the void and invalid types.

Parameters:
env - the contextual environment
type - an OCL re-defined type
Returns:
an unmodifiable collection of the supertypes, which may be empty in some cases
Since:
1.3