Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 123885 Details for
Bug 255786
Investigate support for Constraints directly annotated to Ecore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
some improvements
constraintsDelegator4.patch (text/plain), 74.82 KB, created by
Tristan Faure
on 2009-01-27 10:49:46 EST
(
hide
)
Description:
some improvements
Filename:
MIME Type:
Creator:
Tristan Faure
Created:
2009-01-27 10:49:46 EST
Size:
74.82 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.ecore >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.xml,v >retrieving revision 1.22 >diff -u -r1.22 plugin.xml >--- plugin.xml 27 Apr 2008 20:27:23 -0000 1.22 >+++ plugin.xml 27 Jan 2009 15:48:02 -0000 >@@ -10,6 +10,7 @@ > <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/> > <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/> > <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/> >+ <extension-point id="constraints_delegator_registry" name="%_UI_ConstraintsDelegatorRegistry_extensionpoint" schema="schema/constraints_delegator_registry.exsd"/> > > <extension point="org.eclipse.emf.ecore.generated_package"> > <package >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.properties,v >retrieving revision 1.32 >diff -u -r1.32 plugin.properties >--- plugin.properties 22 Dec 2008 19:51:05 -0000 1.32 >+++ plugin.properties 27 Jan 2009 15:48:02 -0000 >@@ -114,6 +114,8 @@ > _UI_ContentHandler_extensionpoint = Content Handler Registry > _UI_URIMappingRegistry_extensionpoint = URI Converter Mapping Registry > _UI_PackageRegistryImplementation_extensionpoint = Ecore Package Registry Implementation >+_UI_ConstraintsDelegatorRegistry_extensionpoint = Constraints Delegator Registry >+ > > _UI_GenericInvariant_diagnostic = The ''{0}'' invariant is violated on ''{1}'' > _UI_GenericConstraint_diagnostic = The ''{0}'' constraint is violated on ''{1}'' >Index: src/org/eclipse/emf/ecore/plugin/EcorePlugin.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/EcorePlugin.java,v >retrieving revision 1.23 >diff -u -r1.23 EcorePlugin.java >--- src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 2 Aug 2008 13:40:51 -0000 1.23 >+++ src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 27 Jan 2009 15:48:02 -0000 >@@ -55,7 +55,7 @@ > * A collection of platform-neutral static utilities > * as well as Eclipse support utilities. > */ >-public class EcorePlugin extends EMFPlugin >+public class EcorePlugin extends EMFPlugin > { > /** > * The singleton instance of the plugin. >@@ -67,7 +67,7 @@ > */ > private EcorePlugin() > { >- super(new ResourceLocator[] {}); >+ super(new ResourceLocator []{}); > } > > @Override >@@ -162,7 +162,7 @@ > * @param arguments an array of "command line" options. > * @return the arguments stripped of those recognized as platform resource options. > */ >- public static String [] handlePlatformResourceOptions(String [] arguments) >+ public static String[] handlePlatformResourceOptions(String[] arguments) > { > getPlatformResourceMap(); > >@@ -204,7 +204,7 @@ > } > } > >- String [] remainingArguments = new String [arguments.length - (i - start)]; >+ String[] remainingArguments = new String [arguments.length - (i - start)]; > System.arraycopy(arguments, 0, remainingArguments, 0, start); > System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i); > return remainingArguments; >@@ -213,7 +213,7 @@ > > return arguments; > } >- >+ > /** > * Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String) > * to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}). >@@ -258,10 +258,10 @@ > } > return result; > } >- >+ > private static Pattern bundleSymbolNamePattern; >- private static byte [] NO_BYTES = new byte [0]; >- >+ private static byte[] NO_BYTES = new byte [0]; >+ > /** > * Computes a map from <code>platform:/plugin/<plugin-id>/</code> {@link URI} to > * <code>platform:/resource/<plugin-location>/</code> URI >@@ -277,12 +277,12 @@ > Map<URI, URI> result = new HashMap<URI, URI>(); > IWorkspaceRoot root = getWorkspaceRoot(); > if (root != null) >- { >- IProject [] projects = root.getProjects(); >+ { >+ IProject[] projects = root.getProjects(); > if (projects != null) > { > String pluginID = null; >- >+ > class Handler extends DefaultHandler > { > public String pluginID; >@@ -298,11 +298,11 @@ > } > } > Handler handler = new Handler(); >- >- SAXParserFactory parserFactory= SAXParserFactory.newInstance(); >+ >+ SAXParserFactory parserFactory = SAXParserFactory.newInstance(); > parserFactory.setNamespaceAware(true); > SAXParser parser = null; >- >+ > try > { > parser = parserFactory.newSAXParser(); >@@ -311,14 +311,14 @@ > { > INSTANCE.log(exception); > } >- >+ > if (bundleSymbolNamePattern == null) > { > bundleSymbolNamePattern = Pattern.compile("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", Pattern.MULTILINE); > } >- >- byte [] bytes = NO_BYTES; >- >+ >+ byte[] bytes = NO_BYTES; >+ > for (int i = 0, size = projects.length; i < size; ++i) > { > IProject project = projects[i]; >@@ -331,7 +331,7 @@ > InputStream inputStream = null; > try > { >- inputStream = manifest.getContents(); >+ inputStream = manifest.getContents(); > int available = inputStream.available(); > if (bytes.length < available) > { >@@ -386,21 +386,21 @@ > } > } > } >- >+ > if (pluginID != null) > { > URI platformPluginURI = URI.createPlatformPluginURI(pluginID + "/", false); >- URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); >+ URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); > result.put(platformPluginURI, platformResourceURI); > } > } > } > } > } >- >+ > return result; > } >- >+ > /** > * Computes a map so that plugins in the workspace will override those in the environment > * and so that plugins with Ecore and GenModels will look like projects in the workspace. >@@ -425,13 +425,13 @@ > result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet<URI>(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values()))); > return result; > } >- >+ > /** > * The platform resource map. > * @see #getPlatformResourceMap > */ > private static Map<String, URI> platformResourceMap; >- >+ > /** > * The map from package namespace URIs to the location of the GenModel for that package. > * @see #getPlatformResourceMap >@@ -452,7 +452,7 @@ > super(); > plugin = this; > } >- >+ > /** > * Starts up this plugin by reading some extensions and populating the relevant registries. > * <p> >@@ -520,52 +520,53 @@ > workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); > } > >- new RegistryReader >- (Platform.getExtensionRegistry(), >- EcorePlugin.getPlugin().getBundle().getSymbolicName(), >- PACKAGE_REGISTRY_IMPLEMENTATION_PPID) >- { >- IConfigurationElement previous; >- >- @Override >- protected boolean readElement(IConfigurationElement element) >+ new RegistryReader( >+ Platform.getExtensionRegistry(), >+ EcorePlugin.getPlugin().getBundle().getSymbolicName(), >+ PACKAGE_REGISTRY_IMPLEMENTATION_PPID) > { >- if (element.getName().equals("registry")) >+ IConfigurationElement previous; >+ >+ @Override >+ protected boolean readElement(IConfigurationElement element) > { >- String implementationClass = element.getAttribute("class"); >- if (implementationClass == null) >+ if (element.getName().equals("registry")) > { >- logMissingAttribute(element, "class"); >- } >- else >- { >- if (defaultRegistryImplementation != null) >+ String implementationClass = element.getAttribute("class"); >+ if (implementationClass == null) >+ { >+ logMissingAttribute(element, "class"); >+ } >+ else > { >- if (previous != null) >+ if (defaultRegistryImplementation != null) > { >- log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package registry implementation"); >+ if (previous != null) >+ { >+ log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() >+ + "' register a package registry implementation"); >+ } >+ if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) >+ { >+ return false; >+ } > } >- if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) >+ try > { >- return false; >+ defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); >+ previous = element; > } >+ catch (CoreException exception) >+ { >+ log(exception); >+ } >+ return true; > } >- try >- { >- defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); >- previous = element; >- } >- catch (CoreException exception) >- { >- log(exception); >- } >- return true; > } >+ return false; > } >- return false; >- } >- >- }.readRegistry(); >+ >+ }.readRegistry(); > > new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap()).readRegistry(); > new DynamicPackageRegistryReader().readRegistry(); >@@ -575,13 +576,14 @@ > new ContentParserRegistryReader().readRegistry(); > new ContentHandlerRegistryReader().readRegistry(); > new URIMappingRegistryReader().readRegistry(); >+ new ConstraintsDelegatorFactoryRegistryReader().readRegistry(); > } > } > > /** > * The default registry implementation singleton. > */ >- private static EPackage.Registry defaultRegistryImplementation; >+ private static EPackage.Registry defaultRegistryImplementation; > > /** > * Returns the default registry implementation singleton. >@@ -631,4 +633,5 @@ > public static final String SCHEME_PARSER_PPID = "scheme_parser"; > public static final String URI_MAPPING_PPID = "uri_mapping"; > public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation"; >+ public static final String CONSTRAINTS_DELEGATOR_FACTORY = "constraints_delegator_registry"; > } >\ No newline at end of file >Index: src/org/eclipse/emf/ecore/util/EObjectValidator.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EObjectValidator.java,v >retrieving revision 1.29 >diff -u -r1.29 EObjectValidator.java >--- src/org/eclipse/emf/ecore/util/EObjectValidator.java 22 Dec 2008 14:24:54 -0000 1.29 >+++ src/org/eclipse/emf/ecore/util/EObjectValidator.java 27 Jan 2009 15:48:03 -0000 >@@ -16,42 +16,39 @@ > */ > package org.eclipse.emf.ecore.util; > >- >+import java.lang.reflect.Array; >+import java.math.BigDecimal; > import java.util.ArrayList; > import java.util.Collection; >+import java.util.Collections; > import java.util.HashMap; > import java.util.Iterator; >+import java.util.LinkedList; > import java.util.List; > import java.util.ListIterator; > import java.util.Map; > >-import java.lang.reflect.Array; >-import java.math.BigDecimal; >- > import org.eclipse.emf.common.util.BasicDiagnostic; > import org.eclipse.emf.common.util.BasicEList; > import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.DiagnosticChain; > import org.eclipse.emf.common.util.EMap; > import org.eclipse.emf.common.util.ResourceLocator; >- >-import org.eclipse.emf.ecore.EValidator; >- >+import org.eclipse.emf.ecore.EAnnotation; > import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EReference; >-import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.EDataType; >+import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.EValidator; >+import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.InternalEObject; >- > import org.eclipse.emf.ecore.plugin.EcorePlugin; >- > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.ResourceSet; >- >+import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory; > import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; > > >@@ -60,6 +57,14 @@ > */ > public class EObjectValidator implements EValidator > { >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY = "factory"; >+ >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS = "constraints"; >+ >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE = "inheritsConstraints"; >+ >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE = "Ecore"; >+ > public static final EObjectValidator INSTANCE = new EObjectValidator(); > > public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecore"; >@@ -78,7 +83,7 @@ > public static final int EOBJECT__UNIQUE_ID = 12; > public static final int EOBJECT__EVERY_KEY_UNIQUE = 13; > public static final int EOBJECT__EVERY_MAP_ENTRY_UNIQUE = 14; >- >+ > static final int EOBJECT_DIAGNOSTIC_CODE_COUNT = EOBJECT__EVERY_MAP_ENTRY_UNIQUE; > > /** >@@ -173,10 +178,11 @@ > else > { > List<EClass> eSuperTypes = eClass.getESuperTypes(); >- return >- eSuperTypes.isEmpty() ? >- validate_EveryDefaultConstraint(eObject, diagnostics, context) : >- validate(eSuperTypes.get(0), eObject, diagnostics, context); >+ return eSuperTypes.isEmpty() ? validate_EveryDefaultConstraint(eObject, diagnostics, context) : validate( >+ eSuperTypes.get(0), >+ eObject, >+ diagnostics, >+ context); > } > } > >@@ -212,6 +218,11 @@ > { > result &= validate_EveryMapEntryUnique(object, theDiagnostics, context); > } >+ // ADDS FOR MANAGING USER CONSTRAINTS >+ if (result || theDiagnostics != null) >+ { >+ result &= validate_UserConstraints(object, theDiagnostics, context); >+ } > return result; > } > >@@ -229,14 +240,17 @@ > } > return result; > } >- >- protected boolean validate_MultiplicityConforms >- (EObject eObject, EStructuralFeature eStructuralFeature, DiagnosticChain diagnostics, Map<Object, Object> context) >+ >+ protected boolean validate_MultiplicityConforms( >+ EObject eObject, >+ EStructuralFeature eStructuralFeature, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) > { > boolean result = true; > if (eStructuralFeature.isMany()) > { >- if (FeatureMapUtil.isFeatureMap(eStructuralFeature) && ExtendedMetaData.INSTANCE.isDocumentRoot(eObject.eClass())) >+ if (FeatureMapUtil.isFeatureMap(eStructuralFeature) && ExtendedMetaData.INSTANCE.isDocumentRoot(eObject.eClass())) > { > FeatureMap featureMap = (FeatureMap)eObject.eGet(eStructuralFeature); > int count = 0; >@@ -254,20 +268,14 @@ > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MULTIPCITY_CONFORMS, >- "_UI_DocumentRootMustHaveOneElement_diagnostic", >- new Object [] >- { >- getFeatureLabel(eStructuralFeature, context), >- getObjectLabel(eObject, context), >- count >- }, >- new Object [] { eObject, eStructuralFeature }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MULTIPCITY_CONFORMS, >+ "_UI_DocumentRootMustHaveOneElement_diagnostic", >+ new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), count }, >+ new Object []{ eObject, eStructuralFeature }, >+ context)); > } > } > } >@@ -276,27 +284,20 @@ > int lowerBound = eStructuralFeature.getLowerBound(); > if (lowerBound > 0) > { >- int size = ((List<?>)eObject.eGet(eStructuralFeature)).size(); >+ int size = ((List< ? >)eObject.eGet(eStructuralFeature)).size(); > if (size < lowerBound) > { > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MULTIPCITY_CONFORMS, >- "_UI_FeatureHasTooFewValues_diagnostic", >- new Object [] >- { >- getFeatureLabel(eStructuralFeature, context), >- getObjectLabel(eObject, context), >- size, >- lowerBound >- }, >- new Object [] { eObject, eStructuralFeature }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MULTIPCITY_CONFORMS, >+ "_UI_FeatureHasTooFewValues_diagnostic", >+ new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), size, lowerBound }, >+ new Object []{ eObject, eStructuralFeature }, >+ context)); > } > } > int upperBound = eStructuralFeature.getUpperBound(); >@@ -305,21 +306,14 @@ > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MULTIPCITY_CONFORMS, >- "_UI_FeatureHasTooManyValues_diagnostic", >- new Object [] >- { >- getFeatureLabel(eStructuralFeature, context), >- getObjectLabel(eObject, context), >- size, >- upperBound >- }, >- new Object [] { eObject, eStructuralFeature }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MULTIPCITY_CONFORMS, >+ "_UI_FeatureHasTooManyValues_diagnostic", >+ new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), size, upperBound }, >+ new Object []{ eObject, eStructuralFeature }, >+ context)); > } > } > } >@@ -328,27 +322,20 @@ > int upperBound = eStructuralFeature.getUpperBound(); > if (upperBound > 0) > { >- int size = ((List<?>)eObject.eGet(eStructuralFeature)).size(); >+ int size = ((List< ? >)eObject.eGet(eStructuralFeature)).size(); > if (size > upperBound) > { > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MULTIPCITY_CONFORMS, >- "_UI_FeatureHasTooManyValues_diagnostic", >- new Object [] >- { >- getFeatureLabel(eStructuralFeature, context), >- getObjectLabel(eObject, context), >- size, >- upperBound >- }, >- new Object [] { eObject, eStructuralFeature }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MULTIPCITY_CONFORMS, >+ "_UI_FeatureHasTooManyValues_diagnostic", >+ new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), size, upperBound }, >+ new Object []{ eObject, eStructuralFeature }, >+ context)); > } > } > } >@@ -362,15 +349,14 @@ > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MULTIPCITY_CONFORMS, >- "_UI_RequiredFeatureMustBeSet_diagnostic", >- new Object [] { getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context) }, >- new Object [] { eObject, eStructuralFeature }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MULTIPCITY_CONFORMS, >+ "_UI_RequiredFeatureMustBeSet_diagnostic", >+ new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context) }, >+ new Object []{ eObject, eStructuralFeature }, >+ context)); > } > } > } >@@ -381,7 +367,7 @@ > public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) > { > boolean result = true; >- for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext(); ) >+ for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext();) > { > EObject eCrossReferenceObject = i.next(); > if (eCrossReferenceObject.eIsProxy()) >@@ -389,20 +375,17 @@ > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_PROXY_RESOLVES, >- "_UI_UnresolvedProxy_diagnostic", >- new Object [] >- { >- getFeatureLabel(i.feature(), context), >- getObjectLabel(eObject, context), >- getObjectLabel(eCrossReferenceObject, context) >- }, >- new Object [] { eObject, i.feature(), eCrossReferenceObject }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_PROXY_RESOLVES, >+ "_UI_UnresolvedProxy_diagnostic", >+ new Object []{ >+ getFeatureLabel(i.feature(), context), >+ getObjectLabel(eObject, context), >+ getObjectLabel(eCrossReferenceObject, context) }, >+ new Object []{ eObject, i.feature(), eCrossReferenceObject }, >+ context)); > } > else > { >@@ -418,7 +401,7 @@ > boolean result = true; > if (eObject.eResource() != null) > { >- for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext(); ) >+ for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext();) > { > EObject eCrossReferenceObject = i.next(); > if (eCrossReferenceObject.eResource() == null && !eCrossReferenceObject.eIsProxy() && !i.feature().isTransient()) >@@ -426,20 +409,17 @@ > result = false; > if (diagnostics != null) > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_REFERENCE_IS_CONTAINED, >- "_UI_DanglingReference_diagnostic", >- new Object [] >- { >- getFeatureLabel(i.feature(), context), >- getObjectLabel(eObject, context), >- getObjectLabel(eCrossReferenceObject, context) >- }, >- new Object [] { eObject, i.feature(), eCrossReferenceObject }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_REFERENCE_IS_CONTAINED, >+ "_UI_DanglingReference_diagnostic", >+ new Object []{ >+ getFeatureLabel(i.feature(), context), >+ getObjectLabel(eObject, context), >+ getObjectLabel(eCrossReferenceObject, context) }, >+ new Object []{ eObject, i.feature(), eCrossReferenceObject }, >+ context)); > } > else > { >@@ -465,8 +445,11 @@ > return result; > } > >- protected boolean validate_DataValueConforms >- (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context) >+ protected boolean validate_DataValueConforms( >+ EObject eObject, >+ EAttribute eAttribute, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) > { > if (!eObject.eIsSet(eAttribute)) > { >@@ -478,15 +461,15 @@ > Object value = eObject.eGet(eAttribute); > if (FeatureMapUtil.isFeatureMap(eAttribute)) > { >- @SuppressWarnings("unchecked") Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value; >+ @SuppressWarnings("unchecked") >+ Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value; > EClass eClass = eObject.eClass(); > Map<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null; >- for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null); ) >+ for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null);) > { > FeatureMap.Entry entry = i.next(); > EStructuralFeature entryFeature = entry.getEStructuralFeature(); >- if (entryFeature instanceof EAttribute && >- ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute) >+ if (entryFeature instanceof EAttribute && ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute) > { > EDataType entryType = (EDataType)entryFeature.getEType(); > Object entryValue = entry.getValue(); >@@ -514,7 +497,7 @@ > } > else if (eAttribute.isMany()) > { >- for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && result; ) >+ for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && result;) > { > result &= rootValidator.validate(eDataType, i.next(), null, context); > } >@@ -522,7 +505,7 @@ > if (!result && diagnostics != null) > { > DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context); >- for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext(); ) >+ for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext();) > { > rootValidator.validate(eDataType, i.next(), diagnostic, context); > } >@@ -541,33 +524,35 @@ > return result; > } > >- protected DiagnosticChain createBadDataValueDiagnostic >- (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- BasicDiagnostic diagnostic = >- createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_DATA_VALUE_CONFORMS, >- "_UI_BadDataValue_diagnostic", >- new Object [] >- { >- getFeatureLabel(eAttribute, context), >- getObjectLabel(eObject, context) >- }, >- new Object [] { eObject, eAttribute }, >- context); >+ protected DiagnosticChain createBadDataValueDiagnostic( >+ EObject eObject, >+ EAttribute eAttribute, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ BasicDiagnostic diagnostic = createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_DATA_VALUE_CONFORMS, >+ "_UI_BadDataValue_diagnostic", >+ new Object []{ getFeatureLabel(eAttribute, context), getObjectLabel(eObject, context) }, >+ new Object []{ eObject, eAttribute }, >+ context); > diagnostics.add(diagnostic); > return diagnostic; > } > >- protected boolean validatePattern >- (EDataType eDataType, Object value, PatternMatcher [][] patterns, DiagnosticChain diagnostics, Map<Object, Object> context) >+ protected boolean validatePattern( >+ EDataType eDataType, >+ Object value, >+ PatternMatcher[][] patterns, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) > { > String literal = EcoreUtil.convertToString(eDataType, value); > for (int i = 0; i < patterns.length; ++i) > { >- PatternMatcher [] children = patterns[i]; >+ PatternMatcher[] children = patterns[i]; > boolean matches = false; > for (int j = 0; j < children.length; ++j) > { >@@ -592,7 +577,7 @@ > public class DynamicEDataTypeValidator > { > protected List<Object> effectiveEnumeration; >- protected PatternMatcher [][] effectivePattern; >+ protected PatternMatcher[][] effectivePattern; > protected int effectiveTotalDigits = -1; > protected int effectiveFractionDigits = -1; > protected int effectiveMinLength = -1; >@@ -643,9 +628,9 @@ > { > patterns = new ArrayList<PatternMatcher[]>(); > } >- PatternMatcher [] children = new PatternMatcher [pattern.size()]; >+ PatternMatcher[] children = new PatternMatcher [pattern.size()]; > patterns.add(children); >- for (ListIterator<String> i = pattern.listIterator(); i.hasNext(); ) >+ for (ListIterator<String> i = pattern.listIterator(); i.hasNext();) > { > PatternMatcher patternMatcher = XMLTypeUtil.createPatternMatcher(i.next()); > children[i.previousIndex()] = patternMatcher; >@@ -729,7 +714,7 @@ > > if (patterns != null) > { >- effectivePattern = new PatternMatcher [patterns.size()][]; >+ effectivePattern = new PatternMatcher [patterns.size()] []; > patterns.toArray(effectivePattern); > } > >@@ -740,14 +725,15 @@ > { > digits.append("0"); > } >- >+ > try > { > Object lowerBound = EcoreUtil.createFromString(eDataType, "-" + digits.toString()); >- @SuppressWarnings("unchecked") boolean lowerBounded = effectiveMin == null || >- (effectiveMinIsInclusive ? >- ((Comparable<Object>)effectiveMin).compareTo(lowerBound) <= 0: >- ((Comparable<Object>)effectiveMin).compareTo(lowerBound) < 0); >+ @SuppressWarnings("unchecked") >+ boolean lowerBounded = effectiveMin == null >+ || (effectiveMinIsInclusive >+ ? ((Comparable<Object>)effectiveMin).compareTo(lowerBound) <= 0 >+ : ((Comparable<Object>)effectiveMin).compareTo(lowerBound) < 0); > if (lowerBounded) > { > effectiveMinIsInclusive = false; >@@ -755,7 +741,7 @@ > effectiveTotalDigitsMin = effectiveTotalDigits; > } > } >- catch (NumberFormatException exception) >+ catch (NumberFormatException exception) > { > // Ignore the bound if the value is too big. > } >@@ -763,10 +749,11 @@ > try > { > Object upperBound = EcoreUtil.createFromString(eDataType, digits.toString()); >- @SuppressWarnings("unchecked") boolean upperBounded = effectiveMax == null || >- (effectiveMaxIsInclusive ? >- ((Comparable<Object>)effectiveMax).compareTo(upperBound) >= 0: >- ((Comparable<Object>)effectiveMax).compareTo(upperBound) > 0); >+ @SuppressWarnings("unchecked") >+ boolean upperBounded = effectiveMax == null >+ || (effectiveMaxIsInclusive >+ ? ((Comparable<Object>)effectiveMax).compareTo(upperBound) >= 0 >+ : ((Comparable<Object>)effectiveMax).compareTo(upperBound) > 0); > if (upperBounded) > { > effectiveMaxIsInclusive = false; >@@ -774,7 +761,7 @@ > effectiveTotalDigitsMax = effectiveTotalDigits; > } > } >- catch (NumberFormatException exception) >+ catch (NumberFormatException exception) > { > // Ignore the bound if the value is too big. > } >@@ -795,7 +782,8 @@ > { > if (!effectiveEnumeration.contains(value)) > { >- if (diagnostics != null) reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context); >+ if (diagnostics != null) >+ reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context); > result = false; > } > } >@@ -807,10 +795,9 @@ > > if (effectiveMin != null) > { >- @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin; >- if (effectiveMinIsInclusive ? >- comparableObject.compareTo(value) > 0: >- comparableObject.compareTo(value) >= 0) >+ @SuppressWarnings("unchecked") >+ Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin; >+ if (effectiveMinIsInclusive ? comparableObject.compareTo(value) > 0 : comparableObject.compareTo(value) >= 0) > { > if (diagnostics != null) > { >@@ -829,10 +816,9 @@ > > if (effectiveMax != null) > { >- @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax; >- if (effectiveMaxIsInclusive ? >- comparableObject.compareTo(value) < 0: >- comparableObject.compareTo(value) <= 0) >+ @SuppressWarnings("unchecked") >+ Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax; >+ if (effectiveMaxIsInclusive ? comparableObject.compareTo(value) < 0 : comparableObject.compareTo(value) <= 0) > { > if (diagnostics != null) > { >@@ -851,30 +837,24 @@ > > if (effectiveMinLength != -1) > { >- int length = >- value instanceof String ? >- ((String)value).length() : >- value instanceof Collection<?> ? >- ((Collection<?>)value).size() : >- Array.getLength(value); >+ int length = value instanceof String ? ((String)value).length() : value instanceof Collection< ? > >+ ? ((Collection< ? >)value).size() : Array.getLength(value); > if (length < effectiveMinLength) > { >- if (diagnostics != null) reportMinLengthViolation(eDataType, value, length, effectiveMinLength, diagnostics, context); >+ if (diagnostics != null) >+ reportMinLengthViolation(eDataType, value, length, effectiveMinLength, diagnostics, context); > result = false; > } > } > > if (effectiveMaxLength != -1) > { >- int length = >- value instanceof String ? >- ((String)value).length() : >- value instanceof Collection<?> ? >- ((Collection<?>)value).size() : >- Array.getLength(value); >+ int length = value instanceof String ? ((String)value).length() : value instanceof Collection< ? > >+ ? ((Collection< ? >)value).size() : Array.getLength(value); > if (length > effectiveMaxLength) > { >- if (diagnostics != null) reportMaxLengthViolation(eDataType, value, length, effectiveMaxLength, diagnostics, context); >+ if (diagnostics != null) >+ reportMaxLengthViolation(eDataType, value, length, effectiveMaxLength, diagnostics, context); > result = false; > } > } >@@ -883,7 +863,8 @@ > { > if (value instanceof BigDecimal && ((BigDecimal)value).unscaledValue().abs().toString().length() > effectiveTotalDigits) > { >- if (diagnostics != null) reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context); >+ if (diagnostics != null) >+ reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context); > result = false; > } > } >@@ -892,7 +873,8 @@ > { > if (value instanceof BigDecimal && ((BigDecimal)value).scale() > effectiveFractionDigits) > { >- if (diagnostics != null) reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context); >+ if (diagnostics != null) >+ reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context); > result = false; > } > } >@@ -900,7 +882,7 @@ > if (itemType != null) > { > EValidator rootValidator = getRootEValidator(context); >- for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && (result || diagnostics != null); ) >+ for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);) > { > result &= rootValidator.validate(itemType, i.next(), diagnostics, context); > } >@@ -909,7 +891,7 @@ > else if (!memberTypes.isEmpty()) > { > EValidator rootValidator = getRootEValidator(context); >- >+ > for (EDataType memberType : memberTypes) > { > if (rootValidator.validate(memberType, value, null, context)) >@@ -943,7 +925,8 @@ > } > else > { >- if (diagnostics != null) reportDataValueTypeViolation(eDataType, value, diagnostics, context); >+ if (diagnostics != null) >+ reportDataValueTypeViolation(eDataType, value, diagnostics, context); > return false; > } > } >@@ -954,8 +937,7 @@ > } > else > { >- return >- new DynamicEDataTypeValidator(eDataType) >+ return new DynamicEDataTypeValidator(eDataType) > { > // Ensure that the class loader for this class will be used downstream. > // >@@ -963,202 +945,184 @@ > } > } > >- protected void reportMinViolation >- (EDataType eDataType, Object value, Object bound, boolean isInclusive, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__VALUE_IN_RANGE, >- isInclusive ? "_UI_MinInclusiveConstraint_diagnostic" : "_UI_MinExclusiveConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- isInclusive ? ">=" : ">", >- getValueLabel(eDataType, bound, context) >- }, >- new Object [] { value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, >- context)); >- } >- >- protected void reportMaxViolation >- (EDataType eDataType, Object value, Object bound, boolean isInclusive, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__VALUE_IN_RANGE, >- isInclusive ? "_UI_MaxInclusiveConstraint_diagnostic" : "_UI_MaxExclusiveConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- "<", >- getValueLabel(eDataType, bound, context) >- }, >- new Object [] { value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, >- context)); >- } >- >- protected void reportMinLengthViolation >- (EDataType eDataType, Object value, int length, int bound, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__LENGTH_IN_RANGE, >- "_UI_MinLengthConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- Integer.toString(length), >- Integer.toString(bound) >- }, >- new Object [] { value, eDataType, length, bound }, >- context)); >- } >- >- protected void reportMaxLengthViolation >- (EDataType eDataType, Object value, int length, int bound, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__LENGTH_IN_RANGE, >- "_UI_MaxLengthConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- Integer.toString(length), >- Integer.toString(bound) >- }, >- new Object [] { value, eDataType, length, bound }, >- context)); >- } >- >- protected void reportTotalDigitsViolation >- (EDataType eDataType, Object value, int totalDigits, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__TOTAL_DIGITS_IN_RANGE, >- "_UI_TotalDigitsConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- totalDigits >- }, >- new Object [] { value, eDataType, totalDigits }, >- context)); >- } >- >- protected void reportFractionDigitsViolation >- (EDataType eDataType, Object value, int fractionDigits, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__TOTAL_DIGITS_IN_RANGE, >- "_UI_FractionDigitsConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- fractionDigits >- }, >- new Object [] { value, eDataType, fractionDigits }, >- context)); >- } >- >- protected void reportEnumerationViolation >- (EDataType eDataType, Object value, Collection<?> values, DiagnosticChain diagnostics, Map<Object, Object> context) >+ protected void reportMinViolation( >+ EDataType eDataType, >+ Object value, >+ Object bound, >+ boolean isInclusive, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, DATA_VALUE__VALUE_IN_RANGE, isInclusive >+ ? "_UI_MinInclusiveConstraint_diagnostic" : "_UI_MinExclusiveConstraint_diagnostic", new Object []{ >+ getValueLabel(eDataType, value, context), >+ isInclusive ? ">=" : ">", >+ getValueLabel(eDataType, bound, context) }, new Object []{ value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, context)); >+ } >+ >+ protected void reportMaxViolation( >+ EDataType eDataType, >+ Object value, >+ Object bound, >+ boolean isInclusive, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, DATA_VALUE__VALUE_IN_RANGE, isInclusive >+ ? "_UI_MaxInclusiveConstraint_diagnostic" : "_UI_MaxExclusiveConstraint_diagnostic", new Object []{ >+ getValueLabel(eDataType, value, context), >+ "<", >+ getValueLabel(eDataType, bound, context) }, new Object []{ value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, context)); >+ } >+ >+ protected void reportMinLengthViolation( >+ EDataType eDataType, >+ Object value, >+ int length, >+ int bound, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__LENGTH_IN_RANGE, >+ "_UI_MinLengthConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), Integer.toString(length), Integer.toString(bound) }, >+ new Object []{ value, eDataType, length, bound }, >+ context)); >+ } >+ >+ protected void reportMaxLengthViolation( >+ EDataType eDataType, >+ Object value, >+ int length, >+ int bound, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__LENGTH_IN_RANGE, >+ "_UI_MaxLengthConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), Integer.toString(length), Integer.toString(bound) }, >+ new Object []{ value, eDataType, length, bound }, >+ context)); >+ } >+ >+ protected void reportTotalDigitsViolation( >+ EDataType eDataType, >+ Object value, >+ int totalDigits, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__TOTAL_DIGITS_IN_RANGE, >+ "_UI_TotalDigitsConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), totalDigits }, >+ new Object []{ value, eDataType, totalDigits }, >+ context)); >+ } >+ >+ protected void reportFractionDigitsViolation( >+ EDataType eDataType, >+ Object value, >+ int fractionDigits, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__TOTAL_DIGITS_IN_RANGE, >+ "_UI_FractionDigitsConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), fractionDigits }, >+ new Object []{ value, eDataType, fractionDigits }, >+ context)); >+ } >+ >+ protected void reportEnumerationViolation( >+ EDataType eDataType, >+ Object value, >+ Collection< ? > values, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) > { > String valueLiterals = ""; >- Iterator<?> i = values.iterator(); >+ Iterator< ? > i = values.iterator(); > if (i.hasNext()) > { >- valueLiterals = >- getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object [] { getValueLabel(eDataType, i.next(), context) }); >+ valueLiterals = getEcoreResourceLocator().getString( >+ "_UI_ListHead_composition", >+ new Object []{ getValueLabel(eDataType, i.next(), context) }); > while (i.hasNext()) > { >- valueLiterals = >- getEcoreResourceLocator().getString >- ("_UI_ListTail_composition", >- new Object [] { valueLiterals, getValueLabel(eDataType, i.next(), context) }); >- } >- } >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__VALUE_IN_ENUMERATION, >- "_UI_EnumerationConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- valueLiterals >- }, >- new Object [] { value, eDataType, values }, >- context)); >- } >- >- protected void reportDataValuePatternViolation >- (EDataType eDataType, Object value, PatternMatcher [] patterns, DiagnosticChain diagnostics, Map<Object, Object> context) >+ valueLiterals = getEcoreResourceLocator().getString( >+ "_UI_ListTail_composition", >+ new Object []{ valueLiterals, getValueLabel(eDataType, i.next(), context) }); >+ } >+ } >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__VALUE_IN_ENUMERATION, >+ "_UI_EnumerationConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), valueLiterals }, >+ new Object []{ value, eDataType, values }, >+ context)); >+ } >+ >+ protected void reportDataValuePatternViolation( >+ EDataType eDataType, >+ Object value, >+ PatternMatcher[] patterns, >+ DiagnosticChain diagnostics, >+ Map<Object, Object> context) > { > String patternLiterals = ""; > if (patterns.length > 0) > { >- patternLiterals = getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object [] { patterns[0] }); >+ patternLiterals = getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object []{ patterns[0] }); > for (int i = 1; i < patterns.length; ++i) > { >- patternLiterals = getEcoreResourceLocator().getString("_UI_ListTail_composition", new Object [] { patternLiterals, patterns[i] }); >+ patternLiterals = getEcoreResourceLocator().getString("_UI_ListTail_composition", new Object []{ patternLiterals, patterns[i] }); > } > } > >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__MATCHES_PATTERN, >- "_UI_PatternConstraint_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- patternLiterals >- }, >- new Object [] { value, eDataType, patterns }, >- context)); >- } >- >- protected void reportDataValueTypeViolation >- (EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) >- { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- DATA_VALUE__TYPE_CORRECT, >- "_UI_BadDataValueType_diagnostic", >- new Object [] >- { >- getValueLabel(eDataType, value, context), >- value == null ? "<null>" : value.getClass().getName(), >- eDataType.getInstanceClass().getName() >- }, >- new Object [] { value, eDataType }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__MATCHES_PATTERN, >+ "_UI_PatternConstraint_diagnostic", >+ new Object []{ getValueLabel(eDataType, value, context), patternLiterals }, >+ new Object []{ value, eDataType, patterns }, >+ context)); >+ } >+ >+ protected void reportDataValueTypeViolation(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) >+ { >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ DATA_VALUE__TYPE_CORRECT, >+ "_UI_BadDataValueType_diagnostic", >+ new Object []{ >+ getValueLabel(eDataType, value, context), >+ value == null ? "<null>" : value.getClass().getName(), >+ eDataType.getInstanceClass().getName() }, >+ new Object []{ value, eDataType }, >+ context)); > } > >- protected static Collection<Object> wrapEnumerationValues(Object [] values) >+ protected static Collection<Object> wrapEnumerationValues(Object[] values) > { > return java.util.Arrays.asList(values); > } >- >+ > /** > * @since 2.2 > */ >@@ -1175,20 +1139,14 @@ > if (eObject != otherEObject && otherEObject != null) > { > // ... >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__UNIQUE_ID, >- "_UI_DuplicateID_diagnostic", >- new Object [] >- { >- id, >- getObjectLabel(eObject, context), >- getObjectLabel(otherEObject, context) >- }, >- new Object [] { eObject, otherEObject, id }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__UNIQUE_ID, >+ "_UI_DuplicateID_diagnostic", >+ new Object []{ id, getObjectLabel(eObject, context), getObjectLabel(otherEObject, context) }, >+ new Object []{ eObject, otherEObject, id }, >+ context)); > } > } > } >@@ -1224,7 +1182,7 @@ > } > return result; > } >- >+ > /** > * @since 2.3 > * @param eObject >@@ -1233,17 +1191,16 @@ > * @param context > * @return whether every key is unique. > */ >- protected boolean validate_KeyUnique >- (EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context) >+ protected boolean validate_KeyUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context) > { > boolean result = true; > Map<List<Object>, EObject> keys = new HashMap<List<Object>, EObject>(); >- EAttribute [] eAttributes = (EAttribute[])((BasicEList<?>)eReference.getEKeys()).data(); >+ EAttribute[] eAttributes = (EAttribute[])((BasicEList< ? >)eReference.getEKeys()).data(); > @SuppressWarnings("unchecked") > List<EObject> values = (List<EObject>)eObject.eGet(eReference); > for (EObject value : values) > { >- ArrayList<Object> key = new ArrayList<Object>(); >+ ArrayList<Object> key = new ArrayList<Object>(); > for (int i = 0, size = eAttributes.length; i < size; ++i) > { > EAttribute eAttribute = eAttributes[i]; >@@ -1251,7 +1208,7 @@ > { > break; > } >- else >+ else > { > key.add(value.eGet(eAttribute)); > } >@@ -1272,21 +1229,18 @@ > { > uriFragmentSegment = uriFragmentSegment.substring(index); > } >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_KEY_UNIQUE, >- "_UI_DuplicateKey_diagnostic", >- new Object [] >- { >- getFeatureLabel(eReference, context), >- uriFragmentSegment, >- getObjectLabel(value, context), >- getObjectLabel(otherValue, context) >- }, >- new Object [] { eObject, eReference, value, otherValue }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_KEY_UNIQUE, >+ "_UI_DuplicateKey_diagnostic", >+ new Object []{ >+ getFeatureLabel(eReference, context), >+ uriFragmentSegment, >+ getObjectLabel(value, context), >+ getObjectLabel(otherValue, context) }, >+ new Object []{ eObject, eReference, value, otherValue }, >+ context)); > } > } > } >@@ -1329,19 +1283,18 @@ > * @param context > * @return whether every map entry is unique. > */ >- protected boolean validate_MapEntryUnique >- (EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context) >+ protected boolean validate_MapEntryUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context) > { > boolean result = true; > Object value = eObject.eGet(eReference); >- if (value instanceof EMap<?, ?>) >+ if (value instanceof EMap< ? , ? >) > { >- EMap<?, ?> eMap = (EMap<?, ?>)value; >+ EMap< ? , ? > eMap = (EMap< ? , ? >)value; > for (int i = 0, size = eMap.size(); i < size; ++i) > { >- Map.Entry<?, ?> entry = eMap.get(i); >+ Map.Entry< ? , ? > entry = eMap.get(i); > Object key = entry.getKey(); >- int index = eMap.indexOfKey(key); >+ int index = eMap.indexOfKey(key); > if (index != i) > { > result = false; >@@ -1351,20 +1304,14 @@ > } > else > { >- diagnostics.add >- (createDiagnostic >- (Diagnostic.ERROR, >- DIAGNOSTIC_SOURCE, >- EOBJECT__EVERY_MAP_ENTRY_UNIQUE, >- "_UI_DuplicateMapEntry_diagnostic", >- new Object [] >- { >- getFeatureLabel(eReference, context), >- i, >- index >- }, >- new Object [] { eObject, eReference, entry, eMap.get(index) }, >- context)); >+ diagnostics.add(createDiagnostic( >+ Diagnostic.ERROR, >+ DIAGNOSTIC_SOURCE, >+ EOBJECT__EVERY_MAP_ENTRY_UNIQUE, >+ "_UI_DuplicateMapEntry_diagnostic", >+ new Object []{ getFeatureLabel(eReference, context), i, index }, >+ new Object []{ eObject, eReference, entry, eMap.get(index) }, >+ context)); > } > } > } >@@ -1374,6 +1321,116 @@ > } > > /** >+ * @since 2.5 >+ * @param theEClass >+ * @param object >+ * @param theDiagnostics >+ * @param context >+ * @return >+ */ >+ protected boolean validate_UserConstraintsByEClass( >+ EClass theEClass, >+ EObject object, >+ DiagnosticChain theDiagnostics, >+ Map<Object, Object> context) >+ { >+ Collection<EAnnotation> annotations = theEClass.getEAnnotations(); >+ Collection<String> constraints = new LinkedList<String>(); >+ String factoryName = ""; >+ String keyName = ""; >+ boolean result = true; >+ boolean inheritsConstraints = true; >+ for (EAnnotation e : annotations) >+ { >+ if (USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE.equals(e.getSource())) >+ { >+ // check if user specifies how to manage constraints inheritance >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE)) >+ { >+ String value = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE); >+ if (value != null && ("true".equals(value.trim().toLowerCase()) || "false".equals(value.trim().toLowerCase()))) >+ { >+ inheritsConstraints = Boolean.valueOf(value); >+ } >+ } >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS)) >+ { >+ String strConstraints = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS); >+ >+ String[] stringSplited = strConstraints.split("\\s"); >+ Collections.addAll(constraints, stringSplited); >+ if (stringSplited != null && stringSplited.length > 0) >+ { >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY)) >+ { >+ String strFactory = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY); >+ String[] strs = strFactory.split("#"); >+ if (strs != null && strs.length == 2) >+ { >+ factoryName = strs[0]; >+ keyName = strs[1]; >+ } >+ else >+ { >+ factoryName = strFactory; >+ keyName = strFactory; >+ } >+ } >+ } >+ break; >+ } >+ } >+ } >+ if (inheritsConstraints) >+ { >+ for (EClass c : theEClass.getESuperTypes()) >+ { >+ result &= validate_UserConstraintsByEClass(c, object, theDiagnostics, context); >+ } >+ } >+ if (constraints.size() > 0 && keyName.length() > 0 && factoryName.length() > 0) >+ { >+ for (String currentConstraint : constraints) >+ { >+ for (EAnnotation e : annotations) >+ { >+ if (keyName.equals(e.getSource())) >+ { >+ if (e.getDetails().containsKey(currentConstraint)) >+ { >+ String rule = e.getDetails().get(currentConstraint); >+ Factory factory = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(factoryName); >+ if (factory != null) >+ { >+ ConstraintsDelegator constraintDelegator = factory.createConstraintDelegator(); >+ if (constraintDelegator != null) >+ { >+ result &= constraintDelegator.validate(rule, object, theDiagnostics, context); >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+ /** >+ * @since 2.5 >+ * @param object >+ * @param theDiagnostics >+ * @param context >+ * @return >+ */ >+ protected boolean validate_UserConstraints(EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context) >+ { >+ EClass theclass = object.eClass(); >+ boolean result = validate_UserConstraintsByEClass(theclass, object, theDiagnostics, context); >+ return result; >+ } >+ >+ /** > * Creates a new {@link BasicDiagnostic#BasicDiagnostic(int, String, int, String, Object[]) basic diagnostic}. > * If the source is {@link #DIAGNOSTIC_SOURCE "org.eclipse.emf.ecore"}, > * it calls {@link #getEcoreString(String, Object[])}; >@@ -1389,13 +1446,18 @@ > * @see BasicDiagnostic#BasicDiagnostic(int, String, int, String, Object[]) > * @since 2.4 > */ >- protected BasicDiagnostic createDiagnostic >- (int severity, String source, int code, String messageKey, Object[] messageSubstitutions, Object[] data, Map<Object, Object> context) >- { >- String message = >- DIAGNOSTIC_SOURCE.equals(source) ? >- getEcoreString(messageKey, messageSubstitutions) : >- getString(messageKey, messageSubstitutions); >+ protected BasicDiagnostic createDiagnostic( >+ int severity, >+ String source, >+ int code, >+ String messageKey, >+ Object[] messageSubstitutions, >+ Object[] data, >+ Map<Object, Object> context) >+ { >+ String message = DIAGNOSTIC_SOURCE.equals(source) ? getEcoreString(messageKey, messageSubstitutions) : getString( >+ messageKey, >+ messageSubstitutions); > return new BasicDiagnostic(severity, source, code, message, data); > } > >@@ -1407,7 +1469,7 @@ > * @return the message. > * @since 2.4 > */ >- protected String getEcoreString(String key, Object [] substitutions) >+ protected String getEcoreString(String key, Object[] substitutions) > { > return getString(getEcoreResourceLocator(), key, substitutions); > } >@@ -1430,7 +1492,7 @@ > * @return the message. > * @since 2.4 > */ >- protected String getString(String key, Object [] substitutions) >+ protected String getString(String key, Object[] substitutions) > { > return getString("_UI_GenericConstraint_diagnostic".equals(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions); > } >@@ -1447,7 +1509,7 @@ > return getEcoreResourceLocator(); > } > >- private String getString(ResourceLocator resourceLocator, String key, Object [] substitutions) >+ private String getString(ResourceLocator resourceLocator, String key, Object[] substitutions) > { > return substitutions == null ? resourceLocator.getString(key) : resourceLocator.getString(key, substitutions); > } >Index: src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >diff -N src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id: EMF_codetemplates.xml,v 1.1 2008/05/06 20:12:20 nickb Exp $ >+ */ >+package org.eclipse.emf.ecore.plugin; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.common.util.WrappedException; >+import org.eclipse.emf.ecore.util.ConstraintsDelegator; >+import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory; >+ >+/** >+ * A plugin extension reader that populates the >+ * {@link org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory.Registry#INSTANCE global} resource factory's >+ * Clients are not expected to use this class directly. >+ */ >+public class ConstraintsDelegatorFactoryRegistryReader extends RegistryReader >+{ >+ static final String TAG_FACTORY = "factory"; >+ static final String ATT_URI = "uri"; >+ static final String ATT_CLASS = "class"; >+ >+ public ConstraintsDelegatorFactoryRegistryReader() >+ { >+ super >+ (Platform.getExtensionRegistry(), >+ EcorePlugin.getPlugin().getBundle().getSymbolicName(), >+ EcorePlugin.CONSTRAINTS_DELEGATOR_FACTORY); >+ } >+ >+ @Override >+ protected boolean readElement(IConfigurationElement element, boolean add) >+ { >+ if (element.getName().equals(TAG_FACTORY)) >+ { >+ String packageURI = element.getAttribute(ATT_URI); >+ if (packageURI == null) >+ { >+ logMissingAttribute(element, ATT_URI); >+ } >+ else if (element.getAttribute(ATT_CLASS) == null) >+ { >+ logMissingAttribute(element, ATT_CLASS); >+ } >+ else >+ { >+ try >+ { >+ Object o = element.createExecutableExtension(ATT_CLASS); >+ if (o instanceof ConstraintsDelegator.Factory) >+ { >+ Factory tmp = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(packageURI); >+ if (tmp != null) >+ { >+ EcorePlugin.INSTANCE.log >+ ("factory '" + o.getClass().getName() + "'tries to override '" + packageURI + "' instead of factor '" + tmp.getClass().getName()+"'"); >+ } >+ else >+ { >+ ConstraintsDelegator.Factory.Registry.INSTANCE.putFactory(packageURI, (Factory)o); >+ } >+ } >+ return true; >+ } >+ catch (CoreException e) >+ { >+ throw new WrappedException(e); >+ } >+ } >+ } >+ return false; >+ } >+} >Index: schema/constraints_delegator_registry.exsd >=================================================================== >RCS file: schema/constraints_delegator_registry.exsd >diff -N schema/constraints_delegator_registry.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/constraints_delegator_registry.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.emf.ecore" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.emf.ecore" id="constraints_delegator_registry" name="%_UI_ConstraintsDelegatorRegistry_extensionpoint"/> >+ </appinfo> >+ <documentation> >+ Adds a ConstraintDelegatorFactory to check constraints in Ecore models >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="factory"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="factory"> >+ <complexType> >+ <attribute name="uri" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the uri which will be inserted by user to check constraints >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A fully qualified name of the Java class implementing <samp>org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory >+</samp>. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ 2.5.0 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ Following is an example of implementation >+<pre> >+<extension >+ point="org.eclipse.emf.ecore.constraints_delegator_regstry"> >+ <factory >+ class="ocl.test.ConstraintsDelegator.MyFactory" >+ uri="org.eclipse.emf.ocl"> >+ </factory> >+ </extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2002, 2004 IBM Corporation and others.<br> >+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >diff -N src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id: ConstraintsDelegator.java,v 1.0 2008/11/19 16:37:42 tfaure Exp $ >+ */ >+package org.eclipse.emf.ecore.util; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.emf.common.util.DiagnosticChain; >+import org.eclipse.emf.ecore.EObject; >+ >+ >+/** >+ * An interface to validate a constraint >+ * The only method to implement is {@link #validate(String, EObject, DiagnosticChain, Map) >+ * To add a factory please see extension point : constraints_delegator_regstry >+ */ >+public interface ConstraintsDelegator >+{ >+ interface Factory >+ { >+ interface Registry >+ { >+ Registry INSTANCE = new Impl(); >+ >+ /** >+ * Returns the factory identified by the key >+ * @param key the factory id >+ * @return the factory or null if it doesn't exist >+ */ >+ Factory getFactory(String key); >+ >+ /** >+ * Registers a factory and associates it to an id >+ * @param key the id >+ * @param value the factory >+ */ >+ void putFactory(String key, Factory value); >+ >+ class Impl extends HashMap<String, Factory> implements Registry >+ { >+ private static final long serialVersionUID = 1L; >+ >+ public Factory getFactory(String key) >+ { >+ return get(key); >+ } >+ >+ public void putFactory(String key, Factory value) >+ { >+ put(key, value); >+ } >+ } >+ } >+ >+ /** >+ * Create a constraint delegator which is able to check a constraint >+ * @return the constraint Delegator >+ */ >+ ConstraintsDelegator createConstraintDelegator(); >+ } >+ >+ /** >+ * Validate a constraint and add to the diagnostic chain the evaluation's diagnostic >+ * @param value the expression to manage >+ * @param object the current EObject >+ * @param theDiagnostics the diagnostic's chain >+ * @param context the context of the current validation >+ * @return true if it's OK else false >+ */ >+ boolean validate(String value, EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255786
:
118244
|
118245
|
118338
|
123880
|
123881
|
123883
|
123885
|
126724
|
126725
|
126726
|
126727
|
126729
|
146761
|
146762
|
146778
|
146787
|
147341
|
147449
|
147455
|
147479