Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright (c) 2013, Francis Galiegue <>
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the Lesser GNU General Public License as
   * published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Lesser GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <>.
 package com.github.fge.jsonschema.processors.validation;
A validation chain

This processor performs the following:

  • perform reference lookup then syntax validation;
  • throw an exception if the previous step fails;
  • then perform schema digesting and keyword building.

A validation chain handles one schema version. Switching schema versions is done by ValidationProcessor.

 public final class ValidationChain
     implements Processor<SchemaContextValidatorList>
     private final Processor<SchemaHolderSchemaHolderresolver;
     private final Processor<SchemaContextValidatorListbuilder;
     public ValidationChain(final RefResolver refResolver,
         final Library libraryfinal boolean useFormat)
         final SyntaxProcessor syntaxProcessor
             = new SyntaxProcessor(library.getSyntaxCheckers());
         final ProcessorChain<SchemaHolderSchemaHolderchain1
             = ProcessorChain.startWith(refResolver).chainWith(syntaxProcessor);
          = new CachingProcessor<SchemaHolderSchemaHolder>(
             chain1.getProcessor(), .
         final SchemaDigester digester = new SchemaDigester(library);
         final ValidatorBuilder keywordBuilder = new ValidatorBuilder(library);
             = ProcessorChain.startWith(digester).chainWith(keywordBuilder);
         if (useFormat) {
             final FormatProcessor format = new FormatProcessor(library);
             chain2 = chain2.chainWith(format);
          = new CachingProcessor<SchemaContextValidatorList>(
             chain2.getProcessor(), SchemaContextEquivalence.getInstance()
     public ValidatorList process(final ProcessingReport report,
         final SchemaContext input)
         throws ProcessingException
         final SchemaHolder in = new SchemaHolder(input.getSchema());
          * We have to go through an intermediate report. If we re-enter this
          * function with a report already telling there is an error, we don't
          * want to wrongly report that the schema is invalid.
         final ListProcessingReport r = new ListProcessingReport(report);
         final SchemaHolder out = .process(rin);
        if (!r.isSuccess())
            return null;
        final SchemaContext output = new SchemaContext(out.getValue(),
        return .process(reportoutput);
    public String toString()
        return  + " -> " + ;
    private static final class SchemaHolderEquivalence
        extends Equivalence<SchemaHolder>
        private static final Equivalence<SchemaHolderINSTANCE
            = new SchemaHolderEquivalence();
        private static final Equivalence<SchemaTreeEQUIVALENCE
            = SchemaTreeEquivalence.getInstance();
        protected boolean doEquivalent(final SchemaHolder a,
            final SchemaHolder b)
            return .equivalent(a.getValue(), b.getValue());
        protected int doHash(final SchemaHolder t)
            return .hash(t.getValue());
New to GrepCode? Check out our FAQ X