Class EvlValidator
- java.lang.Object
-
- org.eclipse.epsilon.evl.emf.validation.EvlValidator
-
- All Implemented Interfaces:
org.eclipse.emf.ecore.EValidator
public class EvlValidator extends java.lang.Object implements org.eclipse.emf.ecore.EValidator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
EvlValidator.ValidationProblemListener
-
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.EValidator
org.eclipse.emf.ecore.EValidator.Descriptor, org.eclipse.emf.ecore.EValidator.PatternMatcher, org.eclipse.emf.ecore.EValidator.Registry, org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider, org.eclipse.emf.ecore.EValidator.ValidationDelegate
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
bundleId
protected org.eclipse.emf.ecore.resource.Resource
currentResource
static java.lang.String
DEFAULT_MODEL_NAME
protected org.eclipse.emf.common.util.DiagnosticChain
diagnostics
protected java.util.Set<java.lang.String>
diagnosticVariables
protected java.util.Collection<org.eclipse.emf.ecore.EPackage>
ePackages
Collection of all packages that are available to this validatorprotected java.lang.String
ePackageUri
protected java.util.Collection<org.eclipse.emf.ecore.EObject>
history
protected boolean
logErrors
protected java.lang.String
modelName
protected IEvlModule
module
protected EmfPrettyPrinter
printer
protected java.util.Collection<EvlValidator.ValidationProblemListener>
problemListeners
protected ValidationResults
results
protected boolean
showErrorDialog
protected java.net.URI
source
static java.lang.String
VALIDATION_MONITOR
Key for the validation context, that (when provided) holds a IProgressMonitor object
-
Constructor Summary
Constructors Constructor Description EvlValidator()
Note when using this constructor, make sure to callinitialise(URI, String, String, String)
afterwardsEvlValidator(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalPackage(java.lang.String packageUri)
Make an additional package available to be used by this validator.void
addDiagnosticianVariable(java.lang.String name)
Indicates that the value of the entry of theDiagnostician
contextMap
with the specifiedname
should be published as a global variable in the EVL script.protected void
addMarkers(java.lang.String msgPrefix, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics)
void
addValidationProblemListener(EvlValidator.ValidationProblemListener listener)
protected org.eclipse.emf.common.util.Diagnostic
createDiagnostic(java.lang.String msgPrefix, UnsatisfiedConstraint unsatisfied)
void
initialise(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
boolean
isLogErrors()
This method is used by the default implementation oflogException()
boolean
isShowErrorDialog()
boolean
logException(java.lang.Exception exception)
Method to determine whether the given exception needs to be logged.protected IEvlModule
newModule()
boolean
removeValidationProblemListener(EvlValidator.ValidationProblemListener listener)
void
setLogErrors(boolean logErrors)
Sets whether errors need to be logged or notvoid
setShowErrorDialog(boolean showErrorDialog)
Sets whether an error dialog needs to be shownboolean
validate(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
boolean
validate(org.eclipse.emf.ecore.EDataType dataType, java.lang.Object value, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
boolean
validate(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
protected void
validate(org.eclipse.emf.ecore.resource.Resource resource, java.util.Map<java.lang.Object,java.lang.Object> context)
-
-
-
Field Detail
-
diagnosticVariables
protected java.util.Set<java.lang.String> diagnosticVariables
-
module
protected IEvlModule module
-
source
protected java.net.URI source
-
printer
protected EmfPrettyPrinter printer
-
currentResource
protected org.eclipse.emf.ecore.resource.Resource currentResource
-
results
protected ValidationResults results
-
history
protected java.util.Collection<org.eclipse.emf.ecore.EObject> history
-
modelName
protected java.lang.String modelName
-
ePackageUri
protected java.lang.String ePackageUri
-
bundleId
protected java.lang.String bundleId
-
showErrorDialog
protected boolean showErrorDialog
-
logErrors
protected boolean logErrors
-
problemListeners
protected java.util.Collection<EvlValidator.ValidationProblemListener> problemListeners
-
diagnostics
protected org.eclipse.emf.common.util.DiagnosticChain diagnostics
-
ePackages
protected java.util.Collection<org.eclipse.emf.ecore.EPackage> ePackages
Collection of all packages that are available to this validator
-
DEFAULT_MODEL_NAME
public static final java.lang.String DEFAULT_MODEL_NAME
- See Also:
- Constant Field Values
-
VALIDATION_MONITOR
public static final java.lang.String VALIDATION_MONITOR
Key for the validation context, that (when provided) holds a IProgressMonitor object- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EvlValidator
public EvlValidator()
Note when using this constructor, make sure to callinitialise(URI, String, String, String)
afterwards
-
EvlValidator
public EvlValidator(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
-
Method Detail
-
initialise
public void initialise(java.net.URI source, java.lang.String modelName, java.lang.String ePackageUri, java.lang.String bundleId)
-
addDiagnosticianVariable
public void addDiagnosticianVariable(java.lang.String name)
Indicates that the value of the entry of the
Diagnostician
contextMap
with the specifiedname
should be published as a global variable in the EVL script. If the context map does not contain an entry with the specifiedname
, the variable will be set tonull
.Note: this map is received through the
validate
methods in this class.
-
addAdditionalPackage
public void addAdditionalPackage(java.lang.String packageUri)
Make an additional package available to be used by this validator.- Parameters:
packageUri
- Namespace URI of the package
-
validate
public boolean validate(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
- Specified by:
validate
in interfaceorg.eclipse.emf.ecore.EValidator
-
validate
public boolean validate(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
- Specified by:
validate
in interfaceorg.eclipse.emf.ecore.EValidator
-
validate
public boolean validate(org.eclipse.emf.ecore.EDataType dataType, java.lang.Object value, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
- Specified by:
validate
in interfaceorg.eclipse.emf.ecore.EValidator
-
createDiagnostic
protected org.eclipse.emf.common.util.Diagnostic createDiagnostic(java.lang.String msgPrefix, UnsatisfiedConstraint unsatisfied)
-
newModule
protected IEvlModule newModule()
- Returns:
- A new
IEvlModule
- Since:
- 1.6
-
validate
protected void validate(org.eclipse.emf.ecore.resource.Resource resource, java.util.Map<java.lang.Object,java.lang.Object> context)
-
addMarkers
protected void addMarkers(java.lang.String msgPrefix, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics)
-
isShowErrorDialog
public boolean isShowErrorDialog()
- Returns:
- true if an error dialog needs to be shown when an error occurs
-
setShowErrorDialog
public void setShowErrorDialog(boolean showErrorDialog)
Sets whether an error dialog needs to be shown- See Also:
isShowErrorDialog()
-
logException
public boolean logException(java.lang.Exception exception)
Method to determine whether the given exception needs to be logged. Can be overridden to filter out certain types of exceptions (e.g. when the user cancelled the validation)- Returns:
- true if error needs to be logged
-
isLogErrors
public boolean isLogErrors()
This method is used by the default implementation oflogException()
- Returns:
- true if errors need to be logged
- See Also:
logException(Exception)
-
setLogErrors
public void setLogErrors(boolean logErrors)
Sets whether errors need to be logged or not- See Also:
isLogErrors()
-
addValidationProblemListener
public void addValidationProblemListener(EvlValidator.ValidationProblemListener listener)
-
removeValidationProblemListener
public boolean removeValidationProblemListener(EvlValidator.ValidationProblemListener listener)
-
-