com.github.fge.jsonschema.keyword.validator.helpers
Class NumericValidator

java.lang.Object
  extended by com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator
      extended by com.github.fge.jsonschema.keyword.validator.helpers.NumericValidator
All Implemented Interfaces:
KeywordValidator
Direct Known Subclasses:
DivisorValidator, MaximumValidator, MinimumValidator

public abstract class NumericValidator
extends AbstractKeywordValidator

Helper class for keywords validating numeric values

This class' role is to switch between two different validation methods: validateLong(ProcessingReport, MessageBundle, FullData) if both the keyword value and instance fit exactly into a long (for performance reasons), validateDecimal(ProcessingReport, MessageBundle, FullData) otherwise (for accuracy reasons).


Field Summary
protected  JsonNode number
          The keyword value
 
Fields inherited from class com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator
keyword
 
Constructor Summary
protected NumericValidator(String keyword, JsonNode digest)
           
 
Method Summary
 String toString()
           
 void validate(Processor<FullData,FullData> processor, ProcessingReport report, MessageBundle bundle, FullData data)
          Validate the instance
protected abstract  void validateDecimal(ProcessingReport report, MessageBundle bundle, FullData data)
          Method to be implemented by a numeric validator if either of the keyword value or instance value do not fit into a long
protected abstract  void validateLong(ProcessingReport report, MessageBundle bundle, FullData data)
          Method to be implemented by a numeric validator if both the keyword value and instance value fit into a long
 
Methods inherited from class com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator
newMsg, newMsg, toArrayNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

number

protected final JsonNode number
The keyword value

Constructor Detail

NumericValidator

protected NumericValidator(String keyword,
                           JsonNode digest)
Method Detail

validate

public final void validate(Processor<FullData,FullData> processor,
                           ProcessingReport report,
                           MessageBundle bundle,
                           FullData data)
                    throws ProcessingException
Description copied from interface: KeywordValidator
Validate the instance

Parameters:
processor - the main validation processor
report - the report to use
bundle - the message bundle to use
data - the validation data
Throws:
InvalidInstanceException - instance is invalid, and the report has been configured to throw an exception instead of logging errors
ProcessingException

validateLong

protected abstract void validateLong(ProcessingReport report,
                                     MessageBundle bundle,
                                     FullData data)
                              throws ProcessingException
Method to be implemented by a numeric validator if both the keyword value and instance value fit into a long

Parameters:
report - the validation report
bundle - the message bundle to use
data - the validation data
Throws:
ProcessingException

validateDecimal

protected abstract void validateDecimal(ProcessingReport report,
                                        MessageBundle bundle,
                                        FullData data)
                                 throws ProcessingException
Method to be implemented by a numeric validator if either of the keyword value or instance value do not fit into a long

Parameters:
report - the validation report
bundle - the message bundle to use
data - the validation data
Throws:
ProcessingException

toString

public final String toString()
Specified by:
toString in class AbstractKeywordValidator