com.google.gdata.model
Class ValidationContext
java.lang.Object
com.google.gdata.model.ValidationContext
public class ValidationContext
- extends java.lang.Object
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.
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ValidationContext
public ValidationContext()
getErrors
public java.util.Map<Element,java.util.List<ErrorContent>> getErrors()
- Returns:
- map of validation errors
addError
public void addError(Element element,
java.lang.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.
addError
public void addError(Element element,
ErrorContent error)
- Add a validation error to list.
- Parameters:
element
- element that was found to be invaliderror
- error message
isValid
public boolean isValid()
- Returns:
- true if instance data is valid
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object