Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright (c) 2014, Francis Galiegue (
   * This software is dual-licensed under:
   * - the Lesser General Public License (LGPL) version 3.0 or, at your option, any
   *   later version;
   * - the Apache Software License (ASL) version 2.0.
  * The text of this file and of both licenses is available at the root of this
  * project or, if you have the jar distribution, in directory META-INF/, under
  * the names LGPL-3.0.txt and ASL-2.0.txt respectively.
  * Direct link to the sources:
  * - LGPL 3.0:
  * - ASL 2.0:
 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<SchemaContextValidatorListbuilder;
     public ValidationChain(final RefResolver refResolver,
         final Library libraryfinal ValidationConfiguration cfg)
         final SyntaxProcessor syntaxProcessor = new SyntaxProcessor(
             cfg.getSyntaxMessages(), library.getSyntaxCheckers());
             = ProcessorChain.startWith(refResolver).chainWith(syntaxProcessor);
             chain1.getProcessor(), .
         final SchemaDigester digester = new SchemaDigester(library);
         final ValidatorBuilder keywordBuilder = new ValidatorBuilder(library);
             = ProcessorChain.startWith(digester).chainWith(keywordBuilder);
         if (cfg.getUseFormat()) {
             final FormatProcessor format
                 = new FormatProcessor(librarycfg);
             chain2 = chain2.chainWith(format);
          = new CachingProcessor<SchemaContextValidatorList>(
             chain2.getProcessor(), SchemaContextEquivalence.getInstance()
     public ValidatorList process(final ProcessingReport report,
         final SchemaContext input)
         throws ProcessingException
         final ValueHolder<SchemaTreein
             = ValueHolder.hold("schema"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 ProcessingReport r = new ListProcessingReport(report);
        final ValueHolder<SchemaTreeout = .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<ValueHolder<SchemaTree>>
        private static final Equivalence<ValueHolder<SchemaTree>> INSTANCE
            = new SchemaHolderEquivalence();
        private static final Equivalence<SchemaTreeEQUIVALENCE
            = SchemaTreeEquivalence.getInstance();
        protected boolean doEquivalent(final ValueHolder<SchemaTreea,
            final ValueHolder<SchemaTreeb)
            return .equivalent(a.getValue(), b.getValue());
        protected int doHash(final ValueHolder<SchemaTreet)
            return .hash(t.getValue());
New to GrepCode? Check out our FAQ X