org.eclipse.emf.validation.service
Class ConstraintRegistry

java.lang.Object
  extended byorg.eclipse.emf.validation.service.ConstraintRegistry

public class ConstraintRegistry
extends java.lang.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
 java.util.Collection getAllDescriptors()
          Obtains the descriptors for all registered constraints, in no particular order.
 IConstraintDescriptor getDescriptor(java.lang.String id)
          Obtains the unique constraint descriptor having the specified ID.
 IConstraintDescriptor getDescriptor(java.lang.String pluginId, java.lang.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 new constraint descriptor.
 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(java.lang.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(java.lang.String pluginId,
                                           java.lang.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 java.util.Collection 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 new constraint descriptor.

Parameters:
descriptor - a new constraint descriptor, which must have a unique ID (not null)
Throws:
ConstraintExistsException - if the descriptor's ID already exists in the registry

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)

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