org.eclipse.emf.validation.service
Class AbstractConstraintProvider
java.lang.Object
org.eclipse.emf.validation.service.AbstractConstraintProvider
-
All Implemented Interfaces:
-
IExecutableExtension,
IModelConstraintProvider
-
Direct Known Subclasses:
-
XmlConstraintProvider
-
public abstract class AbstractConstraintProvider
- extends
Object
- implements
IModelConstraintProvider,
IExecutableExtension
For situations in which the
XmlConstraintProvider
class
does not suffice (i.e., where a plug-in provides constraints dynamically,
rather than statically registered in XML), this is a useful class to extend
as it provides a partial implementation of the
IModelConstraintProvider
interface. In particular, it extracts the
URI namespace prefix information from the extension point XML and provides
implementations of the provider methods accessing the constraints loaded by this
provider. Additionally, support for lazy initialization of the actual model constraints
implementations is provided.
This class may be subclassed by clients of the validation framework.
-
See Also:
-
AbstractConstraintDescriptor
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
AbstractConstraintProvider
protected AbstractConstraintProvider()
- Initializes me.
createModelConstraint
protected
IModelConstraint createModelConstraint(
IConstraintDescriptor descriptor)
- Creates the model constraint implementation from the descriptor. This
default implementation delegates to the
ConstraintFactory
to create the constraint, if the specified descriptor is of a
known type and a registered
IConstraintParser
is available to
parse the descriptor. If either of these conditions does not hold, then
a disabled constraint implementation will be returned (one that always
returns an info status indicating that it is disabled).
A constraint provider that uses a descriptor type not defined by the
framework or a language for which it is not registering a parser should
override this method to create an appropriate constraint implementation.
-
-
-
Parameters:
-
descriptor
- the descriptor of the constraint to be created
-
Returns:
- actual constraint implementation
-
Since:
- 1.1
createModelConstraintProxy
protected
IModelConstraint createModelConstraintProxy(
IConstraintDescriptor descriptor)
- Creates a contraint proxy which lazily initializes the actual
constraint implementation represented by the given descriptor.
This method is to be used by the concrete provider to initialize its
constraints list if it's the intention to initialize the actual
constraints lazily.
-
-
-
Parameters:
-
descriptor
- the descriptor of the constraint for which a proxy is to be created
-
Returns:
- a proxy for the actual constraint implementation
-
Since:
- 1.1
getConstraints
protected
List<
IModelConstraint> getConstraints()
- Obtains my constraints.
-
-
-
Returns:
- a list of constraints
-
Since:
- 1.1
getNamespaceUris
public final
String[] getNamespaceUris()
- Obtains the namespace URIs of the EMF packages that I provide constraints
for.
-
-
-
Returns:
- my packages' namespace URIs
setInitializationData
public void setInitializationData(
IConfigurationElement config,
String propertyName,
Object data)
throws
CoreException
-
-
-
Specified by:
-
setInitializationData
in interface
IExecutableExtension
-
-
Throws:
-
CoreException
- if the subclass implementation of this
method throws on an error in accessing the config
or for
any other reason (see the subclass documentation)
getLiveConstraints
public
Collection<
IModelConstraint> getLiveConstraints(
Notification notification,
Collection<
IModelConstraint> constraints)
-
Description copied from interface:
IModelConstraintProvider
- Obtains a collection of live
IModelConstraint
s
that will be used to validate an EMF notification
on
committing a transaction on a model.
Clients typically should invoke this method on the service with a
null
value for the constraints
collector
parameter.
-
-
Specified by:
-
getLiveConstraints
in interface
IModelConstraintProvider
-
-
Parameters:
-
notification
- the EMF notification that is to be validated.
Encapsulates the object and the particular change -
constraints
- a collector parameter to which I will add
any constraints that I provide. If this argument is
null
, then I create and return a new collection
-
Returns:
- the collection which was passed in by the
constraints
parameter (with additions), or a new
collection if constraints == null
-
Since:
- 1.1
getBatchConstraints
public
Collection<
IModelConstraint> getBatchConstraints(
EObject eObject,
Collection<
IModelConstraint> constraints)
-
Description copied from interface:
IModelConstraintProvider
- Obtains a collection of batch
IModelConstraint
s
which will be used to validate an eObject
on demand.
Clients typically should invoke this method on the service with a
null
value for the constraints
collector
parameter.
-
-
Specified by:
-
getBatchConstraints
in interface
IModelConstraintProvider
-
-
Parameters:
-
eObject
- the
EObject
for which constraints are to be
obtained that can be applied to it -
constraints
- a collector parameter to which I will add
any constraints that I provide. If this argument is
null
, then I create and return a new collection
-
Returns:
- the collection which was passed in by the
constraints
parameter (with additions), or a new
collection if constraints == null
-
Since:
- 1.1
registerConstraints
protected void registerConstraints(
Collection<? extends
IModelConstraint> constraints)
throws
ConstraintExistsException
- Bulk-registers the specified constraints so that they are accessible to
applications via the
ConstraintRegistry
and are visible in the
preferences UI.
-
-
-
Parameters:
-
constraints
- the constraints to register
-
Throws:
-
ConstraintExistsException
- in case any of the constraints has an
ID that is already registered for a different constraint -
Since:
- 1.2