org.eclipse.wst.validation
Class Validator
java.lang.Object
org.eclipse.wst.validation.Validator
-
All Implemented Interfaces:
- java.lang.Comparable<
Validator>
-
Direct Known Subclasses:
-
Validator.V1,
Validator.V2
-
public abstract class Validator
- extends java.lang.Object
- implements java.lang.Comparable<
Validator>
Represents a validator. This gets instantiated through one of the validator extension points.
This class is not API.
Nested Class Summary
|
static class
|
Validator.Level
The level of configuration for the validator. |
static class
|
Validator.V1
A validator that uses version 1 of the validation framework. |
static class
|
Validator.V2
A validator that uses version 2 of the validation framework. |
Constructor Summary
|
Validator
(IProject project)
|
Method Summary
|
IValidator
|
asIValidator
()
|
Validator.V1
|
asV1Validator
()
If you are a version 1 validator, answer yourself as one, otherwise answer null. |
Validator.V2
|
asV2Validator
()
If you are a version 2 validator, answer yourself as one, otherwise answer null. |
void
|
bumpChangeCountGlobal
()
|
void
|
bumpChangeCountMessages
()
|
void
|
clean
(IProject project,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor)
The project is being cleaned, this method gives the validator a chance to do any special cleanup. |
int
|
compareTo
(
Validator validator)
Compare yourself based on Validator name. |
Validator
|
copy
()
Answer a deep copy of yourself. |
abstract
Validator
|
copy
(boolean includeChangeCounts)
|
static
Validator
|
create
(IConfigurationElement validator,
IProject project)
Create a new validator based on a abstract validator. |
static
Validator
|
create
(ValidatorMetaData vmd,
ValidationConfiguration config,
IProject project)
Create a new validator based on validator meta data. |
int
|
getChangeCountGlobal
()
|
int
|
getChangeCountMessages
()
|
java.lang.String
|
getDelegatingId
()
Get the id of the "real" validator, that is the validator that will be called when this delegating
validator is asked to validate something. |
abstract java.lang.String
|
getId
()
|
java.lang.String
|
getMarkerId
()
|
MessageSeveritySetting
|
getMessage
(java.lang.String id)
|
java.util.Map<java.lang.String,
MessageSeveritySetting>
|
getMessageSettings
()
Answer all the message settings that this validator has defined. |
abstract java.lang.String
|
getName
()
|
IProject
|
getProject
()
Answer the project that you were enabled on. |
java.lang.String
|
getSourceId
()
|
abstract java.lang.String
|
getValidatorClassname
()
Answer the name of the class that implements the validator. |
int
|
getVersion
()
|
boolean
|
hasGlobalChanges
()
|
int
|
hashCodeForConfig
()
Answer a hash code for the configurable fields so that we can quickly determine if two
validators are the same. |
boolean
|
isBuildValidation
()
Is this validator currently enabled for validations that are triggered by builds? |
boolean
|
isChanged
()
Has the validator changed since it was last created or copied? |
boolean
|
isManualValidation
()
Is this validator currently enabled for validations that are triggered manually? |
void
|
resetChangeCounters
()
|
boolean
|
sameConfig
(
Validator validator)
Answer true if you have the same configuration settings as validator. |
boolean
|
setBuildValidation
(boolean buildValidation)
Set whether this validator should be triggered by the build process. |
void
|
setDelegatingId
(java.lang.String delegating)
Set the id of the "real" validator, that is the validator that will be called when this delegating
validator is asked to validate something. |
boolean
|
setManualValidation
(boolean manualValidation)
Set whether this validator should be triggered as part of a manual validation. |
void
|
setMarkerId
(java.lang.String markerId)
|
void
|
setSourceId
(java.lang.String sourceId)
|
void
|
setVersion
(int version)
|
boolean
|
shouldClearMarkers
(
ValidationEvent event)
Should the validation framework first clear the markers that this
validator has placed on this resource? |
boolean
|
shouldValidate
(IResource resource,
boolean isManual,
boolean isBuild)
Answer true if this validator, based on it's filters, should validate
this resource. |
boolean
|
shouldValidate
(IResource resource,
org.eclipse.wst.validation.internal.ValType valType)
Answer true if this validator, based on it's filters, should validate
this resource. |
boolean
|
shouldValidateProject
(IProject project,
boolean isManual,
boolean isBuild)
Answer true if this validator, based on it's filters, should validate this project. |
boolean
|
shouldValidateProject
(IProject project,
org.eclipse.wst.validation.internal.ValType type)
Answer true if this validator, based on it's filters, should validate this project. |
java.lang.String
|
toString
()
|
abstract
ValidationResult
|
validate
(IResource resource,
int kind,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor)
Validate the resource. |
ValidationResult
|
validate
(IResource resource,
int kind,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor,
ValidationEvent event)
Validate the resource. |
void
|
validationFinishing
(IProject project,
ValidationState state,
IProgressMonitor monitor)
This method will be called when validation is complete. |
void
|
validationStarting
(IProject project,
ValidationState state,
IProgressMonitor monitor)
This method will be called before any validation takes place. |
Methods inherited from class java.lang.Object
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
|
Validator
public Validator(IProject project)
create
public static
Validator create(IConfigurationElement validator,
IProject project)
- Create a new validator based on a abstract validator.
-
-
-
Parameters:
-
validator
- The validator that is being wrapped. -
project
- The project that you are defined in. This can be null which
means that you are a global validator.
create
public static
Validator create(ValidatorMetaData vmd,
ValidationConfiguration config,
IProject project)
- Create a new validator based on validator meta data.
-
-
-
Parameters:
-
project
- The project that you are defined in. This can be null which
means that you are a global validator.
asV1Validator
public
Validator.V1 asV1Validator()
- If you are a version 1 validator, answer yourself as one, otherwise answer null.
-
-
asV2Validator
public
Validator.V2 asV2Validator()
- If you are a version 2 validator, answer yourself as one, otherwise answer null.
-
-
clean
public void clean(IProject project,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor)
- The project is being cleaned, this method gives the validator a chance to do any special cleanup.
The default is to do nothing.
-
-
-
Parameters:
-
project
- the project being built. -
monitor
- the monitor that should be used for reporting progress if the clean takes a long time.
compareTo
public int compareTo(
Validator validator)
- Compare yourself based on Validator name.
-
-
Specified by:
-
compareTo
in interface java.lang.Comparable<
Validator>
-
copy
public
Validator copy()
- Answer a deep copy of yourself.
-
-
copy
public abstract
Validator copy(boolean includeChangeCounts)
-
-
shouldClearMarkers
public boolean shouldClearMarkers(
ValidationEvent event)
- Should the validation framework first clear the markers that this
validator has placed on this resource? This method can be overridden by
validator implementors to provide a validator specific behavior.
-
-
-
Parameters:
-
event
- The validation event that triggered the validation.
-
Returns:
- true if the validation framework should first clear all the
markers that this validator produced. This is the default
behavior. Return false to leave the markers unchanged. It then
becomes the responsibility of the validator to manage it's own
markers for this resource, for this validation event.
shouldValidate
public boolean shouldValidate(IResource resource,
boolean isManual,
boolean isBuild)
- Answer true if this validator, based on it's filters, should validate
this resource. This method does not check to see if global validation or
project validation has been suspended or not.
-
-
-
Parameters:
-
resource
- The resource to be checked. -
isManual
- If true then this validator must also be enabled for manual
validation. -
isBuild
- If true then this validator must also be enabled for builder
based validation.
-
Returns:
- true if the resource should be validated.
shouldValidate
public boolean shouldValidate(IResource resource,
org.eclipse.wst.validation.internal.ValType valType)
- Answer true if this validator, based on it's filters, should validate
this resource. This method does not check to see if global validation or
project validation has been suspended or not.
-
-
-
Parameters:
-
resource
- The resource to be checked. -
valType
- The context to use when performing the check.
-
Returns:
- true if the resource should be validated.
shouldValidateProject
public boolean shouldValidateProject(IProject project,
org.eclipse.wst.validation.internal.ValType type)
- Answer true if this validator, based on it's filters, should validate this project. This method
does not check to see if global validation or project validation has been suspended or not.
-
-
-
Parameters:
-
project
- the project to be checked -
type
- The type of validation request
-
Returns:
- true if the project should be validated.
shouldValidateProject
public boolean shouldValidateProject(IProject project,
boolean isManual,
boolean isBuild)
- Answer true if this validator, based on it's filters, should validate this project. This method
does not check to see if global validation or project validation has been suspended or not.
-
-
-
Parameters:
-
project
- the project to be checked -
isManual
- if true then this validator must also be enabled for manual validation. -
isBuild
- if true then this validator must also be enabled for builder based validation.
-
Returns:
- true if the project should be validated.
validate
public abstract
ValidationResult validate(IResource resource,
int kind,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor)
- Validate the resource.
-
-
-
Parameters:
-
resource
- The resource to be validated. -
kind
- The kind of resource change, see IResourceDelta for values. -
operation
- The operation that this validation is running under. This can
be null. -
monitor
- A way to report progress. This can be null.
-
Returns:
- the result of doing the validation, it can be, but usually isn't
null.
validate
public
ValidationResult validate(IResource resource,
int kind,
org.eclipse.wst.validation.internal.ValOperation operation,
IProgressMonitor monitor,
ValidationEvent event)
- Validate the resource.
-
-
-
Parameters:
-
resource
- The resource to be validated. -
kind
- The kind of resource change, see IResourceDelta for values. -
operation
- The operation that this validation is running under. This can
be null. -
monitor
- A way to report progress. This can be null. -
event
- An event that describes in more detail what should be
validated and why it should be validated. This can be null.
-
Returns:
- the result of doing the validation, it can be, but usually isn't
null.
validationStarting
public void validationStarting(IProject project,
ValidationState state,
IProgressMonitor monitor)
- This method will be called before any validation takes place. It allows validators to perform any
initialization that they might need.
-
-
-
Parameters:
-
project
- the project that is being validated. For the very first call in the validation phase,
this will be null. That is the signal to the validator that a top level validation is starting.
Subsequently, the project will be set, as each of the individual projects are validated. -
state
- a way to pass arbitrary, validator specific, data from one invocation of a validator to
the next, during the validation phase. -
monitor
- the monitor that should be used for reporting progress if the clean takes a long time.
validationFinishing
public void validationFinishing(IProject project,
ValidationState state,
IProgressMonitor monitor)
- This method will be called when validation is complete. It allows validators to perform any
cleanup that they might need to do.
-
-
-
Parameters:
-
project
- the project that was validated. The very last call in the validation will set this to
null so that the validator knows that all the projects have now been validated. -
state
- a way to pass arbitrary, validator specific, data from one invocation of a validator to
the next, during the validation phase. -
monitor
- the monitor that should be used for reporting progress if the clean takes a long time.
asIValidator
public
IValidator asIValidator()
-
-
getId
public abstract java.lang.String getId()
-
-
getMessage
public
MessageSeveritySetting getMessage(java.lang.String id)
-
-
getMessageSettings
public java.util.Map<java.lang.String,
MessageSeveritySetting> getMessageSettings()
- Answer all the message settings that this validator has defined.
-
-
-
Returns:
- an empty map if the validator did not define any message settings.
hashCodeForConfig
public int hashCodeForConfig()
- Answer a hash code for the configurable fields so that we can quickly determine if two
validators are the same.
-
-
getName
public abstract java.lang.String getName()
-
-
getProject
public IProject getProject()
- Answer the project that you were enabled on.
-
-
-
Returns:
- null if you are a global (i.e. workspace level) validator.
getValidatorClassname
public abstract java.lang.String getValidatorClassname()
- Answer the name of the class that implements the validator.
-
-
isManualValidation
public boolean isManualValidation()
- Is this validator currently enabled for validations that are triggered manually?
-
-
setManualValidation
public boolean setManualValidation(boolean manualValidation)
- Set whether this validator should be triggered as part of a manual validation.
-
-
-
Parameters:
-
manualValidation
-
-
Returns:
- true if the setting changed.
isBuildValidation
public boolean isBuildValidation()
- Is this validator currently enabled for validations that are triggered by builds?
-
-
isChanged
public boolean isChanged()
- Has the validator changed since it was last created or copied? Or was it migrated from an earlier version.
-
-
setBuildValidation
public boolean setBuildValidation(boolean buildValidation)
- Set whether this validator should be triggered by the build process.
-
-
-
Parameters:
-
buildValidation
-
-
Returns:
- true if the setting changed.
getDelegatingId
public java.lang.String getDelegatingId()
- Get the id of the "real" validator, that is the validator that will be called when this delegating
validator is asked to validate something. If this isn't a delegating validator answer null.
-
-
setDelegatingId
public void setDelegatingId(java.lang.String delegating)
- Set the id of the "real" validator, that is the validator that will be called when this delegating
validator is asked to validate something.
-
-
-
Parameters:
-
delegating
- the id of the validator that is actually going to perform the validation.
getVersion
public int getVersion()
-
-
setVersion
public void setVersion(int version)
-
-
toString
public java.lang.String toString()
-
-
Overrides:
-
toString
in class java.lang.Object
-
getSourceId
public java.lang.String getSourceId()
-
-
setSourceId
public void setSourceId(java.lang.String sourceId)
-
-
getChangeCountGlobal
public int getChangeCountGlobal()
-
-
hasGlobalChanges
public boolean hasGlobalChanges()
-
-
getChangeCountMessages
public int getChangeCountMessages()
-
-
bumpChangeCountMessages
public void bumpChangeCountMessages()
-
-
resetChangeCounters
public void resetChangeCounters()
-
-
bumpChangeCountGlobal
public void bumpChangeCountGlobal()
-
-
sameConfig
public boolean sameConfig(
Validator validator)
- Answer true if you have the same configuration settings as validator.
-
-
-
Parameters:
-
validator
- this can be null.
getMarkerId
public java.lang.String getMarkerId()
-
-
setMarkerId
public void setMarkerId(java.lang.String markerId)
-
-