|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.validation.service.AbstractConstraintProvider
public abstract class AbstractConstraintProvider
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.
AbstractConstraintDescriptor
Constructor Summary | |
---|---|
protected |
AbstractConstraintProvider()
Initializes me. |
Method Summary | |
---|---|
protected IModelConstraint |
createModelConstraint(IConstraintDescriptor descriptor)
Creates the model constraint implementation from the descriptor. |
protected IModelConstraint |
createModelConstraintProxy(IConstraintDescriptor descriptor)
Creates a contraint proxy which lazily initializes the actual constraint implementation represented by the given descriptor. |
Collection<IModelConstraint> |
getBatchConstraints(EObject eObject,
Collection<IModelConstraint> constraints)
Obtains a collection of batch IModelConstraint s
which will be used to validate an eObject on demand. |
protected List<IModelConstraint> |
getConstraints()
Obtains my constraints. |
Collection<IModelConstraint> |
getLiveConstraints(Notification notification,
Collection<IModelConstraint> constraints)
Obtains a collection of live IModelConstraint s
that will be used to validate an EMF notification on
committing a transaction on a model. |
String[] |
getNamespaceUris()
Obtains the namespace URIs of the EMF packages that I provide constraints for. |
protected void |
registerConstraints(Collection<? extends IModelConstraint> constraints)
Bulk-registers the specified constraints so that they are accessible to applications via the ConstraintRegistry and are visible in the
preferences UI. |
void |
setInitializationData(IConfigurationElement config,
String propertyName,
Object data)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractConstraintProvider()
Method Detail |
---|
protected IModelConstraint createModelConstraint(IConstraintDescriptor descriptor)
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.
descriptor
- the descriptor of the constraint to be created
protected IModelConstraint createModelConstraintProxy(IConstraintDescriptor 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.
descriptor
- the descriptor of the constraint for which a proxy is to be created
protected List<IModelConstraint> getConstraints()
public final String[] getNamespaceUris()
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException
setInitializationData
in interface IExecutableExtension
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)public Collection<IModelConstraint> getLiveConstraints(Notification notification, Collection<IModelConstraint> constraints)
IModelConstraintProvider
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.
getLiveConstraints
in interface IModelConstraintProvider
notification
- the EMF notification that is to be validated.
Encapsulates the object and the particular changeconstraints
- 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
constraints
parameter (with additions), or a new
collection if constraints == null
public Collection<IModelConstraint> getBatchConstraints(EObject eObject, Collection<IModelConstraint> constraints)
IModelConstraintProvider
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.
getBatchConstraints
in interface IModelConstraintProvider
eObject
- the EObject
for which constraints are to be
obtained that can be applied to itconstraints
- 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
constraints
parameter (with additions), or a new
collection if constraints == null
protected void registerConstraints(Collection<? extends IModelConstraint> constraints) throws ConstraintExistsException
ConstraintRegistry
and are visible in the
preferences UI.
constraints
- the constraints to register
ConstraintExistsException
- in case any of the constraints has an
ID that is already registered for a different constraint
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |