## org.eclipse.emf.ecore.util
Class EObjectValidator

    java.lang.Object
      org.eclipse.emf.ecore.util.EObjectValidator

All Implemented Interfaces:
  EValidator

Direct Known Subclasses:
  EcoreValidator, GenModelValidator, XMLNamespaceValidator, XMLTypeValidator

    public class EObjectValidator

extends java.lang.Object
implements EValidator

A validity checker for basic EObject constraints.

Nested Class Summary
`class` `EObjectValidator.DynamicEDataTypeValidator`

Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.EValidator
`EValidator.Descriptor, EValidator.PatternMatcher, EValidator.Registry, EValidator.SubstitutionLabelProvider`

Field Summary
`static int` `DATA_VALUE__FRACTION_DIGITS_IN_RANGE`
`static int` `DATA_VALUE__LENGTH_IN_RANGE`
`static int` `DATA_VALUE__MATCHES_PATTERN`
`static int` `DATA_VALUE__TOTAL_DIGITS_IN_RANGE`
`static int` `DATA_VALUE__TYPE_CORRECT`
`static int` `DATA_VALUE__VALUE_IN_ENUMERATION`
`static int` `DATA_VALUE__VALUE_IN_RANGE`
`static java.lang.String` `DIAGNOSTIC_SOURCE`
`static int` `EOBJECT__EVERY_DATA_VALUE_CONFORMS`
`static int` `EOBJECT__EVERY_KEY_UNIQUE`
`static int` `EOBJECT__EVERY_MAP_ENTRY_UNIQUE`
`static int` `EOBJECT__EVERY_MULTIPCITY_CONFORMS`
`static int` `EOBJECT__EVERY_PROXY_RESOLVES`
`static int` `EOBJECT__EVERY_REFERENCE_IS_CONTAINED`
`static int` `EOBJECT__NO_CIRCULAR_CONTAINMENT`
`static int` `EOBJECT__UNIQUE_ID`
`static EObjectValidator` `INSTANCE`
`static java.lang.String` `ROOT_OBJECT` A key to be used in `context` maps to indicate the root object at which validation started.

Fields inherited from interface org.eclipse.emf.ecore.EValidator
`MARKER, RELATED_URIS_ATTRIBUTE, URI_ATTRIBUTE`

Constructor Summary
`EObjectValidator()`

Method Summary
`protected DiagnosticChain` `createBadDataValueDiagnostic(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected BasicDiagnostic` `createDiagnostic(int severity, java.lang.String source, int code, java.lang.String messageKey, java.lang.Object[] messageSubstitutions, java.lang.Object[] data, java.util.Map<java.lang.Object,java.lang.Object> context)` Creates a new `basic diagnostic`.
`protected ResourceLocator` `getEcoreResourceLocator()` Returns the resource locator for `fetching` Ecore-specific messages.
`protected java.lang.String` `getEcoreString(java.lang.String key, java.lang.Object[] substitutions)` Returns a translated message with the given substitutions.
`protected EPackage` `getEPackage()`
`static java.lang.String` `getFeatureLabel(EStructuralFeature eStructuralFeature, java.util.Map<java.lang.Object,java.lang.Object> context)`
`static java.lang.String` `getObjectLabel(EObject eObject, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected ResourceLocator` `getResourceLocator()` Returns the resource locator for `fetching` model-specific messages.
`protected EValidator` `getRootEValidator(java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected java.lang.String` `getString(java.lang.String key, java.lang.Object[] substitutions)` Returns a translated message with the given substitutions.
`static java.lang.String` `getValueLabel(EDataType eDataType, java.lang.Object value, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportDataValuePatternViolation(EDataType eDataType, java.lang.Object value, EValidator.PatternMatcher[] patterns, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportDataValueTypeViolation(EDataType eDataType, java.lang.Object value, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportEnumerationViolation(EDataType eDataType, java.lang.Object value, java.util.Collection<?> values, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportFractionDigitsViolation(EDataType eDataType, java.lang.Object value, int fractionDigits, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportMaxLengthViolation(EDataType eDataType, java.lang.Object value, int length, int bound, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportMaxViolation(EDataType eDataType, java.lang.Object value, java.lang.Object bound, boolean isInclusive, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportMinLengthViolation(EDataType eDataType, java.lang.Object value, int length, int bound, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportMinViolation(EDataType eDataType, java.lang.Object value, java.lang.Object bound, boolean isInclusive, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected void` `reportTotalDigitsViolation(EDataType eDataType, java.lang.Object value, int totalDigits, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected boolean` `validate_DataValueConforms(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryDataValueConforms(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryDefaultConstraint(EObject object, DiagnosticChain theDiagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryKeyUnique(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryMapEntryUnique(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryMultiplicityConforms(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_EveryReferenceIsContained(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected boolean` `validate_KeyUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected boolean` `validate_MapEntryUnique(EObject eObject, EReference eReference, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected boolean` `validate_MultiplicityConforms(EObject eObject, EStructuralFeature eStructuralFeature, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_NoCircularContainment(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate_UniqueID(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate(EDataType eDataType, java.lang.Object value, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`boolean` `validate(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)` Validates the object in the given context, optionally producing diagnostics.
`protected boolean` `validate(int classifierID, java.lang.Object object, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected boolean` `validatePattern(EDataType eDataType, java.lang.Object value, EValidator.PatternMatcher[][] patterns, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)`
`protected static java.util.Collection<java.lang.Object>` `wrapEnumerationValues(java.lang.Object[] values)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INSTANCE

    public static final EObjectValidator INSTANCE

### DIAGNOSTIC_SOURCE

    public static final java.lang.String DIAGNOSTIC_SOURCE

See Also:
  Constant Field Values

### EOBJECT__EVERY_MULTIPCITY_CONFORMS

    public static final int EOBJECT__EVERY_MULTIPCITY_CONFORMS

See Also:
  Constant Field Values

### EOBJECT__EVERY_DATA_VALUE_CONFORMS

    public static final int EOBJECT__EVERY_DATA_VALUE_CONFORMS

See Also:
  Constant Field Values

### EOBJECT__EVERY_REFERENCE_IS_CONTAINED

    public static final int EOBJECT__EVERY_REFERENCE_IS_CONTAINED

See Also:
  Constant Field Values

### EOBJECT__EVERY_PROXY_RESOLVES

    public static final int EOBJECT__EVERY_PROXY_RESOLVES

See Also:
  Constant Field Values

### DATA_VALUE__VALUE_IN_RANGE

    public static final int DATA_VALUE__VALUE_IN_RANGE

See Also:
  Constant Field Values

### DATA_VALUE__LENGTH_IN_RANGE

    public static final int DATA_VALUE__LENGTH_IN_RANGE

See Also:
  Constant Field Values

### DATA_VALUE__TYPE_CORRECT

    public static final int DATA_VALUE__TYPE_CORRECT

See Also:
  Constant Field Values

### DATA_VALUE__VALUE_IN_ENUMERATION

    public static final int DATA_VALUE__VALUE_IN_ENUMERATION

See Also:
  Constant Field Values

### DATA_VALUE__MATCHES_PATTERN

    public static final int DATA_VALUE__MATCHES_PATTERN

See Also:
  Constant Field Values

### DATA_VALUE__TOTAL_DIGITS_IN_RANGE

    public static final int DATA_VALUE__TOTAL_DIGITS_IN_RANGE

See Also:
  Constant Field Values

### DATA_VALUE__FRACTION_DIGITS_IN_RANGE

    public static final int DATA_VALUE__FRACTION_DIGITS_IN_RANGE

See Also:
  Constant Field Values

### EOBJECT__UNIQUE_ID

    public static final int EOBJECT__UNIQUE_ID

See Also:
  Constant Field Values

### EOBJECT__EVERY_KEY_UNIQUE

    public static final int EOBJECT__EVERY_KEY_UNIQUE

See Also:
  Constant Field Values

### EOBJECT__EVERY_MAP_ENTRY_UNIQUE

    public static final int EOBJECT__EVERY_MAP_ENTRY_UNIQUE

See Also:
  Constant Field Values

### EOBJECT__NO_CIRCULAR_CONTAINMENT

    public static final int EOBJECT__NO_CIRCULAR_CONTAINMENT

See Also:
  Constant Field Values

### ROOT_OBJECT

    public static final java.lang.String ROOT_OBJECT

  A key to be used in `context` maps to indicate the root object at which validation started. It's used to detect `circular containment` and to prevent `infinite recursion`. The value of the entry must be the root`EObject`.

  Since:
    2.5
  See Also:
    `EValidator.validate(EObject, DiagnosticChain, Map)`, `validate_NoCircularContainment(EObject, DiagnosticChain, Map)`, Constant Field Values

Constructor Detail

### EObjectValidator

    public EObjectValidator()

Method Detail

### getObjectLabel

    public static java.lang.String getObjectLabel(EObject eObject,
                                                  java.util.Map<java.lang.Object,java.lang.Object> context)

  Since:
    2.1.0

### getFeatureLabel

    public static java.lang.String getFeatureLabel(EStructuralFeature eStructuralFeature,
                                                   java.util.Map<java.lang.Object,java.lang.Object> context)

  Since:
    2.1.0

### getValueLabel

    public static java.lang.String getValueLabel(EDataType eDataType,
                                                 java.lang.Object value,
                                                 java.util.Map<java.lang.Object,java.lang.Object> context)

  Since:
    2.1.0

### getEPackage

    protected EPackage getEPackage()

### getRootEValidator

    protected EValidator getRootEValidator(java.util.Map<java.lang.Object,java.lang.Object> context)

### validate

    public boolean validate(EObject eObject,
                            DiagnosticChain diagnostics,
                            java.util.Map<java.lang.Object,java.lang.Object> context)

  Validates the object in the given context, optionally producing diagnostics.

  Specified by:
    `validate` in interface `EValidator`
  Parameters:
    `diagnostics` - a place to accumulate diagnostics; if it's `null`, no diagnostics should be produced.
    `context` - a place to cache information, if it's `null`, no cache is supported.
  Returns:
    whether the object is valid.

### validate

    public boolean validate(EClass eClass,
                            EObject eObject,
                            DiagnosticChain diagnostics,
                            java.util.Map<java.lang.Object,java.lang.Object> context)

  Specified by:
    `validate` in interface `EValidator`

### validate

    protected boolean validate(int classifierID,
                               java.lang.Object object,
                               DiagnosticChain diagnostics,
                               java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_EveryDefaultConstraint

    public boolean validate_EveryDefaultConstraint(EObject object,
                                                   DiagnosticChain theDiagnostics,
                                                   java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_NoCircularContainment

    public boolean validate_NoCircularContainment(EObject eObject,
                                                  DiagnosticChain diagnostics,
                                                  java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_EveryMultiplicityConforms

    public boolean validate_EveryMultiplicityConforms(EObject eObject,
                                                      DiagnosticChain diagnostics,
                                                      java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_MultiplicityConforms

    protected boolean validate_MultiplicityConforms(EObject eObject,
                                                    EStructuralFeature eStructuralFeature,
                                                    DiagnosticChain diagnostics,
                                                    java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_EveryProxyResolves

    public boolean validate_EveryProxyResolves(EObject eObject,
                                               DiagnosticChain diagnostics,
                                               java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_EveryReferenceIsContained

    public boolean validate_EveryReferenceIsContained(EObject eObject,
                                                      DiagnosticChain diagnostics,
                                                      java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_EveryDataValueConforms

    public boolean validate_EveryDataValueConforms(EObject eObject,
                                                   DiagnosticChain diagnostics,
                                                   java.util.Map<java.lang.Object,java.lang.Object> context)

### validate_DataValueConforms

    protected boolean validate_DataValueConforms(EObject eObject,
                                                 EAttribute eAttribute,
                                                 DiagnosticChain diagnostics,
                                                 java.util.Map<java.lang.Object,java.lang.Object> context)

### createBadDataValueDiagnostic

    protected DiagnosticChain createBadDataValueDiagnostic(EObject eObject,
                                                           EAttribute eAttribute,
                                                           DiagnosticChain diagnostics,
                                                           java.util.Map<java.lang.Object,java.lang.Object> context)

### validatePattern

    protected boolean validatePattern(EDataType eDataType,
                                      java.lang.Object value,
                                      EValidator.PatternMatcher[][] patterns,
                                      DiagnosticChain diagnostics,
                                      java.util.Map<java.lang.Object,java.lang.Object> context)

### validate

    public boolean validate(EDataType eDataType,
                            java.lang.Object value,
                            DiagnosticChain diagnostics,
                            java.util.Map<java.lang.Object,java.lang.Object> context)

  Specified by:
    `validate` in interface `EValidator`

### reportMinViolation

    protected void reportMinViolation(EDataType eDataType,
                                      java.lang.Object value,
                                      java.lang.Object bound,
                                      boolean isInclusive,
                                      DiagnosticChain diagnostics,
                                      java.util.Map<java.lang.Object,java.lang.Object> context)

### reportMaxViolation

    protected void reportMaxViolation(EDataType eDataType,
                                      java.lang.Object value,
                                      java.lang.Object bound,
                                      boolean isInclusive,
                                      DiagnosticChain diagnostics,
                                      java.util.Map<java.lang.Object,java.lang.Object> context)

### reportMinLengthViolation

    protected void reportMinLengthViolation(EDataType eDataType,
                                            java.lang.Object value,
                                            int length,
                                            int bound,
                                            DiagnosticChain diagnostics,
                                            java.util.Map<java.lang.Object,java.lang.Object> context)

### reportMaxLengthViolation

    protected void reportMaxLengthViolation(EDataType eDataType,
                                            java.lang.Object value,
                                            int length,
                                            int bound,
                                            DiagnosticChain diagnostics,
                                            java.util.Map<java.lang.Object,java.lang.Object> context)

### reportTotalDigitsViolation

    protected void reportTotalDigitsViolation(EDataType eDataType,
                                              java.lang.Object value,
                                              int totalDigits,
                                              DiagnosticChain diagnostics,
                                              java.util.Map<java.lang.Object,java.lang.Object> context)

### reportFractionDigitsViolation

    protected void reportFractionDigitsViolation(EDataType eDataType,
                                                 java.lang.Object value,
                                                 int fractionDigits,
                                                 DiagnosticChain diagnostics,
                                                 java.util.Map<java.lang.Object,java.lang.Object> context)

### reportEnumerationViolation

    protected void reportEnumerationViolation(EDataType eDataType,
                                              java.lang.Object value,
                                              java.util.Collection<?> values,
                                              DiagnosticChain diagnostics,
                                              java.util.Map<java.lang.Object,java.lang.Object> context)

### reportDataValuePatternViolation

    protected void reportDataValuePatternViolation(EDataType eDataType,
                                                   java.lang.Object value,
                                                   EValidator.PatternMatcher[] patterns,
                                                   DiagnosticChain diagnostics,
                                                   java.util.Map<java.lang.Object,java.lang.Object> context)

### reportDataValueTypeViolation

    protected void reportDataValueTypeViolation(EDataType eDataType,
                                                java.lang.Object value,
                                                DiagnosticChain diagnostics,
                                                java.util.Map<java.lang.Object,java.lang.Object> context)

### wrapEnumerationValues

    protected static java.util.Collection<java.lang.Object> wrapEnumerationValues(java.lang.Object[] values)

### validate_UniqueID

    public boolean validate_UniqueID(EObject eObject,
                                     DiagnosticChain diagnostics,
                                     java.util.Map<java.lang.Object,java.lang.Object> context)

  Since:
    2.2

### validate_EveryKeyUnique

    public boolean validate_EveryKeyUnique(EObject eObject,
                                           DiagnosticChain diagnostics,
                                           java.util.Map<java.lang.Object,java.lang.Object> context)

  Parameters:
    `eObject` -
    `diagnostics` -
    `context` -
  Returns:
    whether every key is unique.
  Since:
    2.3

### validate_KeyUnique

    protected boolean validate_KeyUnique(EObject eObject,
                                         EReference eReference,
                                         DiagnosticChain diagnostics,
                                         java.util.Map<java.lang.Object,java.lang.Object> context)

  Parameters:
    `eObject` -
    `eReference` -
    `diagnostics` -
    `context` -
  Returns:
    whether every key is unique.
  Since:
    2.3

### validate_EveryMapEntryUnique

    public boolean validate_EveryMapEntryUnique(EObject eObject,
                                                DiagnosticChain diagnostics,
                                                java.util.Map<java.lang.Object,java.lang.Object> context)

  Parameters:
    `eObject` -
    `diagnostics` -
    `context` -
  Returns:
    whether every map entry is unique.
  Since:
    2.3

### validate_MapEntryUnique

    protected boolean validate_MapEntryUnique(EObject eObject,
                                              EReference eReference,
                                              DiagnosticChain diagnostics,
                                              java.util.Map<java.lang.Object,java.lang.Object> context)

  Parameters:
    `eObject` -
    `eReference` -
    `diagnostics` -
    `context` -
  Returns:
    whether every map entry is unique.
  Since:
    2.3

### createDiagnostic

    protected BasicDiagnostic createDiagnostic(int severity,
                                               java.lang.String source,
                                               int code,
                                               java.lang.String messageKey,
                                               java.lang.Object[] messageSubstitutions,
                                               java.lang.Object[] data,
                                               java.util.Map<java.lang.Object,java.lang.Object> context)

  Creates a new `basic diagnostic`. If the source is `"org.eclipse.emf.ecore"`, it calls `getEcoreString(String, Object[])`; otherwise it calls `getString(String, Object[])`.

  Parameters:
    `severity` - an indicator of the severity of the problem.
    `source` - the unique identifier of the source.
    `code` - the source-specific identity code.
    `messageKey` - the key of the message.
    `messageSubstitutions` - the substitutions for the key; `null` if there are no substitutions.
    `data` - the data associated with the diagnostic
    `context` - a place to cache information, if it's `null`, no cache is supported.
  Returns:
    a new diagnostic.
  Since:
    2.4
  See Also:
    `BasicDiagnostic.BasicDiagnostic(int, String, int, String, Object[])`

### getEcoreString

    protected java.lang.String getEcoreString(java.lang.String key,
                                              java.lang.Object[] substitutions)

  Returns a translated message with the given substitutions. The `Ecore resource locator` is used.

  Parameters:
    `key` - the key for the message.
    `substitutions` - the substitutions for the key; `null` if there are no substitutions.
  Returns:
    the message.
  Since:
    2.4

### getEcoreResourceLocator

    protected ResourceLocator getEcoreResourceLocator()

  Returns the resource locator for `fetching` Ecore-specific messages.

  Returns:
    the resource locator for fetching Ecore-specific messages.
  Since:
    2.2

### getString

    protected java.lang.String getString(java.lang.String key,
                                         java.lang.Object[] substitutions)

  Returns a translated message with the given substitutions. The `resource locator` is used.

  Parameters:
    `key` - the key for the message.
    `substitutions` - the substitutions for the key; `null` if there are no substitutions.
  Returns:
    the message.
  Since:
    2.4

### getResourceLocator

    protected ResourceLocator getResourceLocator()

  Returns the resource locator for `fetching` model-specific messages. This implementation returns the `Ecore resource locator`; derived validators must override this to return the resource locator for their model.

  Returns:
    the resource locator for fetching model-specific messages.
  Since:
    2.4

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.