public abstract class AbstractSyntaxChecker extends Object implements SyntaxChecker
Apart from providing a convenient base to create a syntax checker of your
own, it also provides message templates with the appropriate information and
a customized exception provider (throwing a InvalidSchemaException
instead of the base ProcessingException
.
Modifier and Type | Field and Description |
---|---|
protected String |
keyword
The keyword name
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractSyntaxChecker(String keyword,
com.github.fge.jackson.NodeType first,
com.github.fge.jackson.NodeType... other)
Main constructor
|
Modifier and Type | Method and Description |
---|---|
void |
checkSyntax(Collection<com.github.fge.jackson.jsonpointer.JsonPointer> pointers,
com.github.fge.msgsimple.bundle.MessageBundle bundle,
ProcessingReport report,
SchemaTree tree)
Main syntax checking function
|
protected abstract void |
checkValue(Collection<com.github.fge.jackson.jsonpointer.JsonPointer> pointers,
com.github.fge.msgsimple.bundle.MessageBundle bundle,
ProcessingReport report,
SchemaTree tree)
Method which all syntax checkers extending this class must implement
|
protected com.fasterxml.jackson.databind.JsonNode |
getNode(SchemaTree tree)
Convenience method to retrieve the keyword's value
|
EnumSet<com.github.fge.jackson.NodeType> |
getValidTypes() |
protected ProcessingMessage |
newMsg(SchemaTree tree,
com.github.fge.msgsimple.bundle.MessageBundle bundle,
String key)
Provide a new message for reporting purposes
|
protected final String keyword
protected AbstractSyntaxChecker(String keyword, com.github.fge.jackson.NodeType first, com.github.fge.jackson.NodeType... other)
keyword
- the keyword namefirst
- the first valid type for this keyword's valueother
- other valid types for this keyword's value (if any)public final EnumSet<com.github.fge.jackson.NodeType> getValidTypes()
getValidTypes
in interface SyntaxChecker
public final void checkSyntax(Collection<com.github.fge.jackson.jsonpointer.JsonPointer> pointers, com.github.fge.msgsimple.bundle.MessageBundle bundle, ProcessingReport report, SchemaTree tree) throws ProcessingException
This method only checks that the keyword's type is of the correct
type, and reports an error if it isn't; if it is, it handles the rest
of syntax checking to checkValue(Collection, MessageBundle,
ProcessingReport, SchemaTree)
.
checkSyntax
in interface SyntaxChecker
pointers
- the list of JSON Pointers to fill (see description)bundle
- the message bundle to usereport
- the processing report to usetree
- the schemaInvalidSchemaException
- keyword is invalidProcessingException
- an error is detected, and the report is
configured to throw an exception on error.protected abstract void checkValue(Collection<com.github.fge.jackson.jsonpointer.JsonPointer> pointers, com.github.fge.msgsimple.bundle.MessageBundle bundle, ProcessingReport report, SchemaTree tree) throws ProcessingException
At this point, it is known that the keyword's value has at least the correct type.
pointers
- the list of JSON Pointers to fill (see description)bundle
- the message bundle to usereport
- the processing report to usetree
- the schemaInvalidSchemaException
- keyword is invalidProcessingException
protected final ProcessingMessage newMsg(SchemaTree tree, com.github.fge.msgsimple.bundle.MessageBundle bundle, String key)
tree
- the schema treebundle
- the message bundle to usekey
- the messageProcessingMessage
ProcessingMessage.setMessage(String)
protected final com.fasterxml.jackson.databind.JsonNode getNode(SchemaTree tree)
tree
- the tree to extract the keyword's value fromCopyright © 2016. All rights reserved.