public class

ValidationContext

extends Object
java.lang.Object
   ↳ com.google.gdata.model.ValidationContext

Class Overview

Data structure used to accumulate data model validation errors.

would be used as follows:

   public interface Validatable {
     public static class ValidationContext { ... }
     public boolean validate(ValidationContext vc);
   }

   public class Element implements Validatable { ... }
 
Then we could eventually reuse the context class and the accumulation model in other places (attribute validation? metadata validation?). In that case, we might want to make the 1st arg of addError more generic (like 'Object relatedTo') or something.

Summary

Fields
private Map<Element, List<ErrorContent>> errors Collection of validation error messages associated with elements.
Public Constructors
ValidationContext()
Public Methods
void addError(Element element, String error)
Add an error by error string.
void addError(Element element, ErrorContent error)
Add a validation error to list.
Map<Element, List<ErrorContent>> getErrors()
boolean isValid()
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private Map<Element, List<ErrorContent>> errors

Collection of validation error messages associated with elements.

Public Constructors

public ValidationContext ()

Public Methods

public void addError (Element element, String error)

Add an error by error string. This will register an error in the core gdata domain with an error code of "invalidElement" and the internal reason set to the given error string. For a more useful error message, addError(Element, ErrorContent) should be used instead.

Parameters
element
error

public void addError (Element element, ErrorContent error)

Add a validation error to list.

Parameters
element Element that was found to be invalid
error Error message

public Map<Element, List<ErrorContent>> getErrors ()

Returns
  • map of validation errors

public boolean isValid ()

Returns
  • true if instance data is valid

public String toString ()