public abstract class FormatSpecifier extends Object
The format keyword always takes a string as an argument, and this
string is called a "specifier". The draft defines specifiers for recognizing
URIs, phone numbers, different date formats, and so on -- and even CSS 2.1
colors and styles (not supported).
One important thing to remember is that a specifier will only validate a
given subset of JSON instance types (for instance, uri only validates
string instances). In the event that the instane type is not of the
validated types, validation succeeds.
The spec allows for custom specifiers to be added. This implementation, however, does not support it.
| Modifier and Type | Field and Description |
|---|---|
private EnumSet<NodeType> |
typeSet
JSON instance types which this specifier can validate
|
| Modifier | Constructor and Description |
|---|---|
protected |
FormatSpecifier(NodeType first,
NodeType... other)
Protected constructor
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
checkValue(String fmt,
ValidationContext ctx,
ValidationReport report,
JsonNode value)
Abstract method implemented by all specifiers
|
protected static ValidationMessage.Builder |
newMsg(String fmt) |
void |
validate(String fmt,
ValidationContext ctx,
ValidationReport report,
JsonNode value)
Main validation function
|
protected FormatSpecifier(NodeType first, NodeType... other)
Its arguments are the node types recognized by the specifier. Only
one specifier recognizes more than one type: utc-millisec (it
can validate both numbers and integers).
first - first typeother - other types, if anypublic final void validate(String fmt, ValidationContext ctx, ValidationReport report, JsonNode value)
This function only checks whether the value is of a type recognized
by this specifier. If so, it calls checkValue(String,
ValidationContext, ValidationReport, JsonNode).
The message template passed as an argument will have been pre-filled
with the keyword (format, the specifier name and the domain
(ValidationDomain.VALIDATION).
fmt - the format specifier namectx - the validation contextreport - the validation reportvalue - the value to validatepublic abstract void checkValue(String fmt, ValidationContext ctx, ValidationReport report, JsonNode value)
It is only called if the value type is one expected by the
specifier, see validate(String, ValidationContext,
ValidationReport, JsonNode).
fmt - the format specifier namectx - the validation contextreport - the validation reportvalue - the value to validateprotected static ValidationMessage.Builder newMsg(String fmt)
Copyright © 2012. All Rights Reserved.