## org.eclipse.wst.validation
Class ValidationResult

    java.lang.Object
      org.eclipse.wst.validation.ValidationResult

    public final class ValidationResult

extends java.lang.Object

The result of running a validate operation. Validators create and return this objects as part of performing their validation.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Constructor Summary
`ValidationResult()`

Method Summary
`void` `add(ValidatorMessage message)` This is an optional method, that a validator can use to return error messages.
`IResource[]` `getDependsOn()` Answer the resources that the validated resource depends on.
`ValidatorMessage[]` `getMessages()` Answer any validation messages that were added by the validator.
`ValidatorMessage[]` `getMessagesAsCopy()` Answer a copy of any validation messages that were added by the validator.
`int` `getNumberOfValidatedResources()` Answer the number of resources that have been validated.
`IReporter` `getReporter(IProgressMonitor monitor)` Answer an IReporter for handing error messages.
`int` `getSeverityError()` Answer the number of error messages that were generated as part of this validation operation.
`int` `getSeverityInfo()` Answer the number of informational messages that were generated as part of this validation operation.
`int` `getSeverityWarning()` Answer the number of warning messages that were generated as part of this validation operation.
`IProject` `getSuspendValidation()` Answer the project that the validator would like to have suspended.
`IResource[]` `getValidated()`
`org.eclipse.wst.validation.internal.core.ValidationException` `getValidationException()` If the validation ended with an exception, answer it.
`int` `incrementError(int errors)` Increment the number of error messages that were generated as part of this validation operation.
`int` `incrementInfo(int info)` Increment the number of informational messages that were generated as part of this validation operation.
`int` `incrementWarning(int warnings)` Increment the number of warning messages that were generated as part of this validation operation.
`boolean` `isCanceled()` Was the operation canceled before it completed?
`void` `mergeResults(ValidationResult result)` Merge the message counts and messages from an individual validator into this result.
`void` `setCanceled(boolean canceled)` Indicate if the operation was canceled.
`void` `setDependsOn(IResource[] dependsOn)` Update the resources that the validated resource depends on.
`void` `setSeverityError(int severityError)` Set the number of error messages that were generated as part of this validation operation.
`void` `setSeverityInfo(int severityInfo)` Set the number of informational messages that were generated as part of this validation operation.
`void` `setSeverityWarning(int severityWarning)` Set the number of warning messages that were generated as part of this validation operation.
`void` `setSuspendValidation(IProject project)` Calling this method will inform the framework, that this validator does not wish to be called again for any resources in this project, for the duration of this validation operation.
`void` `setValidated(IResource[] validated)` Indicate that additional resources have been validated as part of this validate operation.
`void` `setValidationException(org.eclipse.wst.validation.internal.core.ValidationException validationException)` If the validation failed with an exception, it can be recorded here.

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

Constructor Detail

### ValidationResult

    public ValidationResult()

Method Detail

### add

    public void add(ValidatorMessage message)

  This is an optional method, that a validator can use to return error messages. The validation framework converts these into IMarkers.

  The scenario that motivated this method, is when a validator is used both for as you type validation and build validation. When called in as you type mode, the validator doesn't want to directly create IMarkers, because the resource hasn't been saved yet. It needs to return something other than an IMarker. But when called in build mode, it does ultimately want IMarkers. By returning ValidatorMessages, it only needs to return one type of message, and those messages can be either be directly used by the caller, or automatically converted into IMarkers by the validation framework.

  To make matters even more complicated there is a third way to return messages. To make it easier for old validators to port to the new framework, they can continue to use an IReporter. If a validator calls the getReporter() method then it is assumed by the framework that that is the approach that they have chosen.

  Parameters:
    `message` - A validation message.
  See Also:
    `getReporter(IProgressMonitor)`

### getReporter

    public IReporter getReporter(IProgressMonitor monitor)

  Answer an IReporter for handing error messages.

  This is a transition method, to help old validators port to the new validation framework. If this method is called it is assumed by the framework, that this IReporter will be used as the only way of passing messages back to the framework.

  Parameters:
    `monitor` -
  See Also:
    `add(ValidatorMessage)`

### mergeResults

    public void mergeResults(ValidationResult result)

  Merge the message counts and messages from an individual validator into this result.

  Parameters:
    `result` - it can be null, in which case it is ignored.

### getDependsOn

    public IResource[] getDependsOn()

  Answer the resources that the validated resource depends on.

### getMessages

    public ValidatorMessage[] getMessages()

  Answer any validation messages that were added by the validator.

  Returns:
    an array is returned even if there are no messages.

### getMessagesAsCopy

    public ValidatorMessage[] getMessagesAsCopy()

  Answer a copy of any validation messages that were added by the validator. The array is a new array, and each message is a copy.

  Returns:
    an array is returned even if there are no messages.

### setDependsOn

    public void setDependsOn(IResource[] dependsOn)

  Update the resources that the validated resource depends on. This can be left null. For example, a XML file may depend on a XSD file in order to know if it is valid or not. It would pass back that XSD file.

  Parameters:
    `dependsOn` - If this is null then the dependency information is not updated. To remove the dependency information, an empty array needs to be supplied. A non null parameter, replaces all the dependency information for this resource, for this validator.

### getValidated

    public IResource[] getValidated()

  Returns:
    All the resources that were validated as a side-effect of validating the main resource, or null if none were.

### setValidated

    public void setValidated(IResource[] validated)

  Indicate that additional resources have been validated as part of this validate operation. Sometimes in the course of performing a validation on one resource it is necessary to validate other resources as well. This method is used to let the framework know about these additional validated resources, to possibly save them being validated redundantly.

  Parameters:
    `validated` - Any additional resources that were validated.

### getSeverityError

    public int getSeverityError()

  Answer the number of error messages that were generated as part of this validation operation.

### setSeverityError

    public void setSeverityError(int severityError)

  Set the number of error messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

### incrementError

    public int incrementError(int errors)

  Increment the number of error messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

  Returns:
    the current number of errors.

### getSeverityWarning

    public int getSeverityWarning()

  Answer the number of warning messages that were generated as part of this validation operation.

### setSeverityWarning

    public void setSeverityWarning(int severityWarning)

  Set the number of warning messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

### incrementWarning

    public int incrementWarning(int warnings)

  Increment the number of warning messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

  Returns:
    the current number of warnings.

### getSeverityInfo

    public int getSeverityInfo()

  Answer the number of informational messages that were generated as part of this validation operation.

### setSeverityInfo

    public void setSeverityInfo(int severityInfo)

  Set the number of informational messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

### incrementInfo

    public int incrementInfo(int info)

  Increment the number of informational messages that were generated as part of this validation operation.

  Messages added through the add(ValidationMessage) method should not be included here, as this information will be determined from the ValidationMessage.

  Returns:
    the current number of informational message.

### isCanceled

    public boolean isCanceled()

  Was the operation canceled before it completed? For example if the validation is being run through the user interface, the end user can cancel the operation through the progress monitor.

  Returns:
    true if the operation was canceled

### setCanceled

    public void setCanceled(boolean canceled)

  Indicate if the operation was canceled.

  Parameters:
    `canceled` - Set to true if it was canceled and false if it was not canceled.

### getNumberOfValidatedResources

    public int getNumberOfValidatedResources()

  Answer the number of resources that have been validated.

### getValidationException

    public org.eclipse.wst.validation.internal.core.ValidationException getValidationException()

  If the validation ended with an exception, answer it.

  Returns:
    null if the validator did not finish with an exception.

### setValidationException

    public void setValidationException(org.eclipse.wst.validation.internal.core.ValidationException validationException)

  If the validation failed with an exception, it can be recorded here.

  This method is provided for old validators to ease their transition to the new framework.

  Parameters:
    `validationException` -

### getSuspendValidation

    public IProject getSuspendValidation()

  Answer the project that the validator would like to have suspended.

  Returns:
    the project to suspend or null. The normal result is null, which means that the validator wishes to receive normal validation requests.

### setSuspendValidation

    public void setSuspendValidation(IProject project)

  Calling this method will inform the framework, that this validator does not wish to be called again for any resources in this project, for the duration of this validation operation.

  Some validators may have a rich set of triggers, but once they have been invoked once, do not need to be invoked again during the course of the current validation.

  Parameters:
    `project` - The project that this validator no longer wants to be notified on.