org.eclipse.emf.validation.service
Class ConstraintRegistry

java.lang.Object
  extended by org.eclipse.emf.validation.service.ConstraintRegistry

public class ConstraintRegistry
extends Object

A centralized registry of descriptors for the constraints that are available in the validation system. Clients can use this registry to look up the meta-data for constraints (given the constraint IDs), and constraint providers can register the constraints that they provide in the registry.

Note for dynamic constraint providers: registering constraints in the registry is not absolutely necessary if none of the following capabilities of the system is required for your constraints:


Method Summary
 void addConstraintListener(IConstraintListener listener)
          Adds an IConstraintListener to receive constraint change events.
 void broadcastConstraintChangeEvent(ConstraintChangeEvent event)
          Broadcasts the specified ConstraintChangeEvent to all constraint listeners.
 Collection<IConstraintDescriptor> getAllDescriptors()
          Obtains the descriptors for all registered constraints, in no particular order.
 IConstraintDescriptor getDescriptor(String id)
          Obtains the unique constraint descriptor having the specified ID.
 IConstraintDescriptor getDescriptor(String pluginId, String id)
          Obtains the unique constraint descriptor having the specified ID.
static ConstraintRegistry getInstance()
          Obtains the instance of the constraint registry.
 void register(IConstraintDescriptor descriptor)
          Registers a constraint descriptor.
 void removeConstraintListener(IConstraintListener listener)
          Removes the IConstraintListener from the list of listeners.
 void unregister(IConstraintDescriptor descriptor)
          Unregisters an existing constraint descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConstraintRegistry getInstance()
Obtains the instance of the constraint registry.

Returns:
the Singleton instance

getDescriptor

public IConstraintDescriptor getDescriptor(String id)
Obtains the unique constraint descriptor having the specified ID.

Parameters:
id - the ID of the constraint descriptor to retrieve (not null)
Returns:
the matching constraint descriptor, or null if it does not exist

getDescriptor

public IConstraintDescriptor getDescriptor(String pluginId,
                                           String id)
Obtains the unique constraint descriptor having the specified ID. The ID is prepended by the supplied plug-in ID, to generate a fully-qualified ID of the form <pluginId>.<id>.

Parameters:
pluginId - the ID of the plug-in that contributes the constraint
id - the constraint's ID, relative to the plug-in ID
Returns:
the matching constraint descriptor, or null if it does not exist

getAllDescriptors

public Collection<IConstraintDescriptor> getAllDescriptors()
Obtains the descriptors for all registered constraints, in no particular order. Note that all disabled (for whatever reason) constraints are included in the result.

Returns:
the available constraint descriptors, as an unmodifiable collection

register

public void register(IConstraintDescriptor descriptor)
              throws ConstraintExistsException
Registers a constraint descriptor.

Parameters:
descriptor - a new constraint descriptor, which must have a unique ID (not null)
Throws:
ConstraintExistsException - if a different descriptor is already registered under the given descriptor's ID

unregister

public void unregister(IConstraintDescriptor descriptor)
Unregisters an existing constraint descriptor. This descriptor's ID will subsequently be available for re-use.

Parameters:
descriptor - a constraint descriptor (not null)

addConstraintListener

public void addConstraintListener(IConstraintListener listener)
Adds an IConstraintListener to receive constraint change events. This method has no effect if the IConstraintListener is already registered.

Parameters:
listener - a new constraint listener
Since:
1.1

removeConstraintListener

public void removeConstraintListener(IConstraintListener listener)
Removes the IConstraintListener from the list of listeners. This method has no effect if the IConstraintListener is not currently registered.

Parameters:
listener - a constraint listener
Since:
1.1

broadcastConstraintChangeEvent

public void broadcastConstraintChangeEvent(ConstraintChangeEvent event)
Broadcasts the specified ConstraintChangeEvent to all constraint listeners. This method is used internally by constraints to send notifications when they have changed.

Note that this method should only be invoked by implementation of of the IConstraintDescriptor interface.

Parameters:
event - a constraint change event to broadcast
Since:
1.1

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