Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


org.eclipse.emf.validation.service
Class AbstractConstraintProvider


java.lang.Object
  extended by 
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

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 IModelConstraints 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 IModelConstraints 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

AbstractConstraintProvider

protected AbstractConstraintProvider()
Initializes me.

Method Detail

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 IModelConstraints 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 IModelConstraints 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

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


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire