org.eclipse.ocl.util
Class OCLUtil

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

public final class OCLUtil
extends java.lang.Object

Miscellaneous utilities for use by the OCL parser/interpreter and by clients.

Since:
1.2
Author:
Christian W. Damus (cdamus)

Field Summary
static java.lang.String PLUGIN_ID
          The shared Ecore and UML binding plugin identification.
 
Method Summary
static org.eclipse.emf.common.util.Diagnostic checkForErrors(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env)
          Checks whether the specified environment's problem handler has any diagnostics of error severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.
static org.eclipse.emf.common.util.Diagnostic checkForErrors(ProblemHandler problemHandler)
          Checks whether the specified problem handler has any diagnostics of error severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.
static org.eclipse.emf.common.util.Diagnostic checkForErrorsOrWarnings(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env)
          Checks whether the specified environment's problem handler has any diagnostics of warnings severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.
static org.eclipse.emf.common.util.Diagnostic checkForErrorsOrWarnings(ProblemHandler problemHandler)
          Checks whether the specified problem handler has any diagnostics of warning severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.
static
<T> T
getAdapter(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env, java.lang.Class<T> adapterType)
          Obtains an adapter for the specified interface type.
static
<T> T
getAdapter(EnvironmentFactory<?,?,?,?,?,?,?,?,?,?,?,?> factory, java.lang.Class<T> adapterType)
          Obtains an adapter for the specified interface type.
static
<T> T
getAdapter(EvaluationEnvironment<?,?,?,?,?> env, java.lang.Class<T> adapterType)
          Obtains an adapter for the specified interface type, if the evaluation environment is Adaptable to it.
static
<C,CLS,E> org.eclipse.emf.common.util.Diagnostic
getEvaluationProblems(Query<C,CLS,E> query)
          Attempts to get evaluation problems available from the last evaluation of the given query.
static
<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E>
getValidationEnvironment(java.lang.Object target, java.util.Map<java.lang.Object,java.lang.Object> context)
          Attempts to get an environment instance that is appropriate for introspection of the specified validation target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGIN_ID

public static final java.lang.String PLUGIN_ID
The shared Ecore and UML binding plugin identification.

Since:
3.2
See Also:
Constant Field Values
Method Detail

getAdapter

public static <T> T getAdapter(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env,
                               java.lang.Class<T> adapterType)
Obtains an adapter for the specified interface type. Even for environments that do not adapt to the following interfaces, this method will provide a default implementation for convenience:

Type Parameters:
T - the requested adapter interface
Parameters:
env - an environment to adapt
adapterType - the requested adapter interface
Returns:
an instance of the requested interface, or null if this environment does not adapt to it

getAdapter

public static <T> T getAdapter(EnvironmentFactory<?,?,?,?,?,?,?,?,?,?,?,?> factory,
                               java.lang.Class<T> adapterType)
Obtains an adapter for the specified interface type. Even for environment factories that do not adapt to the following interfaces, this method will provide a default implementation for convenience:

Type Parameters:
T - the requested adapter interface
Parameters:
factory - an environment factory to adapt
adapterType - the requested adapter interface
Returns:
an instance of the requested interface, or null if this environment factory does not adapt to it

getAdapter

public static <T> T getAdapter(EvaluationEnvironment<?,?,?,?,?> env,
                               java.lang.Class<T> adapterType)
Obtains an adapter for the specified interface type, if the evaluation environment is Adaptable to it.

Type Parameters:
T - the requested adapter interface
Parameters:
env - an evaluation environment to adapt
adapterType - the requested adapter interface
Returns:
an instance of the requested interface, or null if this evaluation environment does not adapt to it

checkForErrors

public static org.eclipse.emf.common.util.Diagnostic checkForErrors(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env)
                                                             throws SyntaxException,
                                                                    SemanticException
Checks whether the specified environment's problem handler has any diagnostics of error severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.

Parameters:
env - an environment in which we have parsed some OCL
Throws:
SyntaxException - if there are any errors in parsing the concrete syntax
SemanticException - if there are any errors in analyzing the abstract syntax
See Also:
checkForErrors(ProblemHandler)

checkForErrors

public static org.eclipse.emf.common.util.Diagnostic checkForErrors(ProblemHandler problemHandler)
                                                             throws SyntaxException,
                                                                    SemanticException
Checks whether the specified problem handler has any diagnostics of error severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.

Parameters:
problemHandler - a problem handler
Throws:
SyntaxException - if there are any errors in parsing the concrete syntax
SemanticException - if there are any errors in analyzing the abstract syntax

checkForErrorsOrWarnings

public static org.eclipse.emf.common.util.Diagnostic checkForErrorsOrWarnings(Environment<?,?,?,?,?,?,?,?,?,?,?,?> env)
                                                                       throws SyntaxException,
                                                                              SemanticException
Checks whether the specified environment's problem handler has any diagnostics of warnings severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.

Parameters:
env - an environment in which we have parsed some OCL
Throws:
SyntaxException - if there are any errors in parsing the concrete syntax
SemanticException - if there are any errors in analyzing the abstract syntax
Since:
3.0
See Also:
checkForErrors(ProblemHandler)

checkForErrorsOrWarnings

public static org.eclipse.emf.common.util.Diagnostic checkForErrorsOrWarnings(ProblemHandler problemHandler)
                                                                       throws SyntaxException,
                                                                              SemanticException
Checks whether the specified problem handler has any diagnostics of warning severity or worse and, if so, throws a semantic exception encapsulating these diagnostics.

Parameters:
problemHandler - a problem handler
Throws:
SyntaxException - if there are any errors in parsing the concrete syntax
SemanticException - if there are any errors in analyzing the abstract syntax
Since:
3.0

getValidationEnvironment

public static <PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> Environment<PK,C,O,P,EL,PM,S,COA,SSA,CT,CLS,E> getValidationEnvironment(java.lang.Object target,
                                                                                                                          java.util.Map<java.lang.Object,java.lang.Object> context)
Attempts to get an environment instance that is appropriate for introspection of the specified validation target. If an environment is specified in the validation context, then it is used. Otherwise, an environment is obtained from the registry.

Parameters:
target - an object to be validated in an appropriate environment
context - the current validation context
Returns:
the environment, or null if none can be found
See Also:
Environment.Registry

getEvaluationProblems

public static <C,CLS,E> org.eclipse.emf.common.util.Diagnostic getEvaluationProblems(Query<C,CLS,E> query)
Attempts to get evaluation problems available from the last evaluation of the given query.

Parameters:
query - a query to check for evaluation problems
Returns:
the diagnostic object encapsulating the problem details or null if no problems are available
Since:
1.3