public class Diagnostician extends java.lang.Object implements EValidator.SubstitutionLabelProvider, EValidator
EValidator.Descriptor, EValidator.PatternMatcher, EValidator.Registry, EValidator.SubstitutionLabelProvider, EValidator.ValidationDelegate
Modifier and Type | Field and Description |
---|---|
protected EValidator.Registry |
eValidatorRegistry |
static Diagnostician |
INSTANCE |
static java.lang.String |
VALIDATE_RECURSIVELY
A Boolean key to be used in
context maps to indicate whether validate(EObject, DiagnosticChain, Map)
should directly call validate(EClass, EObject, DiagnosticChain, Map) once and expect that method to recursively call doValidateContents(EObject, DiagnosticChain, Map)
or whether it should iterate over all contents and call validate(EClass, EObject, DiagnosticChain, Map) for each
with the expectation that that method not call doValidateContents(EObject, DiagnosticChain, Map) . |
MARKER, RELATED_URIS_ATTRIBUTE, URI_ATTRIBUTE
Constructor and Description |
---|
Diagnostician() |
Diagnostician(EValidator.Registry eValidatorRegistry) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.Object,java.lang.Object> |
createDefaultContext() |
BasicDiagnostic |
createDefaultDiagnostic(EDataType eDataType,
java.lang.Object value) |
BasicDiagnostic |
createDefaultDiagnostic(EObject eObject) |
protected boolean |
doValidate(EValidator eValidator,
EClass eClass,
EObject eObject,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context) |
protected boolean |
doValidate(EValidator eValidator,
EDataType eDataType,
java.lang.Object value,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context) |
protected boolean |
doValidateContents(EObject eObject,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context) |
java.lang.String |
getFeatureLabel(EStructuralFeature eStructuralFeature)
Returns the label used to identify a feature.
|
java.lang.String |
getObjectLabel(EObject eObject)
Returns the label to identify an object.
|
java.lang.String |
getValueLabel(EDataType eDataType,
java.lang.Object value)
Returns the label to identify a value of some data type.
|
protected boolean |
handleThrowable(EClass eClass,
EObject eObject,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context,
java.lang.Throwable throwable)
Called by
validate(EClass, EObject, DiagnosticChain, Map) when an exception is thrown during validation. |
protected boolean |
isValidateContentsRecursively()
Returns whether
validate(EObject, DiagnosticChain, Map) should call validate(EClass, EObject, DiagnosticChain, Map) once
with VALIDATE_RECURSIVELY mapped to Boolean.TRUE in the context ,
or should iterator over all contents ,
including the given object,
and call validate(EClass, EObject, DiagnosticChain, Map) for each
with VALIDATE_RECURSIVELY mapped to Boolean.FALSE in the context . |
boolean |
validate(EClass eClass,
EObject eObject,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context)
Validates the object.
|
Diagnostic |
validate(EDataType eDataType,
java.lang.Object value) |
boolean |
validate(EDataType eDataType,
java.lang.Object value,
DiagnosticChain diagnostics,
java.util.Map<java.lang.Object,java.lang.Object> context) |
Diagnostic |
validate(EObject eObject) |
boolean |
validate(EObject eObject,
DiagnosticChain diagnostics)
Validates the object in the given context, optionally producing diagnostics.
|
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.
|
Diagnostic |
validate(EObject eObject,
java.util.Map<?,?> contextEntries) |
public static final java.lang.String VALIDATE_RECURSIVELY
context
maps to indicate whether validate(EObject, DiagnosticChain, Map)
should directly call validate(EClass, EObject, DiagnosticChain, Map)
once and expect that method to recursively call doValidateContents(EObject, DiagnosticChain, Map)
or whether it should iterate over all contents and call validate(EClass, EObject, DiagnosticChain, Map)
for each
with the expectation that that method not call doValidateContents(EObject, DiagnosticChain, Map)
.
In either case, doValidate(EValidator, EClass, EObject, DiagnosticChain, Map)
is ultimately called for each object in the tree.
The default behavior is controlled by isValidateContentsRecursively()
which is false
in the default implementation.
So as of EMF 2.14, the default behavior is to use iteration instead of recursion to validate all objects in the tree.public static final Diagnostician INSTANCE
protected EValidator.Registry eValidatorRegistry
public Diagnostician(EValidator.Registry eValidatorRegistry)
public Diagnostician()
public java.lang.String getObjectLabel(EObject eObject)
EValidator.SubstitutionLabelProvider
getObjectLabel
in interface EValidator.SubstitutionLabelProvider
public java.lang.String getFeatureLabel(EStructuralFeature eStructuralFeature)
EValidator.SubstitutionLabelProvider
getFeatureLabel
in interface EValidator.SubstitutionLabelProvider
public java.lang.String getValueLabel(EDataType eDataType, java.lang.Object value)
EValidator.SubstitutionLabelProvider
getValueLabel
in interface EValidator.SubstitutionLabelProvider
public java.util.Map<java.lang.Object,java.lang.Object> createDefaultContext()
public BasicDiagnostic createDefaultDiagnostic(EObject eObject)
public BasicDiagnostic createDefaultDiagnostic(EDataType eDataType, java.lang.Object value)
public Diagnostic validate(EObject eObject)
public Diagnostic validate(EObject eObject, java.util.Map<?,?> contextEntries)
public boolean validate(EObject eObject, DiagnosticChain diagnostics)
eObject
- the object to validate.diagnostics
- a place to accumulate diagnostics; if it's null
, no diagnostics should be produced.protected boolean isValidateContentsRecursively()
validate(EObject, DiagnosticChain, Map)
should call validate(EClass, EObject, DiagnosticChain, Map)
once
with VALIDATE_RECURSIVELY
mapped to Boolean.TRUE
in the context
,
or should iterator over all contents
,
including the given object,
and call validate(EClass, EObject, DiagnosticChain, Map)
for each
with VALIDATE_RECURSIVELY
mapped to Boolean.FALSE
in the context
.public boolean validate(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
This implementation will ultimately recursive validate all objects in the containment tree.
But, depending on isValidateContentsRecursively()
and the value of VALIDATE_RECURSIVELY
in the context
,
it will do so either iteratively or recursively.
validate
in interface EValidator
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.public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
context
does not contain VALIDATE_RECURSIVELY
mapped to Boolean.FALSE
,
this method will call doValidateContents(EObject, DiagnosticChain, Map)
,
i.e., it will recursively validate all contents of the tree unless the context explicitly indicates not to do that.validate
in interface EValidator
protected boolean handleThrowable(EClass eClass, EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context, java.lang.Throwable throwable)
validate(EClass, EObject, DiagnosticChain, Map)
when an exception is thrown during validation.
If diagnostics are being recorded and the exception is a RuntimeException
or an AssertionError
,
a diagnostic is created and added to the diagnostics to record the exception.
Returns true if the throwable has been adequately handled, false if the caller should rethrow it.protected boolean doValidate(EValidator eValidator, EClass eClass, EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
protected boolean doValidateContents(EObject eObject, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
public Diagnostic validate(EDataType eDataType, java.lang.Object value)
public boolean validate(EDataType eDataType, java.lang.Object value, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
validate
in interface EValidator
protected boolean doValidate(EValidator eValidator, EDataType eDataType, java.lang.Object value, DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
Copyright © 2021. Licensed under the Eclipse Public License v2.0. All rights reserved.
Submit a bug or feature