Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2012, Francis Galiegue <fgaliegue@gmail.com>
   *
   * 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
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * 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 <http://www.gnu.org/licenses/>.
  */
 
 package com.github.fge.jsonschema.metaschema;
 
 
 import java.util.Map;
 
 import static com.github.fge.jsonschema.util.NodeType.*;

Utility class for builtin syntax checkers

As for other similar classes, it provides methods to retrieve checkers defined by draft v3 and draft v4.

 
 
 // TODO: make package private in next version
 public final class SyntaxCheckers
 {
     private static final Map<StringSyntaxCheckerDRAFTV3_CORE;
     private static final Map<StringSyntaxCheckerDRAFTV3_HYPERSCHEMA;
     private static final Map<StringSyntaxCheckerDRAFTV4_CORE;
 
     // No making new instances of this class
     private SyntaxCheckers()
     {
     }
 
     static {
         ImmutableMap.Builder<StringSyntaxCheckerbuilder;
 
         String keyword;
         SyntaxChecker checker;
 
         /*
          * Common syntax checkers
          */
         builder = ImmutableMap.builder();
 
         // Arrays
         keyword = "additionalItems";
         checker = new AdditionalSyntaxChecker(keyword);
         builder.put(keywordchecker);
 
         keyword = "minItems";
         checker = new PositiveIntegerSyntaxChecker(keyword);
         builder.put(keywordchecker);
 
         keyword = "maxItems";
         checker = new PositiveIntegerSyntaxChecker(keyword);
         builder.put(keywordchecker);
 
         keyword = "uniqueItems";
         checker = new TypeOnlySyntaxChecker(keyword);
         builder.put(keywordchecker);
 
         // Integer/number
        keyword = "minimum";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "exclusiveMinimum";
        checker = ExclusiveMinimumSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "maximum";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "exclusiveMaximum";
        checker = ExclusiveMaximumSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // Object
        keyword = "additionalProperties";
        checker = new AdditionalSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "patternProperties";
        checker = PatternPropertiesSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // String
        keyword = "minLength";
        checker = new PositiveIntegerSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "maxLength";
        checker = new PositiveIntegerSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "pattern";
        checker = PatternSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // All/none
        keyword = "$schema";
        checker = new URISyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "$ref";
        checker = new URISyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "id";
        checker = new URISyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "description";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "title";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "enum";
        checker = EnumSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "format";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        // Build the map
        final Map<StringSyntaxCheckercommonbuilder.build();
        /*
         * Draft v3
         */
        builder = ImmutableMap.builder();
        // Start by injecting syntax checkers common to all drafts
        builder.putAll(common);
        // Now, inject draft v3 specific syntax checkers
        // Array
        keyword = "items";
        checker = new SchemaOrSchemaArraySyntaxChecker(keywordtrue);
        builder.put(keywordchecker);
        // Integer/number
        keyword = "divisibleBy";
        checker = new DivisorSyntaxChecker(keyword);
        builder.put(keywordchecker);
        // Object
        keyword = "properties";
        checker = DraftV3PropertiesSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "dependencies";
        checker = DraftV3DependenciesSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // All/none
        keyword = "extends";
        checker = new SchemaOrSchemaArraySyntaxChecker(keywordtrue);
        builder.put(keywordchecker);
        keyword = "type";
        checker = new DraftV3TypeKeywordSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "disallow";
        checker = new DraftV3TypeKeywordSyntaxChecker(keyword);
        builder.put(keywordchecker);
        // Build the map
         = builder.build();
        /*
         * Draft v3 hyper schema
         */
        builder = ImmutableMap.builder();
        // Inject all of draft v3 core keywords
        builder.putAll();
        // Inject hyper schema specific keywords
        keyword = "fragmentResolution";
        checker = FragmentResolutionSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "readonly";
        checker = new TypeOnlySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "contentEncoding";
        checker = ContentEncodingSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "pathStart";
        checker = new URISyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "mediaType";
        checker = MediaTypeSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "links";
        checker = LinksSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // Build the map
         = builder.build();
        /*
         * Draft v4
         */
        builder = ImmutableMap.builder();
        // Start by injecting syntax checkers common to all drafts
        builder.putAll(common);
        // Now, inject draft v4 specific syntax checkers
        // Array
        keyword = "items";
        checker = new SchemaOrSchemaArraySyntaxChecker(keywordfalse);
        builder.put(keywordchecker);
        // Integer/number
        keyword = "multipleOf";
        checker = new DivisorSyntaxChecker(keyword);
        builder.put(keywordchecker);
        // Object
        keyword = "minProperties";
        checker = new PositiveIntegerSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "maxProperties";
        checker = new PositiveIntegerSyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "properties";
        checker = DraftV4PropertiesSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "required";
        checker = RequiredSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "dependencies";
        checker = DraftV4DependenciesSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // All/none
        keyword = "anyOf";
        checker = new SchemaArraySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "allOf";
        checker = new SchemaArraySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "oneOf";
        checker = new SchemaArraySyntaxChecker(keyword);
        builder.put(keywordchecker);
        keyword = "not";
        checker = NotSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "type";
        checker = DraftV4TypeSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        keyword = "definitions";
        checker = DefinitionsSyntaxChecker.getInstance();
        builder.put(keywordchecker);
        // Build the map
         = builder.build();
    }

    
Return an immutable map of syntax checkers for draft v3

Returns:
a map pairing keyword names and their syntax checkers
    static Map<StringSyntaxCheckerdraftV3Core()
    {
        return ;
    }

    
Return an immutable map of syntax checkers for draft v3 hyper-schema

Returns:
a map pairing keyword names and their syntax checkers
    {
        return ;
    }
    
Return an immutable map of syntax checkers for draft v4

Returns:
a map pairing keyword names and their syntax checkers
    static Map<StringSyntaxCheckerdraftV4Core()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X