Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 255786 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+1 lines)
Lines 10-15 Link Here
10
   <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/>
10
   <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/>
11
   <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/>
11
   <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/>
12
   <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/>
12
   <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/>
13
   <extension-point id="constraints_delegator_regstry" name="%_UI_ConstraintsDelegatorRegistry_extensionpoint" schema="schema/constraints_delegator_regstry.exsd"/>
13
14
14
   <extension point="org.eclipse.emf.ecore.generated_package">
15
   <extension point="org.eclipse.emf.ecore.generated_package">
15
      <package
16
      <package
(-)plugin.properties (+2 lines)
Lines 113-118 Link Here
113
_UI_ContentHandler_extensionpoint = Content Handler Registry
113
_UI_ContentHandler_extensionpoint = Content Handler Registry
114
_UI_URIMappingRegistry_extensionpoint = URI Converter Mapping Registry
114
_UI_URIMappingRegistry_extensionpoint = URI Converter Mapping Registry
115
_UI_PackageRegistryImplementation_extensionpoint = Ecore Package Registry Implementation
115
_UI_PackageRegistryImplementation_extensionpoint = Ecore Package Registry Implementation
116
_UI_ConstraintsDelegatorRegistry_extensionpoint = Constraints Delegator Registry
117
116
118
117
_UI_GenericInvariant_diagnostic = The ''{0}'' invariant is violated on ''{1}''
119
_UI_GenericInvariant_diagnostic = The ''{0}'' invariant is violated on ''{1}''
118
_UI_GenericConstraint_diagnostic = The ''{0}'' constraint is violated on ''{1}''
120
_UI_GenericConstraint_diagnostic = The ''{0}'' constraint is violated on ''{1}''
(-)src/org/eclipse/emf/ecore/plugin/EcorePlugin.java (+2 lines)
Lines 575-580 Link Here
575
      new ContentParserRegistryReader().readRegistry();
575
      new ContentParserRegistryReader().readRegistry();
576
      new ContentHandlerRegistryReader().readRegistry();
576
      new ContentHandlerRegistryReader().readRegistry();
577
      new URIMappingRegistryReader().readRegistry();
577
      new URIMappingRegistryReader().readRegistry();
578
      new ConstraintsDelegatorFactoryRegistryReader().readRegistry();
578
    }
579
    }
579
  }
580
  }
580
581
Lines 631-634 Link Here
631
  public static final String SCHEME_PARSER_PPID = "scheme_parser";
632
  public static final String SCHEME_PARSER_PPID = "scheme_parser";
632
  public static final String URI_MAPPING_PPID = "uri_mapping";
633
  public static final String URI_MAPPING_PPID = "uri_mapping";
633
  public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation";
634
  public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation";
635
  public static final String CONSTRAINTS_DELEGATOR_FACTORY = "constraints_delegator_regstry";
634
}
636
}
(-)src/org/eclipse/emf/ecore/util/EObjectValidator.java (-407 / +452 lines)
Lines 16-26 Link Here
16
 */
16
 */
17
package org.eclipse.emf.ecore.util;
17
package org.eclipse.emf.ecore.util;
18
18
19
20
import java.util.ArrayList;
19
import java.util.ArrayList;
21
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Collections;
22
import java.util.HashMap;
22
import java.util.HashMap;
23
import java.util.Iterator;
23
import java.util.Iterator;
24
import java.util.LinkedList;
24
import java.util.List;
25
import java.util.List;
25
import java.util.ListIterator;
26
import java.util.ListIterator;
26
import java.util.Map;
27
import java.util.Map;
Lines 37-42 Link Here
37
38
38
import org.eclipse.emf.ecore.EValidator;
39
import org.eclipse.emf.ecore.EValidator;
39
40
41
import org.eclipse.emf.ecore.EAnnotation;
40
import org.eclipse.emf.ecore.EAttribute;
42
import org.eclipse.emf.ecore.EAttribute;
41
import org.eclipse.emf.ecore.EObject;
43
import org.eclipse.emf.ecore.EObject;
42
import org.eclipse.emf.ecore.EClass;
44
import org.eclipse.emf.ecore.EClass;
Lines 51-56 Link Here
51
53
52
import org.eclipse.emf.ecore.resource.Resource;
54
import org.eclipse.emf.ecore.resource.Resource;
53
import org.eclipse.emf.ecore.resource.ResourceSet;
55
import org.eclipse.emf.ecore.resource.ResourceSet;
56
import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory;
54
57
55
import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil;
58
import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil;
56
59
Lines 60-65 Link Here
60
 */
63
 */
61
public class EObjectValidator implements EValidator
64
public class EObjectValidator implements EValidator
62
{
65
{
66
  private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY = "factory";
67
68
  private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS = "constraints";
69
70
  private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE = "Ecore";
71
63
  public static final EObjectValidator INSTANCE = new EObjectValidator();
72
  public static final EObjectValidator INSTANCE = new EObjectValidator();
64
73
65
  public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecore";
74
  public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.ecore";
Lines 78-84 Link Here
78
  public static final int EOBJECT__UNIQUE_ID = 12;
87
  public static final int EOBJECT__UNIQUE_ID = 12;
79
  public static final int EOBJECT__EVERY_KEY_UNIQUE = 13;
88
  public static final int EOBJECT__EVERY_KEY_UNIQUE = 13;
80
  public static final int EOBJECT__EVERY_MAP_ENTRY_UNIQUE = 14;
89
  public static final int EOBJECT__EVERY_MAP_ENTRY_UNIQUE = 14;
81
  
90
82
  static final int EOBJECT_DIAGNOSTIC_CODE_COUNT = EOBJECT__EVERY_MAP_ENTRY_UNIQUE;
91
  static final int EOBJECT_DIAGNOSTIC_CODE_COUNT = EOBJECT__EVERY_MAP_ENTRY_UNIQUE;
83
92
84
  /**
93
  /**
Lines 173-182 Link Here
173
    else
182
    else
174
    {
183
    {
175
      List<EClass> eSuperTypes = eClass.getESuperTypes();
184
      List<EClass> eSuperTypes = eClass.getESuperTypes();
176
      return
185
      return eSuperTypes.isEmpty() ? validate_EveryDefaultConstraint(eObject, diagnostics, context) : validate(
177
        eSuperTypes.isEmpty() ?
186
        eSuperTypes.get(0),
178
          validate_EveryDefaultConstraint(eObject, diagnostics, context) :
187
        eObject,
179
          validate(eSuperTypes.get(0), eObject, diagnostics, context);
188
        diagnostics,
189
        context);
180
    }
190
    }
181
  }
191
  }
182
192
Lines 212-217 Link Here
212
    {
222
    {
213
      result &= validate_EveryMapEntryUnique(object, theDiagnostics, context);
223
      result &= validate_EveryMapEntryUnique(object, theDiagnostics, context);
214
    }
224
    }
225
    // ADDS FOR MANAGING USER CONSTRAINTS
226
    if (result || theDiagnostics != null)
227
    {
228
      result &= validate_UserConstraints(object, theDiagnostics, context);
229
    }
230
    return result;
231
  }
232
233
  /**
234
   * @since 2.5
235
   * @param object
236
   * @param theDiagnostics
237
   * @param context
238
   * @return
239
   */
240
  protected boolean validate_UserConstraints(EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context)
241
  {
242
    EClass theclass = object.eClass();
243
    Collection<EAnnotation> annotations = theclass.getEAnnotations();
244
    Collection<String> constraints = new LinkedList<String>();
245
    String factoryName = "";
246
    String keyName = "";
247
    boolean result = true;
248
    for (EAnnotation e : annotations)
249
    {
250
      if (USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE.equals(e.getSource()))
251
      {
252
        if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS))
253
        {
254
          String strConstraints = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_CONSTRAINTS);
255
256
          String[] stringSplited = strConstraints.split(" ");
257
          Collections.addAll(constraints, stringSplited);
258
          if (stringSplited != null && stringSplited.length > 0)
259
          {
260
            if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY))
261
            {
262
              String strFactory = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY);
263
              String[] strs = strFactory.split("#");
264
              if (strs != null && strs.length == 2)
265
              {
266
                factoryName = strs[0];
267
                keyName = strs[1];
268
              }
269
              else
270
              {
271
                factoryName = strFactory;
272
                keyName = strFactory;
273
              }
274
            }
275
          }
276
          break;
277
        }
278
      }
279
    }
280
    if (constraints.size() > 0 && keyName.length() > 0 && factoryName.length() > 0)
281
    {
282
      for (String currentConstraint : constraints)
283
      {
284
        for (EAnnotation e : annotations)
285
        {
286
          if (keyName.equals(e.getSource()))
287
          {
288
            if (e.getDetails().containsKey(currentConstraint))
289
            {
290
              String rule = e.getDetails().get(currentConstraint);
291
              Factory factory = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(factoryName);
292
              if (factory != null)
293
              {
294
                ConstraintsDelegator constraintDelegator = factory.createConstraintDelegator();
295
                if (constraintDelegator != null)
296
                {
297
                  result &= constraintDelegator.validate(rule, object, theDiagnostics, context);
298
                }
299
              }
300
            }
301
          }
302
        }
303
      }
304
    }
215
    return result;
305
    return result;
216
  }
306
  }
217
307
Lines 229-237 Link Here
229
    }
319
    }
230
    return result;
320
    return result;
231
  }
321
  }
232
  
322
233
  protected boolean validate_MultiplicityConforms
323
  protected boolean validate_MultiplicityConforms(
234
    (EObject eObject, EStructuralFeature eStructuralFeature, DiagnosticChain diagnostics, Map<Object, Object> context)
324
    EObject eObject,
325
    EStructuralFeature eStructuralFeature,
326
    DiagnosticChain diagnostics,
327
    Map<Object, Object> context)
235
  {
328
  {
236
    boolean result = true;
329
    boolean result = true;
237
    if (eStructuralFeature.isMany())
330
    if (eStructuralFeature.isMany())
Lines 239-265 Link Here
239
      int lowerBound = eStructuralFeature.getLowerBound();
332
      int lowerBound = eStructuralFeature.getLowerBound();
240
      if (lowerBound > 0)
333
      if (lowerBound > 0)
241
      {
334
      {
242
        int size = ((List<?>)eObject.eGet(eStructuralFeature)).size();
335
        int size = ((List< ? >)eObject.eGet(eStructuralFeature)).size();
243
        if (size < lowerBound)
336
        if (size < lowerBound)
244
        {
337
        {
245
          result = false;
338
          result = false;
246
          if (diagnostics != null)
339
          if (diagnostics != null)
247
          {
340
          {
248
            diagnostics.add
341
            diagnostics.add(createDiagnostic(
249
              (createDiagnostic
342
              Diagnostic.ERROR,
250
                (Diagnostic.ERROR,
343
              DIAGNOSTIC_SOURCE,
251
                 DIAGNOSTIC_SOURCE,
344
              EOBJECT__EVERY_MULTIPCITY_CONFORMS,
252
                 EOBJECT__EVERY_MULTIPCITY_CONFORMS,
345
              "_UI_FeatureHasTooFewValues_diagnostic",
253
                 "_UI_FeatureHasTooFewValues_diagnostic",
346
              new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context), size, lowerBound },
254
                  new Object []
347
              new Object []{ eObject, eStructuralFeature },
255
                  {
348
              context));
256
                    getFeatureLabel(eStructuralFeature, context),
257
                    getObjectLabel(eObject, context),
258
                    size,
259
                    lowerBound
260
                  },
261
                 new Object [] { eObject, eStructuralFeature },
262
                 context));
263
          }
349
          }
264
        }
350
        }
265
        int upperBound = eStructuralFeature.getUpperBound();
351
        int upperBound = eStructuralFeature.getUpperBound();
Lines 268-288 Link Here
268
          result = false;
354
          result = false;
269
          if (diagnostics != null)
355
          if (diagnostics != null)
270
          {
356
          {
271
            diagnostics.add
357
            diagnostics.add(createDiagnostic(
272
              (createDiagnostic
358
              Diagnostic.ERROR,
273
                (Diagnostic.ERROR,
359
              DIAGNOSTIC_SOURCE,
274
                 DIAGNOSTIC_SOURCE,
360
              EOBJECT__EVERY_MULTIPCITY_CONFORMS,
275
                 EOBJECT__EVERY_MULTIPCITY_CONFORMS,
361
              "_UI_FeatureHasTooManyValues_diagnostic",
276
                 "_UI_FeatureHasTooManyValues_diagnostic",
362
              new Object []{
277
                 new Object []
363
                getFeatureLabel(eStructuralFeature, context),
278
                 {
364
                getObjectLabel(eObject, context),
279
                   getFeatureLabel(eStructuralFeature, context),
365
                new Integer(size),
280
                   getObjectLabel(eObject, context),
366
                new Integer(upperBound) },
281
                   new Integer(size),
367
              new Object []{ eObject, eStructuralFeature },
282
                   new Integer(upperBound)
368
              context));
283
                 },
284
                 new Object [] { eObject, eStructuralFeature },
285
                 context));
286
          }
369
          }
287
        }
370
        }
288
      }
371
      }
Lines 291-317 Link Here
291
        int upperBound = eStructuralFeature.getUpperBound();
374
        int upperBound = eStructuralFeature.getUpperBound();
292
        if (upperBound > 0)
375
        if (upperBound > 0)
293
        {
376
        {
294
          int size = ((List<?>)eObject.eGet(eStructuralFeature)).size();
377
          int size = ((List< ? >)eObject.eGet(eStructuralFeature)).size();
295
          if (size > upperBound)
378
          if (size > upperBound)
296
          {
379
          {
297
            result = false;
380
            result = false;
298
            if (diagnostics != null)
381
            if (diagnostics != null)
299
            {
382
            {
300
              diagnostics.add
383
              diagnostics.add(createDiagnostic(
301
                (createDiagnostic
384
                Diagnostic.ERROR,
302
                  (Diagnostic.ERROR,
385
                DIAGNOSTIC_SOURCE,
303
                   DIAGNOSTIC_SOURCE,
386
                EOBJECT__EVERY_MULTIPCITY_CONFORMS,
304
                   EOBJECT__EVERY_MULTIPCITY_CONFORMS,
387
                "_UI_FeatureHasTooManyValues_diagnostic",
305
                   "_UI_FeatureHasTooManyValues_diagnostic",
388
                new Object []{
306
                   new Object []
389
                  getFeatureLabel(eStructuralFeature, context),
307
                   {
390
                  getObjectLabel(eObject, context),
308
                     getFeatureLabel(eStructuralFeature, context),
391
                  new Integer(size),
309
                     getObjectLabel(eObject, context),
392
                  new Integer(upperBound) },
310
                     new Integer(size),
393
                new Object []{ eObject, eStructuralFeature },
311
                     new Integer(upperBound)
394
                context));
312
                   },
313
                   new Object [] { eObject, eStructuralFeature },
314
                   context));
315
            }
395
            }
316
          }
396
          }
317
        }
397
        }
Lines 324-338 Link Here
324
        result = false;
404
        result = false;
325
        if (diagnostics != null)
405
        if (diagnostics != null)
326
        {
406
        {
327
          diagnostics.add
407
          diagnostics.add(createDiagnostic(
328
            (createDiagnostic
408
            Diagnostic.ERROR,
329
              (Diagnostic.ERROR,
409
            DIAGNOSTIC_SOURCE,
330
               DIAGNOSTIC_SOURCE,
410
            EOBJECT__EVERY_MULTIPCITY_CONFORMS,
331
               EOBJECT__EVERY_MULTIPCITY_CONFORMS,
411
            "_UI_RequiredFeatureMustBeSet_diagnostic",
332
               "_UI_RequiredFeatureMustBeSet_diagnostic",
412
            new Object []{ getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context) },
333
               new Object [] { getFeatureLabel(eStructuralFeature, context), getObjectLabel(eObject, context) },
413
            new Object []{ eObject, eStructuralFeature },
334
               new Object [] { eObject, eStructuralFeature },
414
            context));
335
               context));
336
        }
415
        }
337
      }
416
      }
338
    }
417
    }
Lines 343-349 Link Here
343
  public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
422
  public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
344
  {
423
  {
345
    boolean result = true;
424
    boolean result = true;
346
    for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext(); )
425
    for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext();)
347
    {
426
    {
348
      EObject eCrossReferenceObject = i.next();
427
      EObject eCrossReferenceObject = i.next();
349
      if (eCrossReferenceObject.eIsProxy())
428
      if (eCrossReferenceObject.eIsProxy())
Lines 351-370 Link Here
351
        result = false;
430
        result = false;
352
        if (diagnostics != null)
431
        if (diagnostics != null)
353
        {
432
        {
354
          diagnostics.add
433
          diagnostics.add(createDiagnostic(
355
            (createDiagnostic
434
            Diagnostic.ERROR,
356
              (Diagnostic.ERROR,
435
            DIAGNOSTIC_SOURCE,
357
               DIAGNOSTIC_SOURCE,
436
            EOBJECT__EVERY_PROXY_RESOLVES,
358
               EOBJECT__EVERY_PROXY_RESOLVES,
437
            "_UI_UnresolvedProxy_diagnostic",
359
               "_UI_UnresolvedProxy_diagnostic",
438
            new Object []{
360
               new Object []
439
              getFeatureLabel(i.feature(), context),
361
               {
440
              getObjectLabel(eObject, context),
362
                 getFeatureLabel(i.feature(), context),
441
              getObjectLabel(eCrossReferenceObject, context) },
363
                 getObjectLabel(eObject, context),
442
            new Object []{ eObject, i.feature(), eCrossReferenceObject },
364
                 getObjectLabel(eCrossReferenceObject, context)
443
            context));
365
               },
366
               new Object [] { eObject, i.feature(), eCrossReferenceObject },
367
               context));
368
        }
444
        }
369
        else
445
        else
370
        {
446
        {
Lines 380-386 Link Here
380
    boolean result = true;
456
    boolean result = true;
381
    if (eObject.eResource() != null)
457
    if (eObject.eResource() != null)
382
    {
458
    {
383
      for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext(); )
459
      for (EContentsEList.FeatureIterator<EObject> i = (EContentsEList.FeatureIterator<EObject>)eObject.eCrossReferences().iterator(); i.hasNext();)
384
      {
460
      {
385
        EObject eCrossReferenceObject = i.next();
461
        EObject eCrossReferenceObject = i.next();
386
        if (eCrossReferenceObject.eResource() == null && !eCrossReferenceObject.eIsProxy() && !i.feature().isTransient())
462
        if (eCrossReferenceObject.eResource() == null && !eCrossReferenceObject.eIsProxy() && !i.feature().isTransient())
Lines 388-407 Link Here
388
          result = false;
464
          result = false;
389
          if (diagnostics != null)
465
          if (diagnostics != null)
390
          {
466
          {
391
            diagnostics.add
467
            diagnostics.add(createDiagnostic(
392
              (createDiagnostic
468
              Diagnostic.ERROR,
393
                (Diagnostic.ERROR,
469
              DIAGNOSTIC_SOURCE,
394
                 DIAGNOSTIC_SOURCE,
470
              EOBJECT__EVERY_REFERENCE_IS_CONTAINED,
395
                 EOBJECT__EVERY_REFERENCE_IS_CONTAINED,
471
              "_UI_DanglingReference_diagnostic",
396
                 "_UI_DanglingReference_diagnostic",
472
              new Object []{
397
                 new Object []
473
                getFeatureLabel(i.feature(), context),
398
                 {
474
                getObjectLabel(eObject, context),
399
                   getFeatureLabel(i.feature(), context),
475
                getObjectLabel(eCrossReferenceObject, context) },
400
                   getObjectLabel(eObject, context),
476
              new Object []{ eObject, i.feature(), eCrossReferenceObject },
401
                   getObjectLabel(eCrossReferenceObject, context)
477
              context));
402
                 },
403
                 new Object [] { eObject, i.feature(), eCrossReferenceObject },
404
                 context));
405
          }
478
          }
406
          else
479
          else
407
          {
480
          {
Lines 427-434 Link Here
427
    return result;
500
    return result;
428
  }
501
  }
429
502
430
  protected boolean validate_DataValueConforms
503
  protected boolean validate_DataValueConforms(
431
    (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
504
    EObject eObject,
505
    EAttribute eAttribute,
506
    DiagnosticChain diagnostics,
507
    Map<Object, Object> context)
432
  {
508
  {
433
    if (!eObject.eIsSet(eAttribute))
509
    if (!eObject.eIsSet(eAttribute))
434
    {
510
    {
Lines 440-454 Link Here
440
    Object value = eObject.eGet(eAttribute);
516
    Object value = eObject.eGet(eAttribute);
441
    if (FeatureMapUtil.isFeatureMap(eAttribute))
517
    if (FeatureMapUtil.isFeatureMap(eAttribute))
442
    {
518
    {
443
      @SuppressWarnings("unchecked") Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
519
      @SuppressWarnings("unchecked")
520
      Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
444
      EClass eClass = eObject.eClass();
521
      EClass eClass = eObject.eClass();
445
      Map<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
522
      Map<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
446
      for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null); )
523
      for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null);)
447
      {
524
      {
448
        FeatureMap.Entry entry = i.next();
525
        FeatureMap.Entry entry = i.next();
449
        EStructuralFeature entryFeature = entry.getEStructuralFeature();
526
        EStructuralFeature entryFeature = entry.getEStructuralFeature();
450
        if (entryFeature instanceof EAttribute &&
527
        if (entryFeature instanceof EAttribute && ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
451
              ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
452
        {
528
        {
453
          EDataType entryType = (EDataType)entryFeature.getEType();
529
          EDataType entryType = (EDataType)entryFeature.getEType();
454
          Object entryValue = entry.getValue();
530
          Object entryValue = entry.getValue();
Lines 476-482 Link Here
476
    }
552
    }
477
    else if (eAttribute.isMany())
553
    else if (eAttribute.isMany())
478
    {
554
    {
479
      for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && result; )
555
      for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && result;)
480
      {
556
      {
481
        result &= rootValidator.validate(eDataType, i.next(), null, context);
557
        result &= rootValidator.validate(eDataType, i.next(), null, context);
482
      }
558
      }
Lines 484-490 Link Here
484
      if (!result && diagnostics != null)
560
      if (!result && diagnostics != null)
485
      {
561
      {
486
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
562
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
487
        for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext(); )
563
        for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext();)
488
        {
564
        {
489
          rootValidator.validate(eDataType, i.next(), diagnostic, context);
565
          rootValidator.validate(eDataType, i.next(), diagnostic, context);
490
        }
566
        }
Lines 503-535 Link Here
503
    return result;
579
    return result;
504
  }
580
  }
505
581
506
  protected DiagnosticChain createBadDataValueDiagnostic
582
  protected DiagnosticChain createBadDataValueDiagnostic(
507
    (EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Map<Object, Object> context)
583
    EObject eObject,
508
  {
584
    EAttribute eAttribute,
509
    BasicDiagnostic diagnostic =
585
    DiagnosticChain diagnostics,
510
      createDiagnostic
586
    Map<Object, Object> context)
511
        (Diagnostic.ERROR,
587
  {
512
         DIAGNOSTIC_SOURCE,
588
    BasicDiagnostic diagnostic = createDiagnostic(
513
         EOBJECT__EVERY_DATA_VALUE_CONFORMS,
589
      Diagnostic.ERROR,
514
         "_UI_BadDataValue_diagnostic",
590
      DIAGNOSTIC_SOURCE,
515
         new Object []
591
      EOBJECT__EVERY_DATA_VALUE_CONFORMS,
516
         {
592
      "_UI_BadDataValue_diagnostic",
517
           getFeatureLabel(eAttribute, context),
593
      new Object []{ getFeatureLabel(eAttribute, context), getObjectLabel(eObject, context) },
518
           getObjectLabel(eObject, context)
594
      new Object []{ eObject, eAttribute },
519
         },
595
      context);
520
         new Object [] { eObject, eAttribute },
521
         context);
522
    diagnostics.add(diagnostic);
596
    diagnostics.add(diagnostic);
523
    return diagnostic;
597
    return diagnostic;
524
  }
598
  }
525
599
526
  protected boolean validatePattern
600
  protected boolean validatePattern(
527
    (EDataType eDataType, Object value, PatternMatcher [][] patterns, DiagnosticChain diagnostics, Map<Object, Object> context)
601
    EDataType eDataType,
602
    Object value,
603
    PatternMatcher[][] patterns,
604
    DiagnosticChain diagnostics,
605
    Map<Object, Object> context)
528
  {
606
  {
529
    String literal = EcoreUtil.convertToString(eDataType, value);
607
    String literal = EcoreUtil.convertToString(eDataType, value);
530
    for (int i = 0; i < patterns.length; ++i)
608
    for (int i = 0; i < patterns.length; ++i)
531
    {
609
    {
532
      PatternMatcher [] children = patterns[i];
610
      PatternMatcher[] children = patterns[i];
533
      boolean matches = false;
611
      boolean matches = false;
534
      for (int j = 0; j < children.length; ++j)
612
      for (int j = 0; j < children.length; ++j)
535
      {
613
      {
Lines 554-560 Link Here
554
  public class DynamicEDataTypeValidator
632
  public class DynamicEDataTypeValidator
555
  {
633
  {
556
    protected List<Object> effectiveEnumeration;
634
    protected List<Object> effectiveEnumeration;
557
    protected PatternMatcher [][] effectivePattern;
635
    protected PatternMatcher[][] effectivePattern;
558
    protected int effectiveTotalDigits = -1;
636
    protected int effectiveTotalDigits = -1;
559
    protected int effectiveFractionDigits = -1;
637
    protected int effectiveFractionDigits = -1;
560
    protected int effectiveMinLength = -1;
638
    protected int effectiveMinLength = -1;
Lines 605-613 Link Here
605
          {
683
          {
606
            patterns = new ArrayList<PatternMatcher[]>();
684
            patterns = new ArrayList<PatternMatcher[]>();
607
          }
685
          }
608
          PatternMatcher [] children = new PatternMatcher [pattern.size()];
686
          PatternMatcher[] children = new PatternMatcher [pattern.size()];
609
          patterns.add(children);
687
          patterns.add(children);
610
          for (ListIterator<String> i = pattern.listIterator(); i.hasNext(); )
688
          for (ListIterator<String> i = pattern.listIterator(); i.hasNext();)
611
          {
689
          {
612
            PatternMatcher patternMatcher = XMLTypeUtil.createPatternMatcher(i.next());
690
            PatternMatcher patternMatcher = XMLTypeUtil.createPatternMatcher(i.next());
613
            children[i.previousIndex()] = patternMatcher;
691
            children[i.previousIndex()] = patternMatcher;
Lines 691-697 Link Here
691
769
692
      if (patterns != null)
770
      if (patterns != null)
693
      {
771
      {
694
        effectivePattern = new PatternMatcher [patterns.size()][];
772
        effectivePattern = new PatternMatcher [patterns.size()] [];
695
        patterns.toArray(effectivePattern);
773
        patterns.toArray(effectivePattern);
696
      }
774
      }
697
775
Lines 702-715 Link Here
702
        {
780
        {
703
          digits.append("0");
781
          digits.append("0");
704
        }
782
        }
705
        
783
706
        try
784
        try
707
        {
785
        {
708
          Object lowerBound = EcoreUtil.createFromString(eDataType, "-" + digits.toString());
786
          Object lowerBound = EcoreUtil.createFromString(eDataType, "-" + digits.toString());
709
          @SuppressWarnings("unchecked") boolean lowerBounded = effectiveMin == null ||
787
          @SuppressWarnings("unchecked")
710
                (effectiveMinIsInclusive ?
788
          boolean lowerBounded = effectiveMin == null
711
                   ((Comparable<Object>)effectiveMin).compareTo(lowerBound) <= 0:
789
            || (effectiveMinIsInclusive
712
                   ((Comparable<Object>)effectiveMin).compareTo(lowerBound) < 0);
790
              ? ((Comparable<Object>)effectiveMin).compareTo(lowerBound) <= 0
791
              : ((Comparable<Object>)effectiveMin).compareTo(lowerBound) < 0);
713
          if (lowerBounded)
792
          if (lowerBounded)
714
          {
793
          {
715
            effectiveMinIsInclusive = false;
794
            effectiveMinIsInclusive = false;
Lines 717-723 Link Here
717
            effectiveTotalDigitsMin = effectiveTotalDigits;
796
            effectiveTotalDigitsMin = effectiveTotalDigits;
718
          }
797
          }
719
        }
798
        }
720
        catch (NumberFormatException exception) 
799
        catch (NumberFormatException exception)
721
        {
800
        {
722
          // Ignore the bound if the value is too big.
801
          // Ignore the bound if the value is too big.
723
        }
802
        }
Lines 725-734 Link Here
725
        try
804
        try
726
        {
805
        {
727
          Object upperBound = EcoreUtil.createFromString(eDataType, digits.toString());
806
          Object upperBound = EcoreUtil.createFromString(eDataType, digits.toString());
728
          @SuppressWarnings("unchecked") boolean upperBounded = effectiveMax == null ||
807
          @SuppressWarnings("unchecked")
729
                (effectiveMaxIsInclusive ?
808
          boolean upperBounded = effectiveMax == null
730
                   ((Comparable<Object>)effectiveMax).compareTo(upperBound) >= 0:
809
            || (effectiveMaxIsInclusive
731
                   ((Comparable<Object>)effectiveMax).compareTo(upperBound) > 0);
810
              ? ((Comparable<Object>)effectiveMax).compareTo(upperBound) >= 0
811
              : ((Comparable<Object>)effectiveMax).compareTo(upperBound) > 0);
732
          if (upperBounded)
812
          if (upperBounded)
733
          {
813
          {
734
            effectiveMaxIsInclusive = false;
814
            effectiveMaxIsInclusive = false;
Lines 736-742 Link Here
736
            effectiveTotalDigitsMax = effectiveTotalDigits;
816
            effectiveTotalDigitsMax = effectiveTotalDigits;
737
          }
817
          }
738
        }
818
        }
739
        catch (NumberFormatException exception) 
819
        catch (NumberFormatException exception)
740
        {
820
        {
741
          // Ignore the bound if the value is too big.
821
          // Ignore the bound if the value is too big.
742
        }
822
        }
Lines 757-763 Link Here
757
      {
837
      {
758
        if (!effectiveEnumeration.contains(value))
838
        if (!effectiveEnumeration.contains(value))
759
        {
839
        {
760
          if (diagnostics != null) reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context);
840
          if (diagnostics != null)
841
            reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context);
761
          result = false;
842
          result = false;
762
        }
843
        }
763
      }
844
      }
Lines 769-778 Link Here
769
850
770
      if (effectiveMin != null)
851
      if (effectiveMin != null)
771
      {
852
      {
772
        @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin;
853
        @SuppressWarnings("unchecked")
773
        if (effectiveMinIsInclusive ?
854
        Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin;
774
              comparableObject.compareTo(value) > 0:
855
        if (effectiveMinIsInclusive ? comparableObject.compareTo(value) > 0 : comparableObject.compareTo(value) >= 0)
775
              comparableObject.compareTo(value) >= 0)
776
        {
856
        {
777
          if (diagnostics != null)
857
          if (diagnostics != null)
778
          {
858
          {
Lines 791-800 Link Here
791
871
792
      if (effectiveMax != null)
872
      if (effectiveMax != null)
793
      {
873
      {
794
        @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax;
874
        @SuppressWarnings("unchecked")
795
        if (effectiveMaxIsInclusive ?
875
        Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax;
796
              comparableObject.compareTo(value) < 0:
876
        if (effectiveMaxIsInclusive ? comparableObject.compareTo(value) < 0 : comparableObject.compareTo(value) <= 0)
797
              comparableObject.compareTo(value) <= 0)
798
        {
877
        {
799
          if (diagnostics != null)
878
          if (diagnostics != null)
800
          {
879
          {
Lines 813-842 Link Here
813
892
814
      if (effectiveMinLength != -1)
893
      if (effectiveMinLength != -1)
815
      {
894
      {
816
        int length =
895
        int length = value instanceof String ? ((String)value).length() : value instanceof Collection
817
          value instanceof String ?
896
          ? ((Collection< ? >)value).size() : Array.getLength(value);
818
            ((String)value).length() :
819
             value instanceof Collection ?
820
               ((Collection<?>)value).size() :
821
               Array.getLength(value);
822
        if (length < effectiveMinLength)
897
        if (length < effectiveMinLength)
823
        {
898
        {
824
          if (diagnostics != null) reportMinLengthViolation(eDataType, value, length, effectiveMinLength, diagnostics, context);
899
          if (diagnostics != null)
900
            reportMinLengthViolation(eDataType, value, length, effectiveMinLength, diagnostics, context);
825
          result = false;
901
          result = false;
826
        }
902
        }
827
      }
903
      }
828
904
829
      if (effectiveMaxLength != -1)
905
      if (effectiveMaxLength != -1)
830
      {
906
      {
831
        int length =
907
        int length = value instanceof String ? ((String)value).length() : value instanceof Collection
832
          value instanceof String ?
908
          ? ((Collection< ? >)value).size() : Array.getLength(value);
833
            ((String)value).length() :
834
             value instanceof Collection ?
835
               ((Collection<?>)value).size() :
836
               Array.getLength(value);
837
        if (length > effectiveMaxLength)
909
        if (length > effectiveMaxLength)
838
        {
910
        {
839
          if (diagnostics != null) reportMaxLengthViolation(eDataType, value, length, effectiveMaxLength, diagnostics, context);
911
          if (diagnostics != null)
912
            reportMaxLengthViolation(eDataType, value, length, effectiveMaxLength, diagnostics, context);
840
          result = false;
913
          result = false;
841
        }
914
        }
842
      }
915
      }
Lines 845-851 Link Here
845
      {
918
      {
846
        if (value instanceof BigDecimal && ((BigDecimal)value).unscaledValue().abs().toString().length() > effectiveTotalDigits)
919
        if (value instanceof BigDecimal && ((BigDecimal)value).unscaledValue().abs().toString().length() > effectiveTotalDigits)
847
        {
920
        {
848
          if (diagnostics != null) reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context);
921
          if (diagnostics != null)
922
            reportTotalDigitsViolation(eDataType, value, effectiveTotalDigits, diagnostics, context);
849
          result = false;
923
          result = false;
850
        }
924
        }
851
      }
925
      }
Lines 854-860 Link Here
854
      {
928
      {
855
        if (value instanceof BigDecimal && ((BigDecimal)value).scale() > effectiveFractionDigits)
929
        if (value instanceof BigDecimal && ((BigDecimal)value).scale() > effectiveFractionDigits)
856
        {
930
        {
857
          if (diagnostics != null) reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context);
931
          if (diagnostics != null)
932
            reportFractionDigitsViolation(eDataType, value, effectiveFractionDigits, diagnostics, context);
858
          result = false;
933
          result = false;
859
        }
934
        }
860
      }
935
      }
Lines 862-868 Link Here
862
      if (itemType != null)
937
      if (itemType != null)
863
      {
938
      {
864
        EValidator rootValidator = getRootEValidator(context);
939
        EValidator rootValidator = getRootEValidator(context);
865
        for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && (result || diagnostics != null); )
940
        for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);)
866
        {
941
        {
867
          result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
942
          result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
868
        }
943
        }
Lines 871-877 Link Here
871
      else if (!memberTypes.isEmpty())
946
      else if (!memberTypes.isEmpty())
872
      {
947
      {
873
        EValidator rootValidator = getRootEValidator(context);
948
        EValidator rootValidator = getRootEValidator(context);
874
        
949
875
        for (EDataType memberType : memberTypes)
950
        for (EDataType memberType : memberTypes)
876
        {
951
        {
877
          if (rootValidator.validate(memberType, value, null, context))
952
          if (rootValidator.validate(memberType, value, null, context))
Lines 905-911 Link Here
905
      }
980
      }
906
      else
981
      else
907
      {
982
      {
908
        if (diagnostics != null) reportDataValueTypeViolation(eDataType, value, diagnostics, context);
983
        if (diagnostics != null)
984
          reportDataValueTypeViolation(eDataType, value, diagnostics, context);
909
        return false;
985
        return false;
910
      }
986
      }
911
    }
987
    }
Lines 916-923 Link Here
916
    }
992
    }
917
    else
993
    else
918
    {
994
    {
919
      return
995
      return new DynamicEDataTypeValidator(eDataType)
920
        new DynamicEDataTypeValidator(eDataType)
921
        {
996
        {
922
          // Ensure that the class loader for this class will be used downstream.
997
          // Ensure that the class loader for this class will be used downstream.
923
          //
998
          //
Lines 925-1126 Link Here
925
    }
1000
    }
926
  }
1001
  }
927
1002
928
  protected void reportMinViolation
1003
  protected void reportMinViolation(
929
    (EDataType eDataType, Object value, Object bound, boolean isInclusive, DiagnosticChain diagnostics, Map<Object, Object> context)
1004
    EDataType eDataType,
930
  {
1005
    Object value,
931
    diagnostics.add
1006
    Object bound,
932
      (createDiagnostic
1007
    boolean isInclusive,
933
        (Diagnostic.ERROR,
1008
    DiagnosticChain diagnostics,
934
         DIAGNOSTIC_SOURCE,
1009
    Map<Object, Object> context)
935
         DATA_VALUE__VALUE_IN_RANGE,
1010
  {
936
         isInclusive ? "_UI_MinInclusiveConstraint_diagnostic" : "_UI_MinExclusiveConstraint_diagnostic",
1011
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, DATA_VALUE__VALUE_IN_RANGE, isInclusive
937
         new Object []
1012
      ? "_UI_MinInclusiveConstraint_diagnostic" : "_UI_MinExclusiveConstraint_diagnostic", new Object []{
938
         {
1013
      getValueLabel(eDataType, value, context),
939
           getValueLabel(eDataType, value, context),
1014
      isInclusive ? ">=" : ">",
940
           isInclusive ? ">=" : ">",
1015
      getValueLabel(eDataType, bound, context) }, new Object []{ value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, context));
941
           getValueLabel(eDataType, bound, context)
1016
  }
942
         },
1017
943
         new Object [] { value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE },
1018
  protected void reportMaxViolation(
944
         context));
1019
    EDataType eDataType,
945
  }
1020
    Object value,
946
1021
    Object bound,
947
  protected void reportMaxViolation
1022
    boolean isInclusive,
948
    (EDataType eDataType, Object value, Object bound, boolean isInclusive, DiagnosticChain diagnostics, Map<Object, Object> context)
1023
    DiagnosticChain diagnostics,
949
  {
1024
    Map<Object, Object> context)
950
    diagnostics.add
1025
  {
951
      (createDiagnostic
1026
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, DATA_VALUE__VALUE_IN_RANGE, isInclusive
952
        (Diagnostic.ERROR,
1027
      ? "_UI_MaxInclusiveConstraint_diagnostic" : "_UI_MaxExclusiveConstraint_diagnostic", new Object []{
953
         DIAGNOSTIC_SOURCE,
1028
      getValueLabel(eDataType, value, context),
954
         DATA_VALUE__VALUE_IN_RANGE,
1029
      "<",
955
         isInclusive ? "_UI_MaxInclusiveConstraint_diagnostic" : "_UI_MaxExclusiveConstraint_diagnostic",
1030
      getValueLabel(eDataType, bound, context) }, new Object []{ value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE }, context));
956
         new Object []
1031
  }
957
         {
1032
958
           getValueLabel(eDataType, value, context),
1033
  protected void reportMinLengthViolation(
959
           "<",
1034
    EDataType eDataType,
960
           getValueLabel(eDataType, bound, context)
1035
    Object value,
961
         },
1036
    int length,
962
         new Object [] { value, bound, isInclusive ? Boolean.TRUE : Boolean.FALSE },
1037
    int bound,
963
         context));
1038
    DiagnosticChain diagnostics,
964
  }
1039
    Map<Object, Object> context)
965
1040
  {
966
  protected void reportMinLengthViolation
1041
    diagnostics.add(createDiagnostic(
967
    (EDataType eDataType, Object value, int length, int bound, DiagnosticChain diagnostics, Map<Object, Object> context)
1042
      Diagnostic.ERROR,
968
  {
1043
      DIAGNOSTIC_SOURCE,
969
    diagnostics.add
1044
      DATA_VALUE__LENGTH_IN_RANGE,
970
      (createDiagnostic
1045
      "_UI_MinLengthConstraint_diagnostic",
971
        (Diagnostic.ERROR,
1046
      new Object []{ getValueLabel(eDataType, value, context), Integer.toString(length), Integer.toString(bound) },
972
         DIAGNOSTIC_SOURCE,
1047
      new Object []{ value, eDataType, length, bound },
973
         DATA_VALUE__LENGTH_IN_RANGE,
1048
      context));
974
         "_UI_MinLengthConstraint_diagnostic",
1049
  }
975
         new Object []
1050
976
         {
1051
  protected void reportMaxLengthViolation(
977
           getValueLabel(eDataType, value, context),
1052
    EDataType eDataType,
978
           Integer.toString(length),
1053
    Object value,
979
           Integer.toString(bound)
1054
    int length,
980
         },
1055
    int bound,
981
         new Object [] { value, eDataType, length, bound },
1056
    DiagnosticChain diagnostics,
982
         context));
1057
    Map<Object, Object> context)
983
  }
1058
  {
984
1059
    diagnostics.add(createDiagnostic(
985
  protected void reportMaxLengthViolation
1060
      Diagnostic.ERROR,
986
    (EDataType eDataType, Object value, int length, int bound, DiagnosticChain diagnostics, Map<Object, Object> context)
1061
      DIAGNOSTIC_SOURCE,
987
  {
1062
      DATA_VALUE__LENGTH_IN_RANGE,
988
    diagnostics.add
1063
      "_UI_MaxLengthConstraint_diagnostic",
989
      (createDiagnostic
1064
      new Object []{ getValueLabel(eDataType, value, context), Integer.toString(length), Integer.toString(bound) },
990
        (Diagnostic.ERROR,
1065
      new Object []{ value, eDataType, length, bound },
991
         DIAGNOSTIC_SOURCE,
1066
      context));
992
         DATA_VALUE__LENGTH_IN_RANGE,
1067
  }
993
         "_UI_MaxLengthConstraint_diagnostic",
1068
994
         new Object []
1069
  protected void reportTotalDigitsViolation(
995
         {
1070
    EDataType eDataType,
996
           getValueLabel(eDataType, value, context),
1071
    Object value,
997
           Integer.toString(length),
1072
    int totalDigits,
998
           Integer.toString(bound)
1073
    DiagnosticChain diagnostics,
999
         },
1074
    Map<Object, Object> context)
1000
         new Object [] { value, eDataType, length, bound },
1075
  {
1001
         context));
1076
    diagnostics.add(createDiagnostic(
1002
  }
1077
      Diagnostic.ERROR,
1003
1078
      DIAGNOSTIC_SOURCE,
1004
  protected void reportTotalDigitsViolation
1079
      DATA_VALUE__TOTAL_DIGITS_IN_RANGE,
1005
    (EDataType eDataType, Object value, int totalDigits, DiagnosticChain diagnostics, Map<Object, Object> context)
1080
      "_UI_TotalDigitsConstraint_diagnostic",
1006
  {
1081
      new Object []{ getValueLabel(eDataType, value, context), totalDigits },
1007
    diagnostics.add
1082
      new Object []{ value, eDataType, totalDigits },
1008
      (createDiagnostic
1083
      context));
1009
        (Diagnostic.ERROR,
1084
  }
1010
         DIAGNOSTIC_SOURCE,
1085
1011
         DATA_VALUE__TOTAL_DIGITS_IN_RANGE,
1086
  protected void reportFractionDigitsViolation(
1012
         "_UI_TotalDigitsConstraint_diagnostic",
1087
    EDataType eDataType,
1013
         new Object []
1088
    Object value,
1014
         {
1089
    int fractionDigits,
1015
           getValueLabel(eDataType, value, context),
1090
    DiagnosticChain diagnostics,
1016
           totalDigits
1091
    Map<Object, Object> context)
1017
         },
1092
  {
1018
         new Object [] { value, eDataType, totalDigits },
1093
    diagnostics.add(createDiagnostic(
1019
         context));
1094
      Diagnostic.ERROR,
1020
  }
1095
      DIAGNOSTIC_SOURCE,
1021
1096
      DATA_VALUE__TOTAL_DIGITS_IN_RANGE,
1022
  protected void reportFractionDigitsViolation
1097
      "_UI_FractionDigitsConstraint_diagnostic",
1023
    (EDataType eDataType, Object value, int fractionDigits, DiagnosticChain diagnostics, Map<Object, Object> context)
1098
      new Object []{ getValueLabel(eDataType, value, context), fractionDigits },
1024
  {
1099
      new Object []{ value, eDataType, fractionDigits },
1025
    diagnostics.add
1100
      context));
1026
      (createDiagnostic
1101
  }
1027
        (Diagnostic.ERROR,
1102
1028
         DIAGNOSTIC_SOURCE,
1103
  protected void reportEnumerationViolation(
1029
         DATA_VALUE__TOTAL_DIGITS_IN_RANGE,
1104
    EDataType eDataType,
1030
         "_UI_FractionDigitsConstraint_diagnostic",
1105
    Object value,
1031
         new Object []
1106
    Collection< ? > values,
1032
         {
1107
    DiagnosticChain diagnostics,
1033
           getValueLabel(eDataType, value, context),
1108
    Map<Object, Object> context)
1034
           fractionDigits
1035
         },
1036
         new Object [] { value, eDataType, fractionDigits },
1037
         context));
1038
  }
1039
1040
  protected void reportEnumerationViolation
1041
    (EDataType eDataType, Object value, Collection<?> values, DiagnosticChain diagnostics, Map<Object, Object> context)
1042
  {
1109
  {
1043
    String valueLiterals = "";
1110
    String valueLiterals = "";
1044
    Iterator<?> i = values.iterator();
1111
    Iterator< ? > i = values.iterator();
1045
    if (i.hasNext())
1112
    if (i.hasNext())
1046
    {
1113
    {
1047
      valueLiterals =
1114
      valueLiterals = getEcoreResourceLocator().getString(
1048
        getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object [] { getValueLabel(eDataType, i.next(), context) });
1115
        "_UI_ListHead_composition",
1116
        new Object []{ getValueLabel(eDataType, i.next(), context) });
1049
      while (i.hasNext())
1117
      while (i.hasNext())
1050
      {
1118
      {
1051
        valueLiterals =
1119
        valueLiterals = getEcoreResourceLocator().getString(
1052
          getEcoreResourceLocator().getString
1120
          "_UI_ListTail_composition",
1053
            ("_UI_ListTail_composition",
1121
          new Object []{ valueLiterals, getValueLabel(eDataType, i.next(), context) });
1054
             new Object [] { valueLiterals, getValueLabel(eDataType, i.next(), context) });
1122
      }
1055
      }
1123
    }
1056
    }
1124
    diagnostics.add(createDiagnostic(
1057
    diagnostics.add
1125
      Diagnostic.ERROR,
1058
      (createDiagnostic
1126
      DIAGNOSTIC_SOURCE,
1059
        (Diagnostic.ERROR,
1127
      DATA_VALUE__VALUE_IN_ENUMERATION,
1060
         DIAGNOSTIC_SOURCE,
1128
      "_UI_EnumerationConstraint_diagnostic",
1061
         DATA_VALUE__VALUE_IN_ENUMERATION,
1129
      new Object []{ getValueLabel(eDataType, value, context), valueLiterals },
1062
         "_UI_EnumerationConstraint_diagnostic",
1130
      new Object []{ value, eDataType, values },
1063
         new Object []
1131
      context));
1064
         {
1132
  }
1065
           getValueLabel(eDataType, value, context),
1133
1066
           valueLiterals
1134
  protected void reportDataValuePatternViolation(
1067
         },
1135
    EDataType eDataType,
1068
         new Object [] { value, eDataType, values },
1136
    Object value,
1069
         context));
1137
    PatternMatcher[] patterns,
1070
  }
1138
    DiagnosticChain diagnostics,
1071
1139
    Map<Object, Object> context)
1072
  protected void reportDataValuePatternViolation
1073
    (EDataType eDataType, Object value, PatternMatcher [] patterns, DiagnosticChain diagnostics, Map<Object, Object> context)
1074
  {
1140
  {
1075
    String patternLiterals = "";
1141
    String patternLiterals = "";
1076
    if (patterns.length > 0)
1142
    if (patterns.length > 0)
1077
    {
1143
    {
1078
      patternLiterals = getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object [] { patterns[0] });
1144
      patternLiterals = getEcoreResourceLocator().getString("_UI_ListHead_composition", new Object []{ patterns[0] });
1079
      for (int i = 1; i < patterns.length; ++i)
1145
      for (int i = 1; i < patterns.length; ++i)
1080
      {
1146
      {
1081
        patternLiterals = getEcoreResourceLocator().getString("_UI_ListTail_composition", new Object [] { patternLiterals, patterns[i] });
1147
        patternLiterals = getEcoreResourceLocator().getString("_UI_ListTail_composition", new Object []{ patternLiterals, patterns[i] });
1082
      }
1148
      }
1083
    }
1149
    }
1084
1150
1085
    diagnostics.add
1151
    diagnostics.add(createDiagnostic(
1086
      (createDiagnostic
1152
      Diagnostic.ERROR,
1087
        (Diagnostic.ERROR,
1153
      DIAGNOSTIC_SOURCE,
1088
         DIAGNOSTIC_SOURCE,
1154
      DATA_VALUE__MATCHES_PATTERN,
1089
         DATA_VALUE__MATCHES_PATTERN,
1155
      "_UI_PatternConstraint_diagnostic",
1090
         "_UI_PatternConstraint_diagnostic",
1156
      new Object []{ getValueLabel(eDataType, value, context), patternLiterals },
1091
         new Object []
1157
      new Object []{ value, eDataType, patterns },
1092
         {
1158
      context));
1093
           getValueLabel(eDataType, value, context),
1159
  }
1094
           patternLiterals
1160
1095
         },
1161
  protected void reportDataValueTypeViolation(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
1096
         new Object [] { value, eDataType, patterns },
1162
  {
1097
         context));
1163
    diagnostics.add(createDiagnostic(
1098
  }
1164
      Diagnostic.ERROR,
1099
1165
      DIAGNOSTIC_SOURCE,
1100
  protected void reportDataValueTypeViolation
1166
      DATA_VALUE__TYPE_CORRECT,
1101
    (EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
1167
      "_UI_BadDataValueType_diagnostic",
1102
  {
1168
      new Object []{
1103
    diagnostics.add
1169
        getValueLabel(eDataType, value, context),
1104
      (createDiagnostic
1170
        value == null ? "<null>" : value.getClass().getName(),
1105
        (Diagnostic.ERROR,
1171
        eDataType.getInstanceClass().getName() },
1106
         DIAGNOSTIC_SOURCE,
1172
      new Object []{ value, eDataType },
1107
         DATA_VALUE__TYPE_CORRECT,
1173
      context));
1108
         "_UI_BadDataValueType_diagnostic",
1109
         new Object []
1110
         {
1111
           getValueLabel(eDataType, value, context),
1112
           value == null ? "<null>" : value.getClass().getName(),
1113
           eDataType.getInstanceClass().getName()
1114
         },
1115
         new Object [] { value, eDataType },
1116
         context));
1117
  }
1174
  }
1118
1175
1119
  protected static Collection<Object> wrapEnumerationValues(Object [] values)
1176
  protected static Collection<Object> wrapEnumerationValues(Object[] values)
1120
  {
1177
  {
1121
    return java.util.Arrays.asList(values);
1178
    return java.util.Arrays.asList(values);
1122
  }
1179
  }
1123
  
1180
1124
  /**
1181
  /**
1125
   * @since 2.2
1182
   * @since 2.2
1126
   */
1183
   */
Lines 1137-1156 Link Here
1137
        if (eObject != otherEObject && otherEObject != null)
1194
        if (eObject != otherEObject && otherEObject != null)
1138
        {
1195
        {
1139
          // ...
1196
          // ...
1140
          diagnostics.add
1197
          diagnostics.add(createDiagnostic(
1141
            (createDiagnostic
1198
            Diagnostic.ERROR,
1142
              (Diagnostic.ERROR,
1199
            DIAGNOSTIC_SOURCE,
1143
               DIAGNOSTIC_SOURCE,
1200
            EOBJECT__UNIQUE_ID,
1144
               EOBJECT__UNIQUE_ID,
1201
            "_UI_DuplicateID_diagnostic",
1145
               "_UI_DuplicateID_diagnostic",
1202
            new Object []{ id, getObjectLabel(eObject, context), getObjectLabel(otherEObject, context) },
1146
               new Object []
1203
            new Object []{ eObject, otherEObject, id },
1147
               {
1204
            context));
1148
                 id,
1149
                 getObjectLabel(eObject, context),
1150
                 getObjectLabel(otherEObject, context)
1151
               },
1152
               new Object [] { eObject, otherEObject, id },
1153
               context));
1154
        }
1205
        }
1155
      }
1206
      }
1156
    }
1207
    }
Lines 1186-1192 Link Here
1186
    }
1237
    }
1187
    return result;
1238
    return result;
1188
  }
1239
  }
1189
  
1240
1190
  /**
1241
  /**
1191
   * @since 2.3
1242
   * @since 2.3
1192
   * @param eObject
1243
   * @param eObject
Lines 1195-1211 Link Here
1195
   * @param context
1246
   * @param context
1196
   * @return whether every key is unique.
1247
   * @return whether every key is unique.
1197
   */
1248
   */
1198
  protected boolean validate_KeyUnique
1249
  protected boolean validate_KeyUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context)
1199
    (EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context)
1200
  {
1250
  {
1201
    boolean result = true;
1251
    boolean result = true;
1202
    Map<List<Object>, EObject> keys = new HashMap<List<Object>, EObject>();
1252
    Map<List<Object>, EObject> keys = new HashMap<List<Object>, EObject>();
1203
    EAttribute [] eAttributes = (EAttribute[])((BasicEList<?>)eReference.getEKeys()).data();
1253
    EAttribute[] eAttributes = (EAttribute[])((BasicEList< ? >)eReference.getEKeys()).data();
1204
    @SuppressWarnings("unchecked")
1254
    @SuppressWarnings("unchecked")
1205
    List<EObject> values = (List<EObject>)eObject.eGet(eReference);
1255
    List<EObject> values = (List<EObject>)eObject.eGet(eReference);
1206
    for (EObject value : values)
1256
    for (EObject value : values)
1207
    {
1257
    {
1208
      ArrayList<Object> key = new ArrayList<Object>(); 
1258
      ArrayList<Object> key = new ArrayList<Object>();
1209
      for (int i = 0, size = eAttributes.length; i < size; ++i)
1259
      for (int i = 0, size = eAttributes.length; i < size; ++i)
1210
      {
1260
      {
1211
        EAttribute eAttribute = eAttributes[i];
1261
        EAttribute eAttribute = eAttributes[i];
Lines 1213-1219 Link Here
1213
        {
1263
        {
1214
          break;
1264
          break;
1215
        }
1265
        }
1216
        else 
1266
        else
1217
        {
1267
        {
1218
          key.add(value.eGet(eAttribute));
1268
          key.add(value.eGet(eAttribute));
1219
        }
1269
        }
Lines 1234-1254 Link Here
1234
          {
1284
          {
1235
            uriFragmentSegment = uriFragmentSegment.substring(index);
1285
            uriFragmentSegment = uriFragmentSegment.substring(index);
1236
          }
1286
          }
1237
          diagnostics.add
1287
          diagnostics.add(createDiagnostic(
1238
            (createDiagnostic
1288
            Diagnostic.ERROR,
1239
              (Diagnostic.ERROR,
1289
            DIAGNOSTIC_SOURCE,
1240
               DIAGNOSTIC_SOURCE,
1290
            EOBJECT__EVERY_KEY_UNIQUE,
1241
               EOBJECT__EVERY_KEY_UNIQUE,
1291
            "_UI_DuplicateKey_diagnostic",
1242
               "_UI_DuplicateKey_diagnostic",
1292
            new Object []{
1243
               new Object []
1293
              getFeatureLabel(eReference, context),
1244
               {
1294
              uriFragmentSegment,
1245
                 getFeatureLabel(eReference, context),
1295
              getObjectLabel(value, context),
1246
                 uriFragmentSegment,
1296
              getObjectLabel(otherValue, context) },
1247
                 getObjectLabel(value, context),
1297
            new Object []{ eObject, eReference, value, otherValue },
1248
                 getObjectLabel(otherValue, context)
1298
            context));
1249
               },
1250
               new Object [] { eObject, eReference, value, otherValue },
1251
               context));
1252
        }
1299
        }
1253
      }
1300
      }
1254
    }
1301
    }
Lines 1291-1309 Link Here
1291
   * @param context
1338
   * @param context
1292
   * @return whether every map entry is unique.
1339
   * @return whether every map entry is unique.
1293
   */
1340
   */
1294
  protected boolean validate_MapEntryUnique
1341
  protected boolean validate_MapEntryUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context)
1295
    (EObject eObject, EReference eReference, DiagnosticChain diagnostics, Map<Object, Object> context)
1296
  {
1342
  {
1297
    boolean result = true;
1343
    boolean result = true;
1298
    Object value = eObject.eGet(eReference);
1344
    Object value = eObject.eGet(eReference);
1299
    if (value instanceof EMap)
1345
    if (value instanceof EMap)
1300
    {
1346
    {
1301
      EMap<?, ?> eMap = (EMap<?, ?>)value;
1347
      EMap< ? , ? > eMap = (EMap< ? , ? >)value;
1302
      for (int i = 0, size = eMap.size(); i < size; ++i)
1348
      for (int i = 0, size = eMap.size(); i < size; ++i)
1303
      {
1349
      {
1304
        Map.Entry<?, ?> entry = eMap.get(i);
1350
        Map.Entry< ? , ? > entry = eMap.get(i);
1305
        Object key = entry.getKey();
1351
        Object key = entry.getKey();
1306
        int index =  eMap.indexOfKey(key);
1352
        int index = eMap.indexOfKey(key);
1307
        if (index != i)
1353
        if (index != i)
1308
        {
1354
        {
1309
          result = false;
1355
          result = false;
Lines 1313-1332 Link Here
1313
          }
1359
          }
1314
          else
1360
          else
1315
          {
1361
          {
1316
            diagnostics.add
1362
            diagnostics.add(createDiagnostic(
1317
              (createDiagnostic
1363
              Diagnostic.ERROR,
1318
                (Diagnostic.ERROR,
1364
              DIAGNOSTIC_SOURCE,
1319
                 DIAGNOSTIC_SOURCE,
1365
              EOBJECT__EVERY_MAP_ENTRY_UNIQUE,
1320
                 EOBJECT__EVERY_MAP_ENTRY_UNIQUE,
1366
              "_UI_DuplicateMapEntry_diagnostic",
1321
                 "_UI_DuplicateMapEntry_diagnostic",
1367
              new Object []{ getFeatureLabel(eReference, context), i, index },
1322
                 new Object []
1368
              new Object []{ eObject, eReference, entry, eMap.get(index) },
1323
                 {
1369
              context));
1324
                   getFeatureLabel(eReference, context),
1325
                   i,
1326
                   index
1327
                 },
1328
                 new Object [] { eObject, eReference, entry, eMap.get(index) },
1329
                 context));
1330
          }
1370
          }
1331
        }
1371
        }
1332
      }
1372
      }
Lines 1351-1363 Link Here
1351
   * @see BasicDiagnostic#BasicDiagnostic(int, String, int, String, Object[])
1391
   * @see BasicDiagnostic#BasicDiagnostic(int, String, int, String, Object[])
1352
   * @since 2.4
1392
   * @since 2.4
1353
   */
1393
   */
1354
  protected BasicDiagnostic createDiagnostic
1394
  protected BasicDiagnostic createDiagnostic(
1355
    (int severity, String source, int code, String messageKey, Object[] messageSubstitutions, Object[] data, Map<Object, Object> context)
1395
    int severity,
1356
  {
1396
    String source,
1357
    String message =
1397
    int code,
1358
      DIAGNOSTIC_SOURCE.equals(source) ?
1398
    String messageKey,
1359
        getEcoreString(messageKey, messageSubstitutions) :
1399
    Object[] messageSubstitutions,
1360
        getString(messageKey, messageSubstitutions);
1400
    Object[] data,
1401
    Map<Object, Object> context)
1402
  {
1403
    String message = DIAGNOSTIC_SOURCE.equals(source) ? getEcoreString(messageKey, messageSubstitutions) : getString(
1404
      messageKey,
1405
      messageSubstitutions);
1361
    return new BasicDiagnostic(severity, source, code, message, data);
1406
    return new BasicDiagnostic(severity, source, code, message, data);
1362
  }
1407
  }
1363
1408
Lines 1369-1375 Link Here
1369
   * @return the message.
1414
   * @return the message.
1370
   * @since 2.4
1415
   * @since 2.4
1371
   */
1416
   */
1372
  protected String getEcoreString(String key, Object [] substitutions)
1417
  protected String getEcoreString(String key, Object[] substitutions)
1373
  {
1418
  {
1374
    return getString(getEcoreResourceLocator(), key, substitutions);
1419
    return getString(getEcoreResourceLocator(), key, substitutions);
1375
  }
1420
  }
Lines 1392-1398 Link Here
1392
   * @return the message.
1437
   * @return the message.
1393
   * @since 2.4
1438
   * @since 2.4
1394
   */
1439
   */
1395
  protected String getString(String key, Object [] substitutions)
1440
  protected String getString(String key, Object[] substitutions)
1396
  {
1441
  {
1397
    return getString("_UI_GenericConstraint_diagnostic".equals(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions);
1442
    return getString("_UI_GenericConstraint_diagnostic".equals(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions);
1398
  }
1443
  }
Lines 1409-1415 Link Here
1409
    return getEcoreResourceLocator();
1454
    return getEcoreResourceLocator();
1410
  }
1455
  }
1411
1456
1412
  private String getString(ResourceLocator resourceLocator, String key, Object [] substitutions)
1457
  private String getString(ResourceLocator resourceLocator, String key, Object[] substitutions)
1413
  {
1458
  {
1414
    return substitutions == null ? resourceLocator.getString(key) : resourceLocator.getString(key, substitutions);
1459
    return substitutions == null ? resourceLocator.getString(key) : resourceLocator.getString(key, substitutions);
1415
  }
1460
  }
(-)src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java (+87 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Common Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/cpl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: EMF_codetemplates.xml,v 1.1 2008/05/06 20:12:20 nickb Exp $
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.emf.common.util.WrappedException;
23
import org.eclipse.emf.ecore.util.ConstraintsDelegator;
24
import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory;
25
26
/**
27
 * A plugin extension reader that populates the
28
 * {@link org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory.Registry#INSTANCE global} resource factory's
29
 * Clients are not expected to use this class directly.
30
 */
31
public class ConstraintsDelegatorFactoryRegistryReader extends RegistryReader
32
{
33
  static final String TAG_FACTORY = "factory";
34
  static final String ATT_URI = "uri";
35
  static final String ATT_CLASS = "class";
36
  
37
  public ConstraintsDelegatorFactoryRegistryReader()
38
  {
39
    super
40
    (Platform.getExtensionRegistry(),
41
     EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
42
     EcorePlugin.CONSTRAINTS_DELEGATOR_FACTORY);
43
  }
44
  
45
  @Override
46
  protected boolean readElement(IConfigurationElement element, boolean add)
47
  {
48
    if (element.getName().equals(TAG_FACTORY))
49
    {
50
      String packageURI = element.getAttribute(ATT_URI);
51
      if (packageURI == null)
52
      {
53
        logMissingAttribute(element, ATT_URI);
54
      }
55
      else if (element.getAttribute(ATT_CLASS) == null)
56
      {
57
        logMissingAttribute(element, ATT_CLASS);
58
      }
59
      else
60
      {
61
        try
62
        {
63
          Object o = element.createExecutableExtension(ATT_CLASS);
64
          if (o instanceof ConstraintsDelegator.Factory)
65
          {
66
            Factory tmp = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(packageURI);
67
            if (tmp != null)
68
            {
69
              EcorePlugin.INSTANCE.log
70
              ("factory '" + o.getClass().getName() + "'tries to override '" + packageURI + "' instead of factor '" + tmp.getClass().getName()+"'");
71
            }
72
            else 
73
            {
74
              ConstraintsDelegator.Factory.Registry.INSTANCE.putFactory(packageURI, (Factory)o);
75
            }
76
          }
77
          return true;
78
        }
79
        catch (CoreException e)
80
        {
81
          throw new WrappedException(e);
82
        }
83
      }
84
    }
85
    return false;
86
  }
87
}
(-)src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java (+85 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Common Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/cpl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id: ConstraintsDelegator.java,v 1.0 2008/11/19 16:37:42 tfaure Exp $
16
 */
17
package org.eclipse.emf.ecore.util;
18
19
import java.util.HashMap;
20
import java.util.Map;
21
22
import org.eclipse.emf.common.util.DiagnosticChain;
23
import org.eclipse.emf.ecore.EObject;
24
25
26
/**
27
 * An interface to validate a constraint
28
 * The only method to implement is {@link #validate(String, EObject, DiagnosticChain, Map)
29
 * To add a factory please see extension point : constraints_delegator_regstry
30
 */
31
public interface ConstraintsDelegator
32
{
33
  interface Factory
34
  {
35
    interface Registry
36
    {
37
      Registry INSTANCE = new Impl();
38
39
      /**
40
       * Returns the factory identified by the key
41
       * @param key the factory id
42
       * @return the factory or null if it doesn't exist
43
       */
44
      Factory getFactory(String key);
45
46
      /**
47
       * Registers a factory and associates it to an id
48
       * @param key the id
49
       * @param value the factory
50
       */
51
      void putFactory(String key, Factory value);
52
53
      class Impl extends HashMap<String, Factory> implements Registry
54
      {
55
        private static final long serialVersionUID = 1L;
56
57
        public Factory getFactory(String key)
58
        {
59
          return get(key);
60
        }
61
62
        public void putFactory(String key, Factory value)
63
        {
64
          put(key, value);
65
        }
66
      }
67
    }
68
69
    /**
70
     * Create a constraint delegator which is able to check a constraint
71
     * @return the constraint Delegator
72
     */
73
    ConstraintsDelegator createConstraintDelegator();
74
  }
75
76
  /**
77
   * Validate a constraint and add to the diagnostic chain the evaluation's diagnostic
78
   * @param value the expression to manage
79
   * @param object the current EObject
80
   * @param theDiagnostics the diagnostic's chain
81
   * @param context the context of the current validation
82
   * @return true if it's OK else false
83
   */
84
  boolean validate(String value, EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context);
85
}

Return to bug 255786