/** * A builder with the default configuration * * @see JsonSchemaFactory#newBuilder() */ JsonSchemaFactoryBuilder() { reportProvider = new ListReportProvider(LogLevel.INFO, LogLevel.FATAL); loadingCfg = LoadingConfiguration.byDefault(); validationCfg = ValidationConfiguration.byDefault(); }
Main(final String fakeRoot) throws IOException { final URITranslatorConfigurationBuilder builder = URITranslatorConfiguration.newBuilder() .setNamespace(getCwd()); if (fakeRoot != null) builder.addPathRedirect(fakeRoot, getCwd()); final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() .setURITranslatorConfiguration(builder.freeze()).freeze(); factory = JsonSchemaFactory.newBuilder() .setLoadingConfiguration(cfg).freeze(); syntaxValidator = factory.getSyntaxValidator(); }
= LoadingConfiguration.newBuilder(); builder.preloadSchema(uri, node); builder.preloadSchema(uri, node); .setLoadingConfiguration(builder.freeze()).freeze();
public static void main(final String... args) throws IOException, ProcessingException { final JsonNode good = Utils.loadResource("/fstab-good.json"); final JsonNode bad = Utils.loadResource("/fstab-bad.json"); final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json"); final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() .addScheme("foobar", CustomDownloader.getInstance()).freeze(); final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder() .setLoadingConfiguration(cfg).freeze(); final JsonSchema schema = factory.getJsonSchema("foobar:/fstab.json#"); ProcessingReport report; report = schema.validate(good); System.out.println(report); report = schema.validate(bad); System.out.println(report); report = schema.validate(bad2); System.out.println(report); }
public static void main(final String... args) throws IOException, ProcessingException { final JsonNode fstabSchema = Utils.loadResource("/fstab-inline.json"); final JsonNode good = Utils.loadResource("/fstab-good.json"); final JsonNode bad = Utils.loadResource("/fstab-bad.json"); final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json"); final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() .dereferencing(Dereferencing.INLINE).freeze(); final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder() .setLoadingConfiguration(cfg).freeze(); final JsonSchema schema = factory.getJsonSchema(fstabSchema); ProcessingReport report; report = schema.validate(good); System.out.println(report); report = schema.validate(bad); System.out.println(report); report = schema.validate(bad2); System.out.println(report); } }
/** * Create a default, immutable loading configuration * * <p>This is the result of calling {@link Thawed#freeze()} on {@link * #newBuilder()}.</p> * * @return a default configuration */ public static LoadingConfiguration byDefault() { return new LoadingConfigurationBuilder().freeze(); }
public URIManager(final LoadingConfiguration cfg) { downloaders = cfg.getDownloaderMap(); reader = cfg.getReader(); }
/** * Create a new, default, mutable configuration instance * * @return a {@link LoadingConfigurationBuilder} */ public static LoadingConfigurationBuilder newBuilder() { return new LoadingConfigurationBuilder(); }
/** * Freeze this configuration * * @return a frozen copy of this builder */ @Override public LoadingConfiguration freeze() { return new LoadingConfiguration(this); }
public static void main(final String... args) throws IOException, ProcessingException { final JsonNode good = Utils.loadResource("/fstab-good.json"); final JsonNode bad = Utils.loadResource("/fstab-bad.json"); final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json"); final URITranslatorConfiguration translatorCfg = URITranslatorConfiguration.newBuilder() .addSchemaRedirect(FROM, TO).freeze(); final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() .setURITranslatorConfiguration(translatorCfg).freeze(); final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder() .setLoadingConfiguration(cfg).freeze(); final JsonSchema schema = factory.getJsonSchema(FROM); ProcessingReport report; report = schema.validate(good); System.out.println(report); report = schema.validate(bad); System.out.println(report); report = schema.validate(bad2); System.out.println(report); } }
/** * Create a default, immutable loading configuration * * <p>This is the result of calling {@link Thawed#freeze()} on {@link * #newBuilder()}.</p> * * @return a default configuration */ public static LoadingConfiguration byDefault() { return new LoadingConfigurationBuilder().freeze(); }
public URIManager(final LoadingConfiguration cfg) { downloaders = cfg.getDownloaderMap(); reader = cfg.getReader(); }
/** * Create a new schema loader with the default loading configuration */ public SchemaLoader() { this(LoadingConfiguration.byDefault()); }
/** * Return a thawed version of this loading configuration * * @return a thawed copy * @see LoadingConfigurationBuilder#LoadingConfigurationBuilder(LoadingConfiguration) */ @Override public LoadingConfigurationBuilder thaw() { return new LoadingConfigurationBuilder(this); } }
/** * Freeze this configuration * * @return a frozen copy of this builder */ @Override public LoadingConfiguration freeze() { return new LoadingConfiguration(this); }
public static void main(final String... args) throws IOException, ProcessingException { final JsonNode good = Utils.loadResource("/fstab-good.json"); final JsonNode bad = Utils.loadResource("/fstab-bad.json"); final JsonNode bad2 = Utils.loadResource("/fstab-bad2.json"); final URITranslatorConfiguration translatorCfg = URITranslatorConfiguration.newBuilder() .setNamespace(NAMESPACE).freeze(); final LoadingConfiguration cfg = LoadingConfiguration.newBuilder() .setURITranslatorConfiguration(translatorCfg).freeze(); final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder() .setLoadingConfiguration(cfg).freeze(); final JsonSchema schema = factory.getJsonSchema("fstab.json"); ProcessingReport report; report = schema.validate(good); System.out.println(report); report = schema.validate(bad); System.out.println(report); report = schema.validate(bad2); System.out.println(report); } }
/** * Create a new schema loader with the default loading configuration */ public SchemaLoader() { this(LoadingConfiguration.byDefault()); }
/** * Create a new, default, mutable configuration instance * * @return a {@link LoadingConfigurationBuilder} */ public static LoadingConfigurationBuilder newBuilder() { return new LoadingConfigurationBuilder(); }
/** * Create a new schema loader with the default loading configuration */ public SchemaLoader() { this(LoadingConfiguration.byDefault()); }
/** * Return a thawed version of this loading configuration * * @return a thawed copy * @see LoadingConfigurationBuilder#LoadingConfigurationBuilder(LoadingConfiguration) */ @Override public LoadingConfigurationBuilder thaw() { return new LoadingConfigurationBuilder(this); } }