diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..4ace52b34
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+version: 2
+updates:
+ - package-ecosystem: "gradle"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ time: "02:00"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ time: "02:00"
diff --git a/.gitignore b/.gitignore
index 7c16d713f..ec357e3f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ target
build
.gradle
out
+/.nb-gradle/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..87d176072
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: java
+jdk:
+ - openjdk8
+ - openjdk11
+install: {}
+script:
+ - ./gradlew assemble check
+
+before_cache:
+ - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
+ - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
+
+cache:
+ directories:
+ - $HOME/.gradle/caches/
+ - $HOME/.gradle/wrapper/
+
diff --git a/LICENSE b/LICENSE
index 16cda1283..37e25e033 100644
--- a/LICENSE
+++ b/LICENSE
@@ -6,6 +6,7 @@ This software is dual-licensed under:
The text of both licenses is included (under the names LGPL-3.0.txt and
ASL-2.0.txt respectively).
+Should you choose to redistribute, you can pick either, or continue to dual license.
Direct link to the sources:
diff --git a/README.md b/README.md
index f2e5e6ae6..b02eaffc7 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,16 @@
+[![License LGPLv3][LGPLv3 badge]][LGPLv3]
+[![License ASL 2.0][ASL 2.0 badge]][ASL 2.0]
+[![Build Status][Travis badge]][Travis]
+
+
## Read me first
-The **current** version of this project is licensed under both LGPLv3 (or later) and ASL 2.0. The old version
-(2.0.x) was licensed under LGPL 3.0 (or later) only.
+The **current** version of this project is licensed under both [LGPLv3] (or later) and [ASL 2.0]. The old version
+(2.0.x) was licensed under [LGPL 3.0][LGPLv3] (or later) only.
-**Version 2.2 is out**. See [here](https://github.com/fge/json-schema-validator/wiki/Whatsnew_22)
+**Version 2.2 is out**. See [here](https://github.com/java-json-tools/json-schema-validator/wiki/Whatsnew_22)
for the list of changes compared to 2.0. And of course, it still has [all the
-features](https://github.com/fge/json-schema-validator/wiki/Features) of older versions.
+features](https://github.com/java-json-tools/json-schema-validator/wiki/Features) of older versions.
## What this is
@@ -33,14 +38,14 @@ run by yourself.
## Versions
-* current stable version: **2.2.5**
- ([ChangeLog](https://github.com/fge/json-schema-validator/wiki/ChangeLog_22x),
- [Javadoc](http://fge.github.io/json-schema-validator/2.2.x/index.html), [code
- samples](http://fge.github.io/json-schema-validator/2.2.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
+* current stable version: **2.2.14**
+ ([ChangeLog](https://github.com/java-json-tools/json-schema-validator/wiki/ChangeLog_22x),
+ [Javadoc](http://java-json-tools.github.io/json-schema-validator/2.2.x/index.html), [code
+ samples](http://java-json-tools.github.io/json-schema-validator/2.2.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
* old stable version: **2.0.4**
- ([ChangeLog](https://github.com/fge/json-schema-validator/wiki/ChangeLog_20x),
- [Javadoc](http://fge.github.io/json-schema-validator/2.0.x/index.html), [code
- samples](http://fge.github.io/json-schema-validator/2.0.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
+ ([ChangeLog](https://github.com/java-json-tools/json-schema-validator/wiki/ChangeLog_20x),
+ [Javadoc](http://java-json-tools.github.io/json-schema-validator/2.0.x/index.html), [code
+ samples](http://java-json-tools.github.io/json-schema-validator/2.0.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
## Available downloads
@@ -52,7 +57,7 @@ Gradle:
```groovy
dependencies {
- compile(group: "com.github.fge", name: "json-schema-validator", version: "yourVersionHere");
+ compile(group: "com.github.java-json-tools", name: "json-schema-validator", version: "2.2.14");
}
```
@@ -60,13 +65,14 @@ Maven:
```xml
- com.github.fge
+ com.github.java-json-tools
json-schema-validator
- your-version-here
+ 2.2.14
```
### "Full" jar; command line
+OUTDATED: Let me know if you need this in the issues section.
This jar contains the library plus all its dependencies. Download the **lib** jar (a little more
than 6 MiB) from [Bintray](https://bintray.com/fge/maven/json-schema-validator/view).
@@ -94,8 +100,14 @@ This implementation is based on the following drafts:
## More...
For a detailed discussion of the implementation, see
-[here](https://github.com/fge/json-schema-validator/wiki/Status).
+[here](https://github.com/java-json-tools/json-schema-validator/wiki/Status).
-Please see the [wiki](https://github.com/fge/json-schema-validator/wiki/) for more
+Please see the [wiki](https://github.com/java-json-tools/json-schema-validator/wiki/) for more
details.
+[LGPLv3 badge]: https://img.shields.io/:license-LGPLv3-blue.svg
+[LGPLv3]: http://www.gnu.org/licenses/lgpl-3.0.html
+[ASL 2.0 badge]: https://img.shields.io/:license-Apache%202.0-blue.svg
+[ASL 2.0]: http://www.apache.org/licenses/LICENSE-2.0.html
+[Travis Badge]: https://travis-ci.com/java-json-tools/json-schema-validator.svg?branch=master
+[Travis]: https://travis-ci.com/java-json-tools/json-schema-validator
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 33328c35c..77cd86dd9 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -1 +1,64 @@
-### RESET
+### 2.2.11
+
+* Depend on -core 1.2.10.
+* Update dependencies on jsr305.
+* Fix javadoc generation.
+* Fix issue #293: Lazily instantiate defaults for `JsonSchemaFactoryBuilder`.
+
+### 2.2.10
+
+* Revert strict date-time validation from 2.2.9; now such validation is opt-in.
+
+### 2.2.9
+
+* Use stricter date-time attribute formatter.
+* Added a cache size for # of records in ValidationConfiguration.
+
+### 2.2.8
+
+* update important dependencies like libphonenumber and others. See #210 and #209
+
+### 2.2.7
+
+* First time publishing under com.github.java-json-tools.
+* The secFracs field will support up to 12 chars
+* Switch KeywordValidators to use a factory model
+* Changed JsonSchema to an interface
+
+### 2.2.6
+
+* Fix issue #112: fix circular validation detection; use a "validation stack" to
+ detect and spot those situations.
+* Depend on -core 1.2.5.
+* Update dependencies for libphonenumber, jsr305.
+
+### 2.2.5
+
+* Fix issue #102: detect, and fail on, circular validation.
+* Simplify ValidationProcessor.
+* Remove one-jar generation; the -lib jar now includes Main-Class.
+
+### 2.2.4
+
+* Add a "lib" target to the build.
+* Issue #99: append syntax errors when throwing an InvalidSchemaException.
+* Issue #100: attempt to load resources from the context classloader if loading
+ from JsonLoader.class fails.
+
+### 2.2.3
+
+* Re-release... 2.2.2 was compiled with JDK 8 :/
+
+### 2.2.2
+
+* Depend on -core 1.2.1 to work around Rhino bug with other packages sealing the
+ context.
+
+### 2.2.1
+
+* Main now uses current working directory as default URI namespace.
+
+### 2.2.0
+
+* New major release.
+
diff --git a/build.gradle b/build.gradle
index fbc13551a..0345fa456 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,82 +17,63 @@
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
*/
-/*
- * This has to be here... It will not be taken into account in common.gradle!
- *
- * Looks like a serious bug... See also:
- *
- * http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored
- */
-/*
- * This has to be here... It will not be taken into account in common.gradle!
- *
- * Looks like a serious bug... See also:
- *
- * http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored
- *
- * We also use Spring's propdeps plugin to have a _real_ provided scope. See:
- *
- * https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin
- */
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0'
+ }
+}
+
+plugins {
+ id("net.ltgt.errorprone") version "0.8.1" apply false
+}
apply(plugin: "java");
apply(plugin: "maven");
apply(plugin: "signing");
-apply(plugin: "osgi");
+apply(plugin: "biz.aQute.bnd.builder");
apply(plugin: "idea");
apply(plugin: "eclipse");
+apply(plugin: "net.ltgt.errorprone");
-group = "com.github.fge";
-version = "2.2.5-SNAPSHOT";
-sourceCompatibility = "1.6";
-targetCompatibility = "1.6"; // defaults to sourceCompatibility
+apply(from: "project.gradle");
-project.ext {
- description = "A Java implementation of the JSON Schema specification";
-};
+group = "com.github.java-json-tools";
+
+ext.forRelease = !version.endsWith("-SNAPSHOT");
/*
* Repositories to use
*/
repositories {
mavenCentral();
+ if (!forRelease) {
+ maven {
+ url "https://oss.sonatype.org/content/repositories/snapshots"
+ }
+ }
+ /* Allow staging references for last pre-release testing. */
+ if (project.properties.containsKey("sonatypeUsername")) {
+ maven {
+ url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
+ credentials {
+ username = project.properties["sonatypeUsername"]
+ password = project.properties["sonatypePassword"]
+ }
+ }
+ }
}
/*
- * List of dependencies
+ * Add errorprone checking.
*/
dependencies {
- compile(group: "com.github.fge", name: "json-schema-core",
- version: "1.2.4");
- compile(group: "javax.mail", name: "mailapi", version: "1.4.3");
- compile(group: "joda-time", name: "joda-time", version: "2.3");
- compile(group: "com.googlecode.libphonenumber", name: "libphonenumber",
- version: "6.2");
- compile(group: "com.google.code.findbugs", name: "jsr305",
- version: "3.0.0");
- compile(group: "net.sf.jopt-simple", name: "jopt-simple", version: "4.6");
- testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
- exclude(group: "junit", module: "junit");
- exclude(group: "org.beanshell", module: "bsh");
- exclude(group: "org.yaml", module: "snakeyaml");
- };
- testCompile(group: "org.mockito", name: "mockito-core", version: "1.9.5");
- testCompile(group: "org.easytesting", name: "fest-assert", version: "1.4");
+ errorprone("com.google.errorprone:error_prone_core:2.3.3")
+ errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
-javadoc.options.links("http://docs.oracle.com/javase/6/docs/api/");
-javadoc.options.links("http://jsr-305.googlecode.com/svn/trunk/javadoc/");
-javadoc.options.links("http://fasterxml.github.com/jackson-databind/javadoc/2.2.0/");
-javadoc.options.links("http://fasterxml.github.com/jackson-core/javadoc/2.2.0/");
-javadoc.options.links("http://docs.guava-libraries.googlecode.com/git-history/v16.0.1/javadoc/");
-javadoc.options.links("http://fge.github.io/btf/");
-javadoc.options.links("http://fge.github.io/msg-simple/");
-javadoc.options.links("http://fge.github.io/jackson-coreutils/");
-javadoc.options.links("http://fge.github.io/uri-template/");
-javadoc.options.links("http://fge.github.io/json-schema-core/1.2.x/");
-
-
/*
* Necessary! Otherwise TestNG will not be used...
*
@@ -113,6 +94,20 @@ task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource;
}
+/*
+ * Lint all the things!
+ */
+allprojects {
+ gradle.projectsEvaluated {
+ tasks.withType(JavaCompile) {
+ options.compilerArgs << "-Xlint:all" << "-Werror"
+ }
+ tasks.withType(Javadoc) {
+ options.addStringOption('Xwerror', '-quiet')
+ }
+ }
+}
+
/*
* Javadoc: we need to tell where the overview.html is, it will not pick it up
* automatically...
@@ -120,7 +115,6 @@ task sourcesJar(type: Jar, dependsOn: classes) {
javadoc.options {
overview = "src/main/javadoc/overview.html";
- extDirs = [ file("src/main/javadoc") ];
docFilesSubDirs = true;
}
@@ -128,12 +122,14 @@ javadoc.options {
* Equally annoyingly, the docFilesSubDirs option above does not seem to have
* any effect :/
*/
-task copyDocFiles(dependsOn: javadoc) << {
- copy {
- from("src/main/javadoc") {
- include "**/doc-files/**";
- };
- into javadoc.destinationDir;
+task copyDocFiles(dependsOn: javadoc) {
+ doLast {
+ copy {
+ from("src/main/javadoc") {
+ include "**/doc-files/**";
+ };
+ into javadoc.destinationDir;
+ }
}
}
@@ -166,13 +162,15 @@ artifacts {
archives libJar;
}
-task wrapper(type: Wrapper) {
- gradleVersion = "1.11";
- distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
+wrapper {
+ gradleVersion = "5.6.3";
+ distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
}
-task pom << {
- pom {}.writeTo("${projectDir}/pom.xml");
+task pom {
+ doLast {
+ pom {}.writeTo("${projectDir}/pom.xml");
+ }
}
/*
@@ -180,25 +178,26 @@ task pom << {
*/
project.ext {
- gitrwscm = sprintf("git@github.com:fge/%s", name);
- gitroscm = sprintf("https://github.com/fge/%s.git", name);
- projectURL = sprintf("https://github.com/fge/%s", name);
+ scmUrl = sprintf("git@github.com:java-json-tools/%s.git", name);
+ projectURL = sprintf("https://github.com/java-json-tools/%s", name);
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
};
-task checkSigningRequirements << {
- def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
- def noDice = false;
- requiredProperties.each {
- if (project.properties[it] == null) {
- noDice = true;
- System.err.printf("property \"%s\" is not defined!", it);
+task checkSigningRequirements {
+ doLast {
+ def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
+ def noDice = false;
+ requiredProperties.each {
+ if (project.properties[it] == null) {
+ noDice = true;
+ System.err.printf("property \"%s\" is not defined!\n", it);
+ }
}
+ if (noDice)
+ throw new IllegalStateException("missing required properties for " +
+ "upload");
}
- if (noDice)
- throw new IllegalStateException("missing required properties for " +
- "upload");
}
uploadArchives {
@@ -234,15 +233,15 @@ uploadArchives {
uploadArchives.repositories.mavenDeployer
]*.pom*.whenConfigured { pom ->
pom.project {
- name "${name}";
+ name "${project.name}";
packaging "jar";
- description "${description}";
+ description "${project.ext.description}";
url "${projectURL}";
scm {
- url "${gitrwscm}";
- connection "${gitrwscm}";
- developerConnection "${gitroscm}";
+ url "${scmUrl}";
+ connection "${scmUrl}";
+ developerConnection "scm:git:${scmUrl}";
}
licenses {
@@ -260,15 +259,14 @@ uploadArchives {
developers {
developer {
- id "fge";
- name "Francis Galiegue";
- email "fgaliegue@gmail.com";
+ id "huggsboson";
+ name "John Huffaker";
+ email "jhuffaker+java-json-tools@gmail.com";
}
}
}
}
-ext.forRelease = !version.endsWith("-SNAPSHOT");
signing {
required { forRelease && gradle.taskGraph.hasTask("uploadArchives") };
sign configurations.archives;
diff --git a/dorelease.sh b/dorelease.sh
index decafaa51..62a9a4c34 100755
--- a/dorelease.sh
+++ b/dorelease.sh
@@ -1,4 +1,21 @@
#!/bin/bash
-./gradlew --recompile-scripts clean test uploadArchives
+# Release instructions
+# 1. Follow the gpg setup instructions: http://central.sonatype.org/pages/working-with-pgp-signatures.html
+# a. gpg2 --export-secret-keys > ~/.gnupg/secring.gpg
+# b. gpg2 --list-keys --keyid-format short
+# 2. In ~/.gradle add:
+# sonatypeUsername=your sonatype user name
+# sonatypePassword=password in vault for oss sonatype
+#
+# signing.keyId=generated key in short format
+# signing.password=password for gpg key
+# signing.secretKeyRingFile=/Users/username/.gnupg/secring.gpg
+#
+# 3. ./dorelease.sh
+# 4. Go to UI at: https://oss.sonatype.org
+# 5. Login as sonatypeUsername
+# 6. Follow the instructions here: http://central.sonatype.org/pages/releasing-the-deployment.html
+
+./gradlew --refresh-dependencies clean test uploadArchives
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 3c7abdf12..5c2d1cf01 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 70597454a..3a54a3332 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,25 +1,5 @@
-#
-# Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
-#
-# 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: https://www.gnu.org/licenses/lgpl-3.0.txt
-# - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
-#
-
-#Mon Apr 14 09:45:58 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
diff --git a/gradlew b/gradlew
index 91a7e269e..83f2acfdc 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,20 +22,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -90,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -110,10 +125,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +170,19 @@ if $cygwin ; then
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index aec99730b..24467a141 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +62,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +75,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/project.gradle b/project.gradle
new file mode 100644
index 000000000..3d2665129
--- /dev/null
+++ b/project.gradle
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
+ *
+ * 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: https://www.gnu.org/licenses/lgpl-3.0.txt
+ * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
+ */
+
+/*
+ * Project-specific settings. Unfortunately we cannot put the name in there!
+ */
+group = "com.github.java-json-tools";
+version = "2.2.14";
+sourceCompatibility = JavaVersion.VERSION_1_7;
+targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility
+
+project.ext {
+ description = "A Java implementation of the JSON Schema specification";
+}
+
+/*
+ * List of dependencies
+ */
+dependencies {
+ compile(group: "com.google.guava", name: "guava", version: "28.2-android");
+ compile(group: "com.github.java-json-tools", name: "jackson-coreutils-equivalence", version: "1.0");
+ compile(group: "com.github.java-json-tools", name: "json-schema-core", version: "1.2.14");
+ // FIXME: 1.6.4 exists, but has different license (EDL 1.0, EPL 2.0). Can update?
+ compile(group: "com.sun.mail", name: "mailapi", version: "1.6.2");
+ compile(group: "joda-time", name: "joda-time", version: "2.10.5");
+ compile(group: "com.googlecode.libphonenumber", name: "libphonenumber", version: "8.11.1");
+ compile(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2");
+ compile(group: "net.sf.jopt-simple", name: "jopt-simple", version: "5.0.4");
+ testCompile(group: "org.testng", name: "testng", version: "7.1.0") {
+ exclude(group: "junit", module: "junit");
+ exclude(group: "org.beanshell", module: "bsh");
+ exclude(group: "org.yaml", module: "snakeyaml");
+ };
+ testCompile(group: "org.mockito", name: "mockito-core", version: "2.28.2");
+ // FIXME: update to 3.x once we're off of Java 7.
+ testCompile(group: "org.assertj", name: "assertj-core", version: "2.9.1");
+}
+
+javadoc {
+ options {
+ def currentJavaVersion = org.gradle.api.JavaVersion.current()
+ // FIXME: https://github.com/gradle/gradle/issues/11182
+ if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
+ addStringOption("-release", "7");
+ }
+ links("https://docs.oracle.com/javase/7/docs/api/");
+ links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/");
+ links("https://fasterxml.github.io/jackson-databind/javadoc/2.11/");
+ links("https://fasterxml.github.io/jackson-core/javadoc/2.11/");
+ links("https://www.javadoc.io/doc/com.google.guava/guava/28.2-android/");
+ links("https://java-json-tools.github.io/btf/");
+ links("https://java-json-tools.github.io/msg-simple/");
+ links("https://java-json-tools.github.io/jackson-coreutils/");
+ links("https://java-json-tools.github.io/uri-template/");
+ links("https://java-json-tools.github.io/json-schema-core/1.2.x/");
+ }
+}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/format/draftv3/package-info.java b/settings.gradle
similarity index 62%
rename from src/main/javadoc/com/github/fge/jsonschema/format/draftv3/package-info.java
rename to settings.gradle
index e14192887..4c0aacfa0 100644
--- a/src/main/javadoc/com/github/fge/jsonschema/format/draftv3/package-info.java
+++ b/settings.gradle
@@ -7,8 +7,9 @@
* later version;
* - the Apache Software License (ASL) version 2.0.
*
- * The text of both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
+ * 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:
*
@@ -16,8 +17,4 @@
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
*/
-/**
- * Format attributes specific to draft v3
- */
-
-package com.github.fge.jsonschema.format.draftv3;
\ No newline at end of file
+rootProject.name = "json-schema-validator";
diff --git a/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfiguration.java b/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfiguration.java
index b67fdc840..54a1b9360 100644
--- a/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfiguration.java
+++ b/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfiguration.java
@@ -70,6 +70,11 @@ public final class ValidationConfiguration
* Whether to use {@code format} in the resulting factory
*/
final boolean useFormat;
+
+ /**
+ * Cache size for processing validations
+ */
+ final int cacheSize;
/**
* The set of syntax messages
@@ -113,6 +118,7 @@ public static ValidationConfiguration byDefault()
libraries = ImmutableMap.copyOf(builder.libraries);
defaultLibrary = builder.defaultLibrary;
useFormat = builder.useFormat;
+ cacheSize = builder.cacheSize;
syntaxMessages = builder.syntaxMessages;
validationMessages = builder.validationMessages;
}
@@ -146,6 +152,11 @@ public boolean getUseFormat()
{
return useFormat;
}
+
+ public int getCacheSize()
+ {
+ return cacheSize;
+ }
public MessageBundle getSyntaxMessages()
{
diff --git a/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfigurationBuilder.java b/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfigurationBuilder.java
index 61cdec21c..949a18b3b 100644
--- a/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfigurationBuilder.java
+++ b/src/main/java/com/github/fge/jsonschema/cfg/ValidationConfigurationBuilder.java
@@ -80,6 +80,11 @@ public final class ValidationConfigurationBuilder
* Whether to use {@code format} ({@code true} by default)
*/
boolean useFormat = true;
+
+ /**
+ * Cache maximum size of 512 records by default
+ */
+ int cacheSize = 512;
/**
* The set of syntax messages
@@ -119,6 +124,7 @@ public final class ValidationConfigurationBuilder
libraries = Maps.newHashMap(cfg.libraries);
defaultLibrary = cfg.defaultLibrary;
useFormat = cfg.useFormat;
+ cacheSize = cfg.cacheSize;
syntaxMessages = cfg.syntaxMessages;
validationMessages = cfg.validationMessages;
}
@@ -217,6 +223,14 @@ public ValidationConfigurationBuilder setValidationMessages(
return this;
}
+ public ValidationConfigurationBuilder setCacheSize(
+ final int cacheSize)
+ {
+ BUNDLE.checkArgument(cacheSize >= -1, "invalidCacheSize");
+ this.cacheSize = cacheSize;
+ return this;
+ }
+
/**
* Return a frozen version of this configuration
*
diff --git a/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java b/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java
index f50d10a70..ef609b49b 100644
--- a/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java
+++ b/src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java
@@ -28,6 +28,8 @@
public final class InvalidInstanceException
extends ProcessingException
{
+ private static final long serialVersionUID = -3273787152985150466L;
+
public InvalidInstanceException(final ProcessingMessage message)
{
super(message);
diff --git a/src/main/java/com/github/fge/jsonschema/format/AbstractFormatAttribute.java b/src/main/java/com/github/fge/jsonschema/format/AbstractFormatAttribute.java
index 69b9d5c58..5b44e7bb5 100644
--- a/src/main/java/com/github/fge/jsonschema/format/AbstractFormatAttribute.java
+++ b/src/main/java/com/github/fge/jsonschema/format/AbstractFormatAttribute.java
@@ -72,6 +72,7 @@ public final EnumSet supportedTypes()
* Return a new message for this format attribute
*
* @param data the validation context
+ * @param bundle the format bundle
* @param key key in the format bundle message
* @return a new message
*/
diff --git a/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java
index d2055314b..8aae60ad2 100644
--- a/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java
+++ b/src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java
@@ -31,8 +31,6 @@
import org.joda.time.format.DateTimeFormatterBuilder;
import org.joda.time.format.DateTimeParser;
-import java.util.List;
-
import static org.joda.time.DateTimeFieldType.*;
/**
@@ -41,14 +39,14 @@
public final class DateTimeAttribute
extends AbstractFormatAttribute
{
- private static final List FORMATS = ImmutableList.of(
- "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
+ private static final ImmutableList FORMATS = ImmutableList.of(
+ "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z"
);
private static final DateTimeFormatter FORMATTER;
static {
- final DateTimeParser msParser = new DateTimeFormatterBuilder()
- .appendLiteral('.').appendDecimal(millisOfSecond(), 1, 3)
+ final DateTimeParser secFracsParser = new DateTimeFormatterBuilder()
+ .appendLiteral('.').appendFractionOfSecond(1,12)
.toParser();
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
@@ -64,7 +62,7 @@ public final class DateTimeAttribute
.appendFixedDecimal(minuteOfHour(), 2)
.appendLiteral(':')
.appendFixedDecimal(secondOfMinute(), 2)
- .appendOptional(msParser)
+ .appendOptional(secFracsParser)
.appendTimeZoneOffset("Z", false, 2, 2);
FORMATTER = builder.toFormatter();
diff --git a/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java
new file mode 100644
index 000000000..73c1e12af
--- /dev/null
+++ b/src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java
@@ -0,0 +1,116 @@
+package com.github.fge.jsonschema.format.common;
+
+import com.github.fge.jsonschema.cfg.ValidationConfiguration;
+import com.github.fge.jsonschema.library.DraftV4Library;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.DateTimeFormatterBuilder;
+import org.joda.time.format.DateTimeParser;
+
+import com.github.fge.jackson.NodeType;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.format.AbstractFormatAttribute;
+import com.github.fge.jsonschema.format.FormatAttribute;
+import com.github.fge.jsonschema.processors.data.FullData;
+import com.github.fge.msgsimple.bundle.MessageBundle;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * A {@link DateTimeFormatter} for date and time format defined in RFC3339.
+ *
+ * This is backwards incompat with the original DateTimeAttribute. It will become the default in the future
+ * to use it currently you need to:
+ * Library library = DraftV4Library.get().thaw()
+ * .addFormatAttribute("date-time", RFC3339DateTimeAttribute.getInstance())
+ * .freeze();
+ * Then follow the rest of the steps in example 8 to hook it into your flow.
+ *
+ * @see RFC 3339 - Section 5.6
+ */
+public class RFC3339DateTimeAttribute extends AbstractFormatAttribute {
+
+ private static final ImmutableList RFC3339_FORMATS = ImmutableList.of(
+ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)"
+ );
+
+ private static final DateTimeFormatter FORMATTER;
+
+ static {
+ final DateTimeParser secFracsParser = new DateTimeFormatterBuilder()
+ .appendLiteral('.').appendFractionOfSecond(1,12)
+ .toParser();
+
+ DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder()
+ .appendPattern("yyyy-MM-dd'T'HH:mm:ss")
+ .appendOptional(secFracsParser)
+ .appendTimeZoneOffset("Z", true, 2, 2);
+
+ FORMATTER = builder.toFormatter();
+ }
+
+ private static final FormatAttribute INSTANCE = new RFC3339DateTimeAttribute();
+
+ public static FormatAttribute getInstance()
+ {
+ return INSTANCE;
+ }
+
+ private RFC3339DateTimeAttribute()
+ {
+ super("date-time", NodeType.STRING);
+ }
+
+ @Override
+ public void validate(final ProcessingReport report,
+ final MessageBundle bundle, final FullData data)
+ throws ProcessingException
+ {
+ final String value = data.getInstance().getNode().textValue();
+
+ try
+ {
+ FORMATTER.parseDateTime(value);
+
+ final String secFracsAndOffset = value.substring("yyyy-MM-ddTHH:mm:ss".length());
+ final String offset;
+ if (!secFracsAndOffset.startsWith(".")) {
+ offset = secFracsAndOffset;
+ } else{
+ if (secFracsAndOffset.contains("Z")) {
+ offset = secFracsAndOffset.substring(secFracsAndOffset.indexOf("Z"));
+ } else if (secFracsAndOffset.contains("+")) {
+ offset = secFracsAndOffset.substring(secFracsAndOffset.indexOf("+"));
+ } else {
+ offset = secFracsAndOffset.substring(secFracsAndOffset.indexOf("-"));
+ }
+ }
+ if (!isOffSetStrictRFC3339(offset)) {
+ throw new IllegalArgumentException();
+ }
+
+ } catch (IllegalArgumentException ignored) {
+ report.error(newMsg(data, bundle, "err.format.invalidDate")
+ .putArgument("value", value).putArgument("expected", RFC3339_FORMATS));
+ }
+
+ }
+
+ /**
+ * Return true if date-time offset stricly follows RFC3339:
+ * time-hour = 2DIGIT ; 00-23
+ * time-minute = 2DIGIT ; 00-59
+ * time-numoffset = ("+" / "-") time-hour ":" time-minute
+ * time-offset = "Z" / time-numoffset,
+ * and false otherwise
+ * @param offset
+ * @return
+ */
+ private boolean isOffSetStrictRFC3339(final String offset)
+ {
+ if (offset.endsWith("Z")) return true;
+ if (offset.length() == 6 && offset.contains(":")) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java b/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java
index 9db53adee..f20127c19 100644
--- a/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java
+++ b/src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java
@@ -22,7 +22,7 @@
import com.github.fge.jackson.NodeType;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.core.util.RhinoHelper;
+import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.format.AbstractFormatAttribute;
import com.github.fge.jsonschema.format.FormatAttribute;
import com.github.fge.jsonschema.processors.data.FullData;
@@ -34,7 +34,7 @@
* Again, here, we do not use {@link java.util.regex} because it does
* not fit the bill.
*
- * @see RhinoHelper
+ * @see RegexECMA262Helper
*/
public final class RegexAttribute
extends AbstractFormatAttribute
@@ -58,7 +58,7 @@ public void validate(final ProcessingReport report,
{
final String value = data.getInstance().getNode().textValue();
- if (!RhinoHelper.regexIsValid(value))
+ if (!RegexECMA262Helper.regexIsValid(value))
report.error(newMsg(data, bundle, "err.format.invalidRegex")
.putArgument("value", value));
}
diff --git a/src/main/java/com/github/fge/jsonschema/format/helpers/AbstractDateFormatAttribute.java b/src/main/java/com/github/fge/jsonschema/format/helpers/AbstractDateFormatAttribute.java
index ed253f6ea..687452c1c 100644
--- a/src/main/java/com/github/fge/jsonschema/format/helpers/AbstractDateFormatAttribute.java
+++ b/src/main/java/com/github/fge/jsonschema/format/helpers/AbstractDateFormatAttribute.java
@@ -61,7 +61,7 @@ public final void validate(final ProcessingReport report,
final String value = data.getInstance().getNode().textValue();
try {
- formatter.parseDateTime(value);
+ formatter.parseLocalDate(value);
} catch (IllegalArgumentException ignored) {
report.error(newMsg(data, bundle, "err.format.invalidDate")
.putArgument("value", value).putArgument("expected", format));
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/common/AdditionalPropertiesDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/common/AdditionalPropertiesDigester.java
index 5f9a949fb..3a485700e 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/common/AdditionalPropertiesDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/common/AdditionalPropertiesDigester.java
@@ -64,8 +64,8 @@ public JsonNode digest(final JsonNode schema)
* not be the case if and only if it has boolean value false.
*/
ret.put(keyword, true);
- ret.put("properties", properties);
- ret.put("patternProperties", patternProperties);
+ ret.set("properties", properties);
+ ret.set("patternProperties", patternProperties);
if (schema.get(keyword).asBoolean(true))
return ret;
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java
index 386bb07bb..d081b6f41 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java
@@ -61,10 +61,10 @@ public JsonNode digest(final JsonNode schema)
final ObjectNode ret = FACTORY.objectNode();
final ObjectNode propertyDeps = FACTORY.objectNode();
- ret.put("propertyDeps", propertyDeps);
+ ret.set("propertyDeps", propertyDeps);
final ArrayNode schemaDeps = FACTORY.arrayNode();
- ret.put("schemaDeps", schemaDeps);
+ ret.set("schemaDeps", schemaDeps);
final List list = Lists.newArrayList();
@@ -86,11 +86,14 @@ public JsonNode digest(final JsonNode schema)
case ARRAY:
final JsonNode node = sortedSet(value);
if (node.size() != 0)
- propertyDeps.put(key, node);
+ propertyDeps.set(key, node);
break;
case STRING:
- propertyDeps.put(key, FACTORY.arrayNode()
+ propertyDeps.set(key, FACTORY.arrayNode()
.add(value.textValue()));
+ break;
+ default:
+ break;
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3PropertiesDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3PropertiesDigester.java
index 2565374de..5d6c0aa59 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3PropertiesDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3PropertiesDigester.java
@@ -56,7 +56,7 @@ public JsonNode digest(final JsonNode schema)
// TODO: return an array directly (same for "required" in v4)
final ObjectNode ret = FACTORY.objectNode();
final ArrayNode required = FACTORY.arrayNode();
- ret.put("required", required);
+ ret.set("required", required);
final JsonNode node = schema.get(keyword);
final List list = Lists.newArrayList(node.fieldNames());
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4DependenciesDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4DependenciesDigester.java
index d82fe1200..9dc20c527 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4DependenciesDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4DependenciesDigester.java
@@ -60,10 +60,10 @@ public JsonNode digest(final JsonNode schema)
final ObjectNode ret = FACTORY.objectNode();
final ObjectNode propertyDeps = FACTORY.objectNode();
- ret.put("propertyDeps", propertyDeps);
+ ret.set("propertyDeps", propertyDeps);
final ArrayNode schemaDeps = FACTORY.arrayNode();
- ret.put("schemaDeps", schemaDeps);
+ ret.set("schemaDeps", schemaDeps);
final List list = Lists.newArrayList();
@@ -79,7 +79,7 @@ public JsonNode digest(final JsonNode schema)
if (value.isObject()) // schema dep
list.add(key);
else // property dep
- propertyDeps.put(key, sortedSet(value));
+ propertyDeps.set(key, sortedSet(value));
}
for (final String s: Ordering.natural().sortedCopy(list))
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4TypeDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4TypeDigester.java
index dc67e0206..1bb64e4c0 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4TypeDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/DraftV4TypeDigester.java
@@ -59,7 +59,7 @@ public JsonNode digest(final JsonNode schema)
{
final ObjectNode ret = FACTORY.objectNode();
final ArrayNode allowedTypes = FACTORY.arrayNode();
- ret.put(keyword, allowedTypes);
+ ret.set(keyword, allowedTypes);
final JsonNode node = schema.get(keyword);
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester.java
index db3a11f37..75527ee8c 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/draftv4/RequiredDigester.java
@@ -57,7 +57,7 @@ public JsonNode digest(final JsonNode schema)
{
final ObjectNode ret = FACTORY.objectNode();
final ArrayNode required = FACTORY.arrayNode();
- ret.put(keyword, required);
+ ret.set(keyword, required);
final List list = Lists.newArrayList(schema.get(keyword));
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/DraftV3TypeKeywordDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/DraftV3TypeKeywordDigester.java
index 00b0f55ea..127962ef5 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/DraftV3TypeKeywordDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/DraftV3TypeKeywordDigester.java
@@ -49,9 +49,9 @@ public JsonNode digest(final JsonNode schema)
{
final ObjectNode ret = FACTORY.objectNode();
final ArrayNode simpleTypes = FACTORY.arrayNode();
- ret.put(keyword, simpleTypes);
+ ret.set(keyword, simpleTypes);
final ArrayNode schemas = FACTORY.arrayNode();
- ret.put("schemas", schemas);
+ ret.set("schemas", schemas);
final JsonNode node = schema.get(keyword);
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/NumericDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/NumericDigester.java
index 5e08958fb..69501ca1a 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/NumericDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/NumericDigester.java
@@ -67,14 +67,14 @@ protected final ObjectNode digestedNumberNode(final JsonNode schema)
ret.put("valueIsLong", isLong);
if (isLong) {
- ret.put(keyword, node.canConvertToInt()
+ ret.set(keyword, node.canConvertToInt()
? FACTORY.numberNode(node.intValue())
: FACTORY.numberNode(node.longValue()));
return ret;
}
final BigDecimal decimal = node.decimalValue();
- ret.put(keyword, decimal.scale() == 0
+ ret.set(keyword, decimal.scale() == 0
? FACTORY.numberNode(decimal.toBigIntegerExact())
: node);
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/SimpleDigester.java b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/SimpleDigester.java
index c83141d11..87849e345 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/SimpleDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/digest/helpers/SimpleDigester.java
@@ -43,7 +43,7 @@ public SimpleDigester(final String keyword, final NodeType first,
public JsonNode digest(final JsonNode schema)
{
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schema.get(keyword));
+ ret.set(keyword, schema.get(keyword));
return ret;
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/KeywordValidatorFactory.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/KeywordValidatorFactory.java
new file mode 100755
index 000000000..db84c642e
--- /dev/null
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/KeywordValidatorFactory.java
@@ -0,0 +1,20 @@
+package com.github.fge.jsonschema.keyword.validator;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+
+/**
+ * Interface for a keyword validator factory
+ */
+public interface KeywordValidatorFactory
+{
+ /**
+ * Create a validator for the instance
+ *
+ * @param node the instance to validate
+ * @return a validator for the given instance
+ * @throws ProcessingException an error occurs creating the validator
+ */
+ KeywordValidator getKeywordValidator(JsonNode node)
+ throws ProcessingException;
+}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/ReflectionKeywordValidatorFactory.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/ReflectionKeywordValidatorFactory.java
new file mode 100755
index 000000000..54e394c1c
--- /dev/null
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/ReflectionKeywordValidatorFactory.java
@@ -0,0 +1,52 @@
+package com.github.fge.jsonschema.keyword.validator;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+import com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle;
+import com.github.fge.msgsimple.bundle.MessageBundle;
+import com.github.fge.msgsimple.load.MessageBundles;
+
+/**
+ * A validator factory that uses reflection to create an instance of the
+ * specified KeywordValidator class
+ */
+public class ReflectionKeywordValidatorFactory
+ implements KeywordValidatorFactory
+{
+ private static final String ERRMSG = "failed to build keyword validator";
+ private static final MessageBundle BUNDLE
+ = MessageBundles.getBundle(JsonSchemaConfigurationBundle.class);
+
+ private final Constructor extends KeywordValidator> constructor;
+
+ public ReflectionKeywordValidatorFactory(String name,
+ Class extends KeywordValidator> clazz)
+ {
+ try {
+ constructor = clazz.getConstructor(JsonNode.class);
+ } catch (NoSuchMethodException ignored) {
+ throw new IllegalArgumentException(BUNDLE.printf(
+ "noAppropriateConstructor", name, clazz.getCanonicalName()
+ ));
+ }
+ }
+
+ @Override
+ public KeywordValidator getKeywordValidator(JsonNode node)
+ throws ProcessingException
+ {
+ try {
+ return constructor.newInstance(node);
+ } catch (InstantiationException e) {
+ throw new ProcessingException(ERRMSG, e);
+ } catch (IllegalAccessException e) {
+ throw new ProcessingException(ERRMSG, e);
+ } catch (InvocationTargetException e) {
+ throw new ProcessingException(ERRMSG, e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java
index b466ba678..1741dad02 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java
@@ -25,7 +25,7 @@
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.core.util.RhinoHelper;
+import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
@@ -84,7 +84,7 @@ public void validate(final Processor processor,
for (final String field: fields)
for (final String regex: patternProperties)
- if (RhinoHelper.regMatch(regex, field))
+ if (RegexECMA262Helper.regMatch(regex, field))
tmp.add(field);
fields.removeAll(tmp);
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/EnumValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/EnumValidator.java
index e0caaa50e..1df7aa1ea 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/EnumValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/EnumValidator.java
@@ -20,7 +20,7 @@
package com.github.fge.jsonschema.keyword.validator.common;
import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.JsonNumEquals;
+import com.github.fge.jackson.JsonNumEquivalence;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
@@ -32,13 +32,13 @@
/**
* Keyword validator for {@code enum}
*
- * @see JsonNumEquals
+ * @see JsonNumEquivalence
*/
public final class EnumValidator
extends AbstractKeywordValidator
{
private static final Equivalence EQUIVALENCE
- = JsonNumEquals.getInstance();
+ = JsonNumEquivalence.getInstance();
private final JsonNode values;
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java
index 653428a27..5bce7ea79 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java
@@ -23,7 +23,7 @@
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.core.util.RhinoHelper;
+import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
@@ -31,7 +31,7 @@
/**
* Keyword validator for {@code pattern}
*
- * @see RhinoHelper
+ * @see RegexECMA262Helper
*/
public final class PatternValidator
extends AbstractKeywordValidator
@@ -50,7 +50,7 @@ public void validate(final Processor processor,
final String regex = data.getSchema().getNode().get(keyword)
.textValue();
final String value = data.getInstance().getNode().textValue();
- if (!RhinoHelper.regMatch(regex, value))
+ if (!RegexECMA262Helper.regMatch(regex, value))
report.error(newMsg(data, bundle, "err.common.pattern.noMatch")
.putArgument("regex", regex).putArgument("string", value));
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/UniqueItemsValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/UniqueItemsValidator.java
index a04bab2f4..7cb8b2140 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/common/UniqueItemsValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/common/UniqueItemsValidator.java
@@ -20,7 +20,7 @@
package com.github.fge.jsonschema.keyword.validator.common;
import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.JsonNumEquals;
+import com.github.fge.jackson.JsonNumEquivalence;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
@@ -35,13 +35,13 @@
/**
* Keyword validator for {@code uniqueItems}
*
- * @see JsonNumEquals
+ * @see JsonNumEquivalence
*/
public final class UniqueItemsValidator
extends AbstractKeywordValidator
{
private static final Equivalence EQUIVALENCE
- = JsonNumEquals.getInstance();
+ = JsonNumEquivalence.getInstance();
private final boolean uniqueItems;
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DisallowKeywordValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DisallowKeywordValidator.java
index eb128947d..22d472525 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DisallowKeywordValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DisallowKeywordValidator.java
@@ -75,7 +75,7 @@ public void validate(final Processor processor,
ptr = schemaPointer.append(JsonPointer.of(keyword, index));
newData = data.withSchema(tree.setPointer(ptr));
processor.process(subReport, newData);
- fullReport.put(ptr.toString(), subReport.asJson());
+ fullReport.set(ptr.toString(), subReport.asJson());
if (subReport.isSuccess())
nrSuccess++;
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DraftV3TypeValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DraftV3TypeValidator.java
index 8894f4597..ac269fa30 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DraftV3TypeValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv3/DraftV3TypeValidator.java
@@ -79,7 +79,7 @@ public void validate(final Processor processor,
ptr = schemaPointer.append(JsonPointer.of(keyword, index));
newData = data.withSchema(tree.setPointer(ptr));
processor.process(subReport, newData);
- fullReport.put(ptr.toString(), subReport.asJson());
+ fullReport.set(ptr.toString(), subReport.asJson());
if (subReport.isSuccess())
nrSuccess++;
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AllOfValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AllOfValidator.java
index f7fb5f94b..77ab62332 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AllOfValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AllOfValidator.java
@@ -66,7 +66,7 @@ public void validate(final Processor processor,
ptr = schemaPointer.append(JsonPointer.of(keyword, index));
newData = data.withSchema(tree.setPointer(ptr));
processor.process(subReport, newData);
- fullReport.put(ptr.toString(), subReport.asJson());
+ fullReport.set(ptr.toString(), subReport.asJson());
if (subReport.isSuccess())
nrSuccess++;
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AnyOfValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AnyOfValidator.java
index 27756d459..c2760eb16 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AnyOfValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/AnyOfValidator.java
@@ -66,7 +66,7 @@ public void validate(final Processor processor,
ptr = schemaPointer.append(JsonPointer.of(keyword, index));
newData = data.withSchema(tree.setPointer(ptr));
processor.process(subReport, newData);
- fullReport.put(ptr.toString(), subReport.asJson());
+ fullReport.set(ptr.toString(), subReport.asJson());
if (subReport.isSuccess())
nrSuccess++;
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/OneOfValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/OneOfValidator.java
index d1eb70e8d..f40cd7dec 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/OneOfValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/draftv4/OneOfValidator.java
@@ -66,7 +66,7 @@ public void validate(final Processor processor,
ptr = schemaPointer.append(JsonPointer.of(keyword, index));
newData = data.withSchema(tree.setPointer(ptr));
processor.process(subReport, newData);
- fullReport.put(ptr.toString(), subReport.asJson());
+ fullReport.set(ptr.toString(), subReport.asJson());
if (subReport.isSuccess())
nrSuccess++;
}
diff --git a/src/main/java/com/github/fge/jsonschema/keyword/validator/helpers/NumericValidator.java b/src/main/java/com/github/fge/jsonschema/keyword/validator/helpers/NumericValidator.java
index e6a9ac001..3a8669040 100644
--- a/src/main/java/com/github/fge/jsonschema/keyword/validator/helpers/NumericValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/keyword/validator/helpers/NumericValidator.java
@@ -77,7 +77,8 @@ public final void validate(final Processor processor,
* @param report the validation report
* @param bundle the message bundle to use
* @param data the validation data
- */
+ * @throws ProcessingException a processing error occurred during validation
+ */
protected abstract void validateLong(final ProcessingReport report,
final MessageBundle bundle, final FullData data)
throws ProcessingException;
@@ -89,6 +90,7 @@ protected abstract void validateLong(final ProcessingReport report,
* @param report the validation report
* @param bundle the message bundle to use
* @param data the validation data
+ * @throws ProcessingException a processing error occurred during validation
*/
protected abstract void validateDecimal(final ProcessingReport report,
final MessageBundle bundle, final FullData data)
diff --git a/src/main/java/com/github/fge/jsonschema/library/Keyword.java b/src/main/java/com/github/fge/jsonschema/library/Keyword.java
index b9a6d8ea1..adace7d33 100644
--- a/src/main/java/com/github/fge/jsonschema/library/Keyword.java
+++ b/src/main/java/com/github/fge/jsonschema/library/Keyword.java
@@ -22,9 +22,7 @@
import com.github.fge.Frozen;
import com.github.fge.jsonschema.core.keyword.syntax.checkers.SyntaxChecker;
import com.github.fge.jsonschema.keyword.digest.Digester;
-import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
-
-import java.lang.reflect.Constructor;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
/**
@@ -51,9 +49,9 @@ public final class Keyword
final Digester digester;
/**
- * {@link KeywordValidator} constructor
+ * Validator factory
*/
- final Constructor extends KeywordValidator> constructor;
+ final KeywordValidatorFactory validatorFactory;
/**
* Instantiate a new keyword builder
@@ -79,7 +77,7 @@ public static KeywordBuilder newBuilder(final String name)
name = builder.name;
syntaxChecker = builder.syntaxChecker;
digester = builder.digester;
- constructor = builder.constructor;
+ validatorFactory = builder.validatorFactory;
}
/**
diff --git a/src/main/java/com/github/fge/jsonschema/library/KeywordBuilder.java b/src/main/java/com/github/fge/jsonschema/library/KeywordBuilder.java
index fd1f9b330..553b1f8a0 100644
--- a/src/main/java/com/github/fge/jsonschema/library/KeywordBuilder.java
+++ b/src/main/java/com/github/fge/jsonschema/library/KeywordBuilder.java
@@ -19,7 +19,6 @@
package com.github.fge.jsonschema.library;
-import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.Thawed;
import com.github.fge.jackson.NodeType;
import com.github.fge.jsonschema.core.keyword.syntax.checkers.SyntaxChecker;
@@ -27,12 +26,12 @@
import com.github.fge.jsonschema.keyword.digest.helpers.IdentityDigester;
import com.github.fge.jsonschema.keyword.digest.helpers.SimpleDigester;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
+import com.github.fge.jsonschema.keyword.validator.ReflectionKeywordValidatorFactory;
import com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import java.lang.reflect.Constructor;
-
/**
* A keyword builder -- the thawed version of a {@link Keyword}
*
@@ -48,7 +47,7 @@ public final class KeywordBuilder
final String name;
SyntaxChecker syntaxChecker;
Digester digester;
- Constructor extends KeywordValidator> constructor;
+ KeywordValidatorFactory validatorFactory;
/**
* Create a new, empty keyword builder
@@ -74,7 +73,7 @@ public final class KeywordBuilder
name = keyword.name;
syntaxChecker = keyword.syntaxChecker;
digester = keyword.digester;
- constructor = keyword.constructor;
+ validatorFactory = keyword.validatorFactory;
}
/**
@@ -149,7 +148,20 @@ public KeywordBuilder withSimpleDigester(final NodeType first,
public KeywordBuilder withValidatorClass(
final Class extends KeywordValidator> c)
{
- constructor = getConstructor(name, c);
+ validatorFactory = new ReflectionKeywordValidatorFactory(name, c);
+ return this;
+ }
+
+ /**
+ * Set the validator factory for this keyword
+ *
+ * @param factory the factory
+ * @return this
+ */
+ public KeywordBuilder withValidatorFactory(
+ KeywordValidatorFactory factory)
+ {
+ validatorFactory = factory;
return this;
}
@@ -169,24 +181,11 @@ public Keyword freeze()
* We can have a keyword without a validator; however, if there is one,
* there must be a digester.
*/
- BUNDLE.checkArgumentPrintf(constructor == null || digester != null,
+ BUNDLE.checkArgumentPrintf(validatorFactory == null || digester != null,
"malformedKeyword", name);
return new Keyword(this);
}
-
- private static Constructor extends KeywordValidator> getConstructor(
- final String name, final Class extends KeywordValidator> c)
- {
- try {
- return c.getConstructor(JsonNode.class);
- } catch (NoSuchMethodException ignored) {
- throw new IllegalArgumentException(BUNDLE.printf(
- "noAppropriateConstructor", name, c.getCanonicalName()
- ));
- }
- }
-
private static NodeType checkType(final NodeType type)
{
return BUNDLE.checkNotNull(type, "nullType");
diff --git a/src/main/java/com/github/fge/jsonschema/library/Library.java b/src/main/java/com/github/fge/jsonschema/library/Library.java
index 74aa566ce..24087f1a6 100644
--- a/src/main/java/com/github/fge/jsonschema/library/Library.java
+++ b/src/main/java/com/github/fge/jsonschema/library/Library.java
@@ -26,9 +26,7 @@
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.format.FormatAttribute;
import com.github.fge.jsonschema.keyword.digest.Digester;
-import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
-
-import java.lang.reflect.Constructor;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
/**
* A schema keyword library
@@ -54,9 +52,9 @@ public final class Library
final Dictionary digesters;
/**
- * Dictionary of keyword validator constructors
+ * Dictionary of keyword validator factories
*/
- final Dictionary> validators;
+ final Dictionary validators;
/**
* Dictionary of format attributes
@@ -97,7 +95,7 @@ public static LibraryBuilder newBuilder()
*/
Library(final Dictionary syntaxCheckers,
final Dictionary digesters,
- final Dictionary> validators,
+ final Dictionary validators,
final Dictionary formatAttributes)
{
this.syntaxCheckers = syntaxCheckers;
@@ -131,7 +129,7 @@ public Dictionary getDigesters()
*
* @return a dictionary
*/
- public Dictionary> getValidators()
+ public Dictionary getValidators()
{
return validators;
}
diff --git a/src/main/java/com/github/fge/jsonschema/library/LibraryBuilder.java b/src/main/java/com/github/fge/jsonschema/library/LibraryBuilder.java
index b65f64264..93d2a170a 100644
--- a/src/main/java/com/github/fge/jsonschema/library/LibraryBuilder.java
+++ b/src/main/java/com/github/fge/jsonschema/library/LibraryBuilder.java
@@ -25,13 +25,11 @@
import com.github.fge.jsonschema.core.util.DictionaryBuilder;
import com.github.fge.jsonschema.format.FormatAttribute;
import com.github.fge.jsonschema.keyword.digest.Digester;
-import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import java.lang.reflect.Constructor;
-
/**
* Mutable version of a library
*
@@ -60,7 +58,7 @@ public final class LibraryBuilder
/**
* Dictionary builder of keyword validator constructors
*/
- final DictionaryBuilder> validators;
+ final DictionaryBuilder validators;
/**
* Dictionary builder of format attributes
@@ -107,9 +105,9 @@ public LibraryBuilder addKeyword(final Keyword keyword)
syntaxCheckers.addEntry(name, keyword.syntaxChecker);
- if (keyword.constructor != null) {
+ if (keyword.validatorFactory != null) {
digesters.addEntry(name, keyword.digester);
- validators.addEntry(name, keyword.constructor);
+ validators.addEntry(name, keyword.validatorFactory);
}
return this;
}
diff --git a/src/main/java/com/github/fge/jsonschema/library/validator/CommonValidatorDictionary.java b/src/main/java/com/github/fge/jsonschema/library/validator/CommonValidatorDictionary.java
index 20ade1257..b96141b72 100644
--- a/src/main/java/com/github/fge/jsonschema/library/validator/CommonValidatorDictionary.java
+++ b/src/main/java/com/github/fge/jsonschema/library/validator/CommonValidatorDictionary.java
@@ -19,10 +19,11 @@
package com.github.fge.jsonschema.library.validator;
-import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.core.util.DictionaryBuilder;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
+import com.github.fge.jsonschema.keyword.validator.ReflectionKeywordValidatorFactory;
import com.github.fge.jsonschema.keyword.validator.common.AdditionalItemsValidator;
import com.github.fge.jsonschema.keyword.validator.common.AdditionalPropertiesValidator;
import com.github.fge.jsonschema.keyword.validator.common.EnumValidator;
@@ -35,27 +36,25 @@
import com.github.fge.jsonschema.keyword.validator.common.PatternValidator;
import com.github.fge.jsonschema.keyword.validator.common.UniqueItemsValidator;
-import java.lang.reflect.Constructor;
-
/**
* Keyword validator constructors common to draft v4 and v3
*/
public final class CommonValidatorDictionary
{
- private static final Dictionary>
+ private static final Dictionary
DICTIONARY;
private CommonValidatorDictionary()
{
}
- public static Dictionary> get()
+ public static Dictionary get()
{
return DICTIONARY;
}
static {
- final DictionaryBuilder>
+ final DictionaryBuilder
builder = Dictionary.newBuilder();
String keyword;
@@ -66,67 +65,63 @@ public static Dictionary> get()
*/
keyword = "additionalItems";
c = AdditionalItemsValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "minItems";
c = MinItemsValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "maxItems";
c = MaxItemsValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "uniqueItems";
c = UniqueItemsValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* Numbers and integers
*/
keyword = "minimum";
c = MinimumValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "maximum";
c = MaximumValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* Objects
*/
keyword = "additionalProperties";
c = AdditionalPropertiesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* Strings
*/
keyword = "minLength";
c = MinLengthValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "maxLength";
c = MaxLengthValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "pattern";
c = PatternValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "enum";
c = EnumValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
DICTIONARY = builder.freeze();
}
- private static Constructor extends KeywordValidator> constructor(
+ private static KeywordValidatorFactory factory(String name,
final Class extends KeywordValidator> c)
{
- try {
- return c.getConstructor(JsonNode.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("No appropriate constructor", e);
- }
+ return new ReflectionKeywordValidatorFactory(name, c);
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/library/validator/DraftV3ValidatorDictionary.java b/src/main/java/com/github/fge/jsonschema/library/validator/DraftV3ValidatorDictionary.java
index a6d648c11..ecf982b1f 100644
--- a/src/main/java/com/github/fge/jsonschema/library/validator/DraftV3ValidatorDictionary.java
+++ b/src/main/java/com/github/fge/jsonschema/library/validator/DraftV3ValidatorDictionary.java
@@ -19,10 +19,11 @@
package com.github.fge.jsonschema.library.validator;
-import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.core.util.DictionaryBuilder;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
+import com.github.fge.jsonschema.keyword.validator.ReflectionKeywordValidatorFactory;
import com.github.fge.jsonschema.keyword.validator.common.DependenciesValidator;
import com.github.fge.jsonschema.keyword.validator.draftv3.DisallowKeywordValidator;
import com.github.fge.jsonschema.keyword.validator.draftv3.DivisibleByValidator;
@@ -30,27 +31,25 @@
import com.github.fge.jsonschema.keyword.validator.draftv3.ExtendsValidator;
import com.github.fge.jsonschema.keyword.validator.draftv3.PropertiesValidator;
-import java.lang.reflect.Constructor;
-
/**
* Draft v3 specific keyword validator constructors
*/
public final class DraftV3ValidatorDictionary
{
- private static final Dictionary>
+ private static final Dictionary
DICTIONARY;
private DraftV3ValidatorDictionary()
{
}
- public static Dictionary> get()
+ public static Dictionary get()
{
return DICTIONARY;
}
static {
- final DictionaryBuilder>
+ final DictionaryBuilder
builder = Dictionary.newBuilder();
String keyword;
@@ -63,41 +62,37 @@ public static Dictionary> get()
*/
keyword = "divisibleBy";
c = DivisibleByValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* Object
*/
keyword = "properties";
c = PropertiesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "dependencies";
c = DependenciesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "type";
c = DraftV3TypeValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "disallow";
c = DisallowKeywordValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "extends";
c = ExtendsValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
DICTIONARY = builder.freeze();
}
- private static Constructor extends KeywordValidator> constructor(
+ private static KeywordValidatorFactory factory(String name,
final Class extends KeywordValidator> c)
{
- try {
- return c.getConstructor(JsonNode.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("No appropriate constructor found", e);
- }
+ return new ReflectionKeywordValidatorFactory(name, c);
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/library/validator/DraftV4ValidatorDictionary.java b/src/main/java/com/github/fge/jsonschema/library/validator/DraftV4ValidatorDictionary.java
index 6e517c7c9..a82a74b49 100644
--- a/src/main/java/com/github/fge/jsonschema/library/validator/DraftV4ValidatorDictionary.java
+++ b/src/main/java/com/github/fge/jsonschema/library/validator/DraftV4ValidatorDictionary.java
@@ -19,10 +19,11 @@
package com.github.fge.jsonschema.library.validator;
-import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.core.util.DictionaryBuilder;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
+import com.github.fge.jsonschema.keyword.validator.ReflectionKeywordValidatorFactory;
import com.github.fge.jsonschema.keyword.validator.common.DependenciesValidator;
import com.github.fge.jsonschema.keyword.validator.draftv4.AllOfValidator;
import com.github.fge.jsonschema.keyword.validator.draftv4.AnyOfValidator;
@@ -34,27 +35,25 @@
import com.github.fge.jsonschema.keyword.validator.draftv4.OneOfValidator;
import com.github.fge.jsonschema.keyword.validator.draftv4.RequiredKeywordValidator;
-import java.lang.reflect.Constructor;
-
/**
* Draft v4 specific keyword validator constructors
*/
public final class DraftV4ValidatorDictionary
{
- private static final Dictionary>
+ private static final Dictionary
DICTIONARY;
private DraftV4ValidatorDictionary()
{
}
- public static Dictionary> get()
+ public static Dictionary get()
{
return DICTIONARY;
}
static {
- final DictionaryBuilder>
+ final DictionaryBuilder
builder = Dictionary.newBuilder();
String keyword;
@@ -67,60 +66,56 @@ public static Dictionary> get()
*/
keyword = "multipleOf";
c = MultipleOfValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* Object
*/
keyword = "minProperties";
c = MinPropertiesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "maxProperties";
c = MaxPropertiesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "required";
c = RequiredKeywordValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "dependencies";
c = DependenciesValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
/*
* All
*/
keyword = "anyOf";
c = AnyOfValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "allOf";
c = AllOfValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "oneOf";
c = OneOfValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "not";
c = NotValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
keyword = "type";
c = DraftV4TypeValidator.class;
- builder.addEntry(keyword, constructor(c));
+ builder.addEntry(keyword, factory(keyword, c));
DICTIONARY = builder.freeze();
}
- private static Constructor extends KeywordValidator> constructor(
+ private static KeywordValidatorFactory factory(String name,
final Class extends KeywordValidator> c)
{
- try {
- return c.getConstructor(JsonNode.class);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("No appropriate constructor found", e);
- }
+ return new ReflectionKeywordValidatorFactory(name, c);
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/main/JsonSchema.java b/src/main/java/com/github/fge/jsonschema/main/JsonSchema.java
index 2ec548ae0..31a3d9084 100644
--- a/src/main/java/com/github/fge/jsonschema/main/JsonSchema.java
+++ b/src/main/java/com/github/fge/jsonschema/main/JsonSchema.java
@@ -26,69 +26,15 @@
import com.github.fge.jsonschema.core.report.ListProcessingReport;
import com.github.fge.jsonschema.core.report.MessageProvider;
import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.core.report.ReportProvider;
-import com.github.fge.jsonschema.core.tree.SchemaTree;
-import com.github.fge.jsonschema.core.tree.SimpleJsonTree;
-import com.github.fge.jsonschema.processors.data.FullData;
-import com.github.fge.jsonschema.processors.validation.ValidationProcessor;
-
-import javax.annotation.concurrent.Immutable;
/**
* Single-schema instance validator
*
- * This is the class you will use the most often. It is, in essence, a {@link
+ *
This is the interface you will use the most often. It is, in essence, a {@link
* JsonValidator} initialized with a single JSON Schema. Note however that this
* class still retains the ability to resolve JSON References.
- *
- * It has no public constructors: you should use the appropriate methods in
- * {@link JsonSchemaFactory} to obtain an instance of this class.
*/
-@Immutable
-public final class JsonSchema
-{
- private final ValidationProcessor processor;
- private final SchemaTree schema;
- private final ReportProvider reportProvider;
-
- /**
- * Package private constructor
- *
- * @param processor the validation processor
- * @param schema the schema to bind to this instance
- * @param reportProvider the report provider
- */
- JsonSchema(final ValidationProcessor processor, final SchemaTree schema,
- final ReportProvider reportProvider)
- {
- this.processor = processor;
- this.schema = schema;
- this.reportProvider = reportProvider;
- }
-
- private ProcessingReport doValidate(final JsonNode node,
- final boolean deepCheck)
- throws ProcessingException
- {
- final FullData data = new FullData(schema, new SimpleJsonTree(node),
- deepCheck);
- final ProcessingReport report = reportProvider.newReport();
- final ProcessingResult result
- = ProcessingResult.of(processor, report, data);
- return result.getReport();
- }
-
- private ProcessingReport doValidateUnchecked(final JsonNode node,
- final boolean deepCheck)
- {
- final FullData data = new FullData(schema, new SimpleJsonTree(node),
- deepCheck);
- final ProcessingReport report = reportProvider.newReport();
- final ProcessingResult result
- = ProcessingResult.uncheckedResult(processor, report, data);
- return result.getReport();
- }
-
+public interface JsonSchema {
/**
* Validate an instance and return a processing report
*
@@ -102,28 +48,21 @@ private ProcessingReport doValidateUnchecked(final JsonNode node,
*
* @since 2.1.8
*/
- public ProcessingReport validate(final JsonNode instance,
- final boolean deepCheck)
- throws ProcessingException
- {
- return doValidate(instance, deepCheck);
- }
+ ProcessingReport validate(JsonNode instance, boolean deepCheck)
+ throws ProcessingException;
/**
* Validate an instance and return a processing report
*
* This calls {@link #validate(JsonNode, boolean)} with {@code false} as
- * a third argument.
+ * a second argument.
*
* @param instance the instance to validate
* @return a processing report
* @throws ProcessingException a processing error occurred during validation
*/
- public ProcessingReport validate(final JsonNode instance)
- throws ProcessingException
- {
- return validate(instance, false);
- }
+ ProcessingReport validate(JsonNode instance)
+ throws ProcessingException;
/**
* Validate an instance and return a processing report (unchecked version)
@@ -148,12 +87,8 @@ public ProcessingReport validate(final JsonNode instance)
*
* @since 2.1.8
*/
- public ProcessingReport validateUnchecked(final JsonNode instance,
- final boolean deepCheck)
- {
- return doValidateUnchecked(instance, deepCheck);
- }
-
+ ProcessingReport validateUnchecked(JsonNode instance,
+ boolean deepCheck);
/**
* Validate an instance and return a processing report (unchecked version)
*
@@ -164,10 +99,7 @@ public ProcessingReport validateUnchecked(final JsonNode instance,
* @return a report (a {@link ListProcessingReport} if an exception was
* thrown during processing)
*/
- public ProcessingReport validateUnchecked(final JsonNode instance)
- {
- return doValidateUnchecked(instance, false);
- }
+ ProcessingReport validateUnchecked(JsonNode instance);
/**
* Check whether an instance is valid against this schema
@@ -176,11 +108,8 @@ public ProcessingReport validateUnchecked(final JsonNode instance)
* @return true if the instance is valid
* @throws ProcessingException an error occurred during processing
*/
- public boolean validInstance(final JsonNode instance)
- throws ProcessingException
- {
- return doValidate(instance, false).isSuccess();
- }
+ boolean validInstance(JsonNode instance)
+ throws ProcessingException;
/**
* Check whether an instance is valid against this schema (unchecked
@@ -192,8 +121,5 @@ public boolean validInstance(final JsonNode instance)
* @param instance the instance to validate
* @return true if the instance is valid
*/
- public boolean validInstanceUnchecked(final JsonNode instance)
- {
- return doValidateUnchecked(instance, false).isSuccess();
- }
+ boolean validInstanceUnchecked(JsonNode instance);
}
diff --git a/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactory.java b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactory.java
index bfaca5fe0..8822e9470 100644
--- a/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactory.java
+++ b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactory.java
@@ -60,7 +60,7 @@
* a {@link SyntaxValidator}, to validate schemas;
* a {@link JsonValidator}, to validate an instance against a schema;
*
- * a {@link JsonSchema}, to validate instances against a fixed schema.
+ * a {@link JsonSchemaImpl}, to validate instances against a fixed schema.
*
*
*
@@ -275,6 +275,6 @@ private Processor buildProcessor()
final Processor processor
= map.getProcessor();
return new CachingProcessor(processor,
- SchemaContextEquivalence.getInstance());
+ SchemaContextEquivalence.getInstance(), validationCfg.getCacheSize());
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactoryBuilder.java b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactoryBuilder.java
index b4869a4e5..247da45a1 100644
--- a/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactoryBuilder.java
+++ b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaFactoryBuilder.java
@@ -74,12 +74,7 @@ public final class JsonSchemaFactoryBuilder
* @param factory the factory
* @see JsonSchemaFactory#thaw()
*/
- JsonSchemaFactoryBuilder(final JsonSchemaFactory factory)
- {
- reportProvider = factory.reportProvider;
- loadingCfg = factory.loadingCfg;
- validationCfg = factory.validationCfg;
- }
+ JsonSchemaFactoryBuilder(final JsonSchemaFactory factory) {}
/**
* Set a new report provider for this factory
@@ -135,6 +130,12 @@ public JsonSchemaFactoryBuilder setValidationConfiguration(
@Override
public JsonSchemaFactory freeze()
{
+ if (reportProvider == null)
+ reportProvider = new ListReportProvider(LogLevel.INFO, LogLevel.FATAL);
+ if (loadingCfg == null)
+ loadingCfg = LoadingConfiguration.byDefault();
+ if (validationCfg == null)
+ validationCfg = ValidationConfiguration.byDefault();
return new JsonSchemaFactory(this);
}
}
diff --git a/src/main/java/com/github/fge/jsonschema/main/JsonSchemaImpl.java b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaImpl.java
new file mode 100644
index 000000000..900e24b61
--- /dev/null
+++ b/src/main/java/com/github/fge/jsonschema/main/JsonSchemaImpl.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
+ *
+ * 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: https://www.gnu.org/licenses/lgpl-3.0.txt
+ * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
+ */
+
+package com.github.fge.jsonschema.main;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.github.fge.jsonschema.core.exceptions.ProcessingException;
+import com.github.fge.jsonschema.core.processing.ProcessingResult;
+import com.github.fge.jsonschema.core.processing.Processor;
+import com.github.fge.jsonschema.core.report.ListProcessingReport;
+import com.github.fge.jsonschema.core.report.MessageProvider;
+import com.github.fge.jsonschema.core.report.ProcessingReport;
+import com.github.fge.jsonschema.core.report.ReportProvider;
+import com.github.fge.jsonschema.core.tree.SchemaTree;
+import com.github.fge.jsonschema.core.tree.SimpleJsonTree;
+import com.github.fge.jsonschema.processors.data.FullData;
+import com.github.fge.jsonschema.processors.validation.ValidationProcessor;
+
+import javax.annotation.concurrent.Immutable;
+
+/**
+ * Single-schema instance validator
+ *
+ * This is the class you will use the most often. It is, in essence, a {@link
+ * JsonValidator} initialized with a single JSON Schema. Note however that this
+ * class still retains the ability to resolve JSON References.
+ *
+ * It has no public constructors: you should use the appropriate methods in
+ * {@link JsonSchemaFactory} to obtain an instance of this class.
+ */
+@Immutable
+final class JsonSchemaImpl implements JsonSchema
+{
+ private final ValidationProcessor processor;
+ private final SchemaTree schema;
+ private final ReportProvider reportProvider;
+
+ /**
+ * Package private constructor
+ *
+ * @param processor the validation processor
+ * @param schema the schema to bind to this instance
+ * @param reportProvider the report provider
+ */
+ JsonSchemaImpl(final ValidationProcessor processor, final SchemaTree schema,
+ final ReportProvider reportProvider)
+ {
+ this.processor = processor;
+ this.schema = schema;
+ this.reportProvider = reportProvider;
+ }
+
+ private ProcessingReport doValidate(final JsonNode node,
+ final boolean deepCheck)
+ throws ProcessingException
+ {
+ final FullData data = new FullData(schema, new SimpleJsonTree(node),
+ deepCheck);
+ final ProcessingReport report = reportProvider.newReport();
+ final ProcessingResult result
+ = ProcessingResult.of(processor, report, data);
+ return result.getReport();
+ }
+
+ private ProcessingReport doValidateUnchecked(final JsonNode node,
+ final boolean deepCheck)
+ {
+ final FullData data = new FullData(schema, new SimpleJsonTree(node),
+ deepCheck);
+ final ProcessingReport report = reportProvider.newReport();
+ final ProcessingResult result
+ = ProcessingResult.uncheckedResult(processor, report, data);
+ return result.getReport();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ProcessingReport validate(final JsonNode instance,
+ final boolean deepCheck)
+ throws ProcessingException
+ {
+ return doValidate(instance, deepCheck);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ProcessingReport validate(final JsonNode instance)
+ throws ProcessingException
+ {
+ return validate(instance, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ProcessingReport validateUnchecked(final JsonNode instance,
+ final boolean deepCheck)
+ {
+ return doValidateUnchecked(instance, deepCheck);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ProcessingReport validateUnchecked(final JsonNode instance)
+ {
+ return doValidateUnchecked(instance, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean validInstance(final JsonNode instance)
+ throws ProcessingException
+ {
+ return doValidate(instance, false).isSuccess();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean validInstanceUnchecked(final JsonNode instance)
+ {
+ return doValidateUnchecked(instance, false).isSuccess();
+ }
+}
diff --git a/src/main/java/com/github/fge/jsonschema/main/JsonValidator.java b/src/main/java/com/github/fge/jsonschema/main/JsonValidator.java
index 72b8a31ba..0fa7cc28c 100644
--- a/src/main/java/com/github/fge/jsonschema/main/JsonValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/main/JsonValidator.java
@@ -188,7 +188,7 @@ JsonSchema buildJsonSchema(final JsonNode schema, final JsonPointer pointer)
if (tree.getNode().isMissingNode())
throw new JsonReferenceException(new ProcessingMessage()
.setMessage(BUNDLE.getMessage("danglingRef")));
- return new JsonSchema(processor, tree, reportProvider);
+ return new JsonSchemaImpl(processor, tree, reportProvider);
}
/**
@@ -212,7 +212,7 @@ JsonSchema buildJsonSchema(final String uri)
if (tree.getNode().isMissingNode())
throw new JsonReferenceException(new ProcessingMessage()
.setMessage(BUNDLE.getMessage("danglingRef")));
- return new JsonSchema(processor, tree, reportProvider);
+ return new JsonSchemaImpl(processor, tree, reportProvider);
}
/**
diff --git a/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java b/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java
index 95c6eaa4a..752fd7bb3 100644
--- a/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java
+++ b/src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java
@@ -34,7 +34,7 @@
final class CustomHelpFormatter
implements HelpFormatter
{
- private static final List HELP_PREAMBLE = ImmutableList.of(
+ private static final ImmutableList HELP_PREAMBLE = ImmutableList.of(
"Syntax:",
" java -jar jsonschema.jar [options] schema file [file...]",
" java -jar jsonschema.jar --syntax [options] schema [schema...]",
@@ -42,7 +42,7 @@ final class CustomHelpFormatter
"Options: "
);
- private static final List HELP_POST
+ private static final ImmutableList HELP_POST
= ImmutableList.builder()
.add("")
.add("Exit codes:")
diff --git a/src/main/java/com/github/fge/jsonschema/processors/build/ValidatorBuilder.java b/src/main/java/com/github/fge/jsonschema/processors/build/ValidatorBuilder.java
index f8fba5171..27409c83b 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/build/ValidatorBuilder.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/build/ValidatorBuilder.java
@@ -19,23 +19,22 @@
package com.github.fge.jsonschema.processors.build;
+import java.util.Map;
+import java.util.SortedMap;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.library.Library;
import com.github.fge.jsonschema.processors.data.SchemaDigest;
import com.github.fge.jsonschema.processors.data.ValidatorList;
import com.github.fge.jsonschema.processors.validation.ValidationProcessor;
import com.google.common.collect.Maps;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-import java.util.SortedMap;
-
/**
* Keyword builder processor
*
@@ -48,20 +47,18 @@
public final class ValidatorBuilder
implements Processor
{
- private static final String ERRMSG = "failed to build keyword validator";
-
- private final Map>
- constructors;
+ private final Map
+ factories;
public ValidatorBuilder(final Library library)
{
- constructors = library.getValidators().entries();
+ factories = library.getValidators().entries();
}
public ValidatorBuilder(
- final Dictionary> dict)
+ final Dictionary dict)
{
- constructors = dict.entries();
+ factories = dict.entries();
}
/**
@@ -82,35 +79,19 @@ public ValidatorList process(final ProcessingReport report,
String keyword;
JsonNode digest;
KeywordValidator validator;
- Constructor extends KeywordValidator> constructor;
+ KeywordValidatorFactory factory;
for (final Map.Entry entry:
input.getDigests().entrySet()) {
keyword = entry.getKey();
digest = entry.getValue();
- constructor = constructors.get(keyword);
- validator = buildKeyword(constructor, digest);
+ factory = factories.get(keyword);
+ validator = factory.getKeywordValidator(digest);
map.put(keyword, validator);
}
return new ValidatorList(input.getContext(), map.values());
}
- private static KeywordValidator buildKeyword(
- final Constructor extends KeywordValidator> constructor,
- final JsonNode node)
- throws ProcessingException
- {
- try {
- return constructor.newInstance(node);
- } catch (InstantiationException e) {
- throw new ProcessingException(ERRMSG, e);
- } catch (IllegalAccessException e) {
- throw new ProcessingException(ERRMSG, e);
- } catch (InvocationTargetException e) {
- throw new ProcessingException(ERRMSG, e);
- }
- }
-
@Override
public String toString()
{
diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java b/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java
index 9267950bb..4b79aa145 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java
@@ -31,7 +31,6 @@
import com.github.fge.jsonschema.core.tree.JsonTree;
import com.github.fge.jsonschema.core.tree.SchemaTree;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
-import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonValidator;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.jsonschema.processors.data.SchemaContext;
diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigester.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigester.java
index 722ea8ac7..67814ca95 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigester.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigester.java
@@ -59,14 +59,14 @@ public JsonNode digest(final JsonNode schema)
ArrayNode node;
node = FACTORY.arrayNode();
- ret.put("properties", node);
+ ret.set("properties", node);
set = Sets.newHashSet(schema.path("properties").fieldNames());
for (final String field: Ordering.natural().sortedCopy(set))
node.add(field);
node = FACTORY.arrayNode();
- ret.put("patternProperties", node);
+ ret.set("patternProperties", node);
set = Sets.newHashSet(schema.path("patternProperties").fieldNames());
for (final String field: Ordering.natural().sortedCopy(set))
diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java
index 91e63a10a..9ddc1f3bb 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
-import com.github.fge.jsonschema.core.util.RhinoHelper;
+import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -73,7 +73,7 @@ public Iterable selectSchemas(final String memberName)
list.add(PROPERTIES.append(memberName));
for (final String regex: patternProperties)
- if (RhinoHelper.regMatch(regex, memberName))
+ if (RegexECMA262Helper.regMatch(regex, memberName))
list.add(PATTERNPROPERTIES.append(regex));
if (!list.isEmpty())
diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationChain.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationChain.java
index bc4e4ad9e..061574aec 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationChain.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationChain.java
@@ -71,7 +71,7 @@ public ValidationChain(final RefResolver refResolver,
= ProcessorChain.startWith(refResolver).chainWith(syntaxProcessor);
resolver = new CachingProcessor, ValueHolder>(
- chain1.getProcessor(), SchemaHolderEquivalence.INSTANCE
+ chain1.getProcessor(), SchemaHolderEquivalence.INSTANCE, cfg.getCacheSize()
);
final SchemaDigester digester = new SchemaDigester(library);
@@ -86,7 +86,7 @@ public ValidationChain(final RefResolver refResolver,
}
builder = new CachingProcessor(
- chain2.getProcessor(), SchemaContextEquivalence.getInstance()
+ chain2.getProcessor(), SchemaContextEquivalence.getInstance(), cfg.getCacheSize()
);
}
diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java
index 0759cb87f..ea31f1730 100644
--- a/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java
+++ b/src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java
@@ -58,12 +58,6 @@
@ParametersAreNonnullByDefault
final class ValidationStack
{
- /*
- * Sentinel which is always the first element of the stack; we use it in
- * order to simplify the pop code.
- */
- private static final Element NULL_ELEMENT = new Element(null, null);
-
/*
* Queue of visited contexts
*/
diff --git a/src/main/javadoc/com/github/fge/jsonschema/cfg/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/cfg/package-info.java
deleted file mode 100644
index b261e929c..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/cfg/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Validation processor configuration classes
- *
- * The validation process can be influenced in two ways: how JSON Schemas
- * should be loaded and how validation should operate.
- *
- * Each of these ways is materialized by a pair of frozen/thawed instances.
- *
- */
-package com.github.fge.jsonschema.cfg;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example1.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example1.java
deleted file mode 100644
index 03921d559..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example1.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-
-/**
- * First example: basic usage
- *
- * link to source code
- *
- * This shows a basic usage example. The schema used for validation is
- * here, which conforms to draft v4, which is
- * the default version. You will notice that a JSON Pointer ({@code
- * #/definitions/mntent}) is used to address a subschema defining a mount entry.
- *
- *
- * This example uses {@link JsonSchemaFactory#byDefault()}, and uses
- * {@link JsonSchemaFactory#getJsonSchema(JsonNode)} to create the {@link
- * JsonSchema} instance.
- *
- * The first sample (here) validates
- * successfully.
- *
- * The second sample (here) fails to
- * validate. Please note that the failure occurs at the structural level
- * (required entry {@code swap} is missing). Validation therefore stops here,
- * and does not attempt to validate the {@code /} member of the instance, which
- * is itself invalid.
- *
- * The third sample (here) fails to
- * validate as well. This time, the problem is with the member values:
- *
- *
- * - the {@code options} member of {@code /tmp} is a string, but an array
- * is expected;
- * - the {@code /} member is missing the required {@code fstype} member.
- *
- *
- */
-public final class Example1
-{
- public static void main(final String... args)
- throws IOException, ProcessingException
- {
- final JsonNode fstabSchema = Utils.loadResource("/fstab.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 JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example10.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example10.java
deleted file mode 100644
index e3d6f3dbf..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example10.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder;
-import com.github.fge.jsonschema.core.ref.JsonRef;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-
-/**
- * Tenth example: registering schemas
- *
- * link to source code
- *
- * In this example, we register a custom schema with a given URI, and
- * initiate the {@link JsonSchema} instance using that URI. This is done by
- * customizing a {@link LoadingConfiguration} and registering schemas using
- * {@link LoadingConfigurationBuilder#preloadSchema(String, JsonNode)}.
- *
- * The only necessary condition for the URI is for it to be an absolute JSON
- * reference (see {@link JsonRef#isAbsolute()}), and you can register as many
- * schemas as you want. Here, we register both schemas from {@link Example5}.
- * You will notice that the scheme for these URIs is {@code xxx}: it does not
- * matter in the slightest that it is not a supported scheme by default, the
- * schema is registered all the same.
- *
- * This also shows that reference resolution still works in such a case,
- * since the {@code mntent} schema is referred to via a relative URI from the
- * {@code fstab} schema.
- *
- */
-public final class Example10
-{
- private static final String URI_BASE = "xxx://foo.bar/path/to/";
-
- public static void main(final String... args)
- throws IOException, ProcessingException
- {
- final LoadingConfigurationBuilder builder
- = LoadingConfiguration.newBuilder();
-
- JsonNode node;
- String uri;
-
- node = Utils.loadResource("/split/fstab.json");
- uri = URI_BASE + "fstab.json";
- builder.preloadSchema(uri, node);
-
- node = Utils.loadResource("/split/mntent.json");
- uri = URI_BASE + "mntent.json";
- builder.preloadSchema(uri, node);
-
- final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
- .setLoadingConfiguration(builder.freeze()).freeze();
-
- final JsonSchema schema
- = factory.getJsonSchema(URI_BASE + "fstab.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");
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example2.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example2.java
deleted file mode 100644
index 6a5ecf5ba..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example2.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.load.Dereferencing;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.main.JsonSchemaFactoryBuilder;
-
-import java.io.IOException;
-
-/**
- * Second example: inline schema addressing
- *
- * link to source code
- *
- * This example uses the same schema with one difference: the mntent
- * subschema is now referenced via inline addressing using an {@code id}.
- *
- * The schema used for validation is
- * here.
- *
- * In order to use inline schema addressing, we cannot use the default
- * factory: we must go through a {@link JsonSchemaFactoryBuilder} and use a
- * modified {@link LoadingConfiguration} to tell that we want to use inline
- * dereferencing.
- *
- * Apart from these, the files used for validation and validation results
- * are the same as {@link Example1}.
- *
- * @see Dereferencing
- */
-public final class Example2
-{
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example3.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example3.java
deleted file mode 100644
index a703eb68a..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example3.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-
-/**
- * Third example: draft v3 detection via {@code $schema}
- *
- * link to source code
- *
- * This shows a basic usage example. This is the same source code as for
- * {@link Example1}, except this time the schema (here) conforms to draft v3 instead of
- * draft v4 (the {@code $schema} value differs).
- *
- * One thing to note is a difference in the validation messages: while
- * required properties are described using the {@code required} keyword, with
- * draft v3, they were in charge of the {@code properties} keyword.
- */
-public final class Example3
-{
- public static void main(final String... args)
- throws IOException, ProcessingException
- {
- final JsonNode fstabSchema = Utils.loadResource("/fstab-draftv3.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 JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example4.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example4.java
deleted file mode 100644
index bd8e01e59..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example4.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-
-/**
- * Fourth example: schema loading via URIs, and subschema addressing
- *
- * link to source code
- *
- * link to schema
- *
- * This demonstrates two capabilities of {@link JsonSchemaFactory}:
- *
- *
- * - the ability to Utils.load schemas via URIs;
- * - the ability to address subschemas in a schema.
- *
- *
- * The implementation provides a {@code resource} scheme which allows to Utils.load
- * JSON from files in the classpath. It is strictly equivalent to calling {@link
- * Class#getResourceAsStream(String)}.
- *
- * The URI used is {@code
- * resource:/org/eel/kitchen/jsonschema/examples/fstab-sub.json}. Because we
- * want to validate against the {@code fstab} subschema, we use {@link
- * JsonSchemaFactory#getJsonSchema(String)} to Utils.load the actual schema; the URI
- * used as an argument also has a JSON Pointer as a fragment.
- *
- * Files validated, and the validation outputs, are the same as for {@link
- * Example2}.
- */
-public final class Example4
-{
- private static final String SCHEMA_URI
- = "resource:/com/github/fge/jsonschema/examples/fstab-sub.json#/fstab";
-
- 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 JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
-
- final JsonSchema schema = factory.getJsonSchema(SCHEMA_URI);
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example5.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example5.java
deleted file mode 100644
index 1ba94ffc0..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example5.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.load.SchemaLoader;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder;
-import com.github.fge.jsonschema.core.load.uri.URITranslatorConfiguration;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.main.JsonSchemaFactoryBuilder;
-
-import java.io.IOException;
-
-/**
- * Fifth example: setting a URI namespace; relative URI resolution
- *
- * link to source code
- *
- * This example demonstrates another capability of {@link JsonSchemaFactory}:
- * the ability to set a URI namespace. This requires to customize the factory,
- * and therefore go through {@link JsonSchemaFactoryBuilder} again.
- *
- * In order to set a URI namespace, we must grab a {@link
- * LoadingConfigurationBuilder}, set the namespace, freeze it, and pass it to
- * the factory builder and then freeze the factory.
- *
- * The net effect is that all schema loading done by {@link SchemaLoader}
- * will now resolve against this namespace, and this includes arguments to
- * {@link JsonSchemaFactory#getJsonSchema(String)}.
- *
- * The schemas are split in two:
- *
- *
- * - one describing fstab: here;
- *
- * - another describing an entry:
- * here.
- *
- *
- * The first refers to the second one via the relative URI {@code
- * mntent.json}. This works precisely because a URI namespace has been set: all
- * URIs are resolved against this namespace.
- *
- * Files validated, and the validation outputs, are the same as for {@link
- * Example2}.
- */
-public final class Example5
-{
- private static final String NAMESPACE
- = "resource:/com/github/fge/jsonschema/examples/split/";
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example6.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example6.java
deleted file mode 100644
index 464b59caf..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example6.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder;
-import com.github.fge.jsonschema.core.load.uri.URITranslatorConfiguration;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-
-/**
- * Sixth example: URI redirection
- *
- * link to source code
- *
- * In this example, the same schema file is used as in {@link Example1}. This
- * time, though, it is assumed that the base URI used for addressing this schema
- * is {@code http://my.site/schemas/fstab.json#}. But instead of trying to
- * fetch it from the web directly, we want to use the local copy, which is
- * located under URI {@code
- * resource:/org/eel/kitchen/jsonschema/examples/fstab.json#}.
- *
- * The solution is here again to build a custom {@link LoadingConfiguration},
- * which allows to add schema redirections (using {@link
- * LoadingConfigurationBuilder#addSchemaRedirect(String, String)}. This method
- * can be called for as many schemas as you wish to redirect.
- *
- * The effect is that if you required a schema via URI {@code
- * http://my.site/schemas/fstab.json#}, it will silently transform this URI into
- * {@code resource:/org/eel/kitchen/jsonschema/examples/fstab.json#}
- * internally.
- *
- * Note that URIs must be absolute JSON references (see {@link JsonRef}).
- */
-public final class Example6
-{
- private static final String FROM = "http://my.site/schemas/fstab.json#";
- private static final String TO
- = "resource:/com/github/fge/jsonschema/examples/fstab.json#";
-
- 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);
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example7.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example7.java
deleted file mode 100644
index f281a870c..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example7.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration;
-import com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder;
-import com.github.fge.jsonschema.core.load.download.URIDownloader;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-
-/**
- * Seventh example: custom URI scheme
- *
- * link to source code
- *
- * This demonstrates {@link JsonSchemaFactory}'s ability to register a
- * custom URI scheme. In this example, the scheme is {@code foobar}, and it is
- * simply an alias to fetch a resource from the current package.
- *
- * Two things are needed:
- *
- *
- * - an implementation of {@link URIDownloader} for this scheme,
- * - registering this scheme using {@link
- * LoadingConfigurationBuilder#addScheme(String, URIDownloader)}.
- *
- *
- * Once this is done, this scheme, when encountered anywhere in JSON
- * References, will use this downloader, and you are also able to use it when
- * loading schemas using {@link JsonSchemaFactory#getJsonSchema(String)}, which
- * is what this example does.
- *
- * The schema and files used are the same as for {@link Example2}.
- */
-public final class Example7
-{
- 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);
- }
-
- private static final class CustomDownloader
- implements URIDownloader
- {
- private static final String PREFIX;
- private static final URIDownloader INSTANCE = new CustomDownloader();
-
- static {
- final String pkgname = CustomDownloader.class.getPackage()
- .getName();
- PREFIX = '/' + pkgname.replace(".", "/");
- }
-
- public static URIDownloader getInstance()
- {
- return INSTANCE;
- }
-
- @Override
- public InputStream fetch(final URI source)
- throws IOException
- {
- final String path = PREFIX + source.getPath();
- final InputStream ret = getClass().getResourceAsStream(path);
-
- if (ret == null)
- throw new IOException("resource " + path + " not found");
- return ret;
- }
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example8.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example8.java
deleted file mode 100644
index a6d6f0b9f..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example8.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.NodeType;
-import com.github.fge.jsonschema.cfg.ValidationConfiguration;
-import com.github.fge.jsonschema.cfg.ValidationConfigurationBuilder;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.format.AbstractFormatAttribute;
-import com.github.fge.jsonschema.format.FormatAttribute;
-import com.github.fge.jsonschema.library.DraftV4Library;
-import com.github.fge.jsonschema.library.Library;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
-import com.github.fge.jsonschema.processors.data.FullData;
-import com.github.fge.msgsimple.bundle.MessageBundle;
-import com.github.fge.msgsimple.load.MessageBundles;
-import com.github.fge.msgsimple.source.MapMessageSource;
-import com.github.fge.msgsimple.source.MessageSource;
-
-import java.io.IOException;
-import java.util.UUID;
-
-/**
- * Eighth example: augmenting schemas with custom format attributes
- *
- * link to source code
- *
- * link to schema
- *
- * This example adds a custom format attribute named {@code uuid}, which
- * checks whether a string instance is a valid UUID.
- *
- * For this, you need to write an implementation of {@link FormatAttribute},
- * registering it in a {@link Library}, and feed that library to a {@link
- * ValidationConfiguration} which you submit to the {@link JsonSchemaFactory}.
- *
- *
- * Here, we choose to augment the draft v4 library, which we get hold of
- * using {@link DraftV4Library#get()}; we thaw it, add the new attribute and
- * freeze it again. We also choose to make this new library the default by
- * using {@link
- * ValidationConfigurationBuilder#setDefaultLibrary(String, Library)}.
- *
- * Note also that the schema has no {@code $schema} defined; as a result, the
- * default library is used (it is not recommended to omit {@code $schema}
- * in your schemas, however).
- *
- * Two sample files are given: the first (link) is valid, the other (link) isn't (the provided {@code id}
- * for the second array element is invalid).
- */
-public final class Example8
-{
- public static void main(final String... args)
- throws IOException, ProcessingException
- {
- final JsonNode customSchema = Utils.loadResource("/custom-fmt.json");
- final JsonNode good = Utils.loadResource("/custom-fmt-good.json");
- final JsonNode bad = Utils.loadResource("/custom-fmt-bad.json");
-
- /*
- * Build a new library with our added format attribute
- */
- final Library library = DraftV4Library.get().thaw()
- .addFormatAttribute("uuid", UUIDFormatAttribute.getInstance())
- .freeze();
-
- /*
- * Build a new message bundle with our added error message
- */
- final String key = "invalidUUID";
- final String value = "input is not a valid UUID";
- final MessageSource source = MapMessageSource.newBuilder()
- .put(key, value).build();
- final MessageBundle bundle
- = MessageBundles.getBundle(JsonSchemaValidationBundle.class)
- .thaw().appendSource(source).freeze();
-
- /*
- * Build our dedicated validation configuration
- */
- final ValidationConfiguration cfg = ValidationConfiguration.newBuilder()
- .setDefaultLibrary("http://my.site/myschema#", library)
- .setValidationMessages(bundle).freeze();
-
- final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
- .setValidationConfiguration(cfg).freeze();
-
- final JsonSchema schema = factory.getJsonSchema(customSchema);
-
- ProcessingReport report;
-
- report = schema.validate(good);
- System.out.println(report);
-
- report = schema.validate(bad);
- System.out.println(report);
- }
-
- private static final class UUIDFormatAttribute
- extends AbstractFormatAttribute
- {
- private static final FormatAttribute INSTANCE
- = new UUIDFormatAttribute();
-
- private UUIDFormatAttribute()
- {
- super("uuid", NodeType.STRING);
- }
-
- public static FormatAttribute getInstance()
- {
- return INSTANCE;
- }
-
- @Override
- public void validate(final ProcessingReport report,
- final MessageBundle bundle, final FullData data)
- throws ProcessingException
- {
- final String value = data.getInstance().getNode().textValue();
- try {
- UUID.fromString(value);
- } catch (IllegalArgumentException ignored) {
- report.error(newMsg(data, bundle, "invalidUUID")
- .put("input", value));
- }
- }
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example9.java b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example9.java
deleted file mode 100644
index df3714f3d..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/Example9.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-package com.github.fge.jsonschema.examples;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jackson.NodeType;
-import com.github.fge.jackson.jsonpointer.JsonPointer;
-import com.github.fge.jsonschema.cfg.ValidationConfiguration;
-import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.keyword.syntax.checkers.AbstractSyntaxChecker;
-import com.github.fge.jsonschema.core.keyword.syntax.checkers.SyntaxChecker;
-import com.github.fge.jsonschema.core.processing.Processor;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
-import com.github.fge.jsonschema.core.tree.SchemaTree;
-import com.github.fge.jsonschema.keyword.digest.AbstractDigester;
-import com.github.fge.jsonschema.keyword.digest.Digester;
-import com.github.fge.jsonschema.keyword.digest.helpers.IdentityDigester;
-import com.github.fge.jsonschema.keyword.digest.helpers.SimpleDigester;
-import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
-import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
-import com.github.fge.jsonschema.library.DraftV4Library;
-import com.github.fge.jsonschema.library.Keyword;
-import com.github.fge.jsonschema.library.KeywordBuilder;
-import com.github.fge.jsonschema.library.Library;
-import com.github.fge.jsonschema.library.LibraryBuilder;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
-import com.github.fge.jsonschema.processors.data.FullData;
-import com.github.fge.msgsimple.bundle.MessageBundle;
-import com.github.fge.msgsimple.load.MessageBundles;
-import com.github.fge.msgsimple.source.MapMessageSource;
-import com.github.fge.msgsimple.source.MessageSource;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-
-/**
- * Ninth example: augmenting schemas with custom keywords
- *
- * link to source code
- *
- * link to schema
- *
- * This example adds a custom keyword with syntax checking, digesting and
- * keyword validation. The chosen keyword is {@code divisors}: it applies to
- * integer values and takes an array of (unique) integers as an argument.
- *
- * The validation is the same as for {@code multipleOf} except that it is
- * restricted to integer values and the instance must be a multiple of all
- * divisors. For instance, if the value of this keyword is {@code [2, 3]}, then
- * 6 validates successfully but 14 does not (it is divisible by 2 but not 3).
- *
- *
- * For this, you need to create your own keyword. This is done using {@link
- * Keyword#newBuilder(String)}, where the argument is the name of your keyword,
- * and then add the following elements:
- *
- *
- * - a {@link SyntaxChecker} (using {@link
- * KeywordBuilder#withSyntaxChecker(SyntaxChecker)};
- * - a {@link Digester} (using {@link
- * KeywordBuilder#withDigester(Digester)};
- * - and finally, a {@link KeywordValidator} (using {@link
- * KeywordBuilder#withValidatorClass(Class)}.
- *
- *
- * Then, as in {@link Example8}, you need to get hold of a {@link Library}
- * (we choose again to extend the draft v4 library) and add the (frozen)
- * keyword to it using {@link LibraryBuilder#addKeyword(Keyword)}.
- *
- * The keyword validator must have a single constructor taking a
- * {@link JsonNode} as an argument (which will be the result of the {@link
- * Digester}). Note that you may omit to write a digester and choose instead to
- * use an {@link IdentityDigester} or a {@link SimpleDigester} (which you inject
- * into a keyword using {@link
- * KeywordBuilder#withIdentityDigester(NodeType, NodeType...)} and {@link
- * KeywordBuilder#withSimpleDigester(NodeType, NodeType...)} respectively).
- *
- * Two sample files are given: the first (link) is valid, the other (link) isn't (the first and third
- * elements fail to divide by one or more factors).
- */
-public final class Example9
-{
- public static void main(final String... args)
- throws IOException, ProcessingException
- {
- final JsonNode customSchema = Utils.loadResource("/custom-keyword.json");
- final JsonNode good = Utils.loadResource("/custom-keyword-good.json");
- final JsonNode bad = Utils.loadResource("/custom-keyword-bad.json");
-
- /*
- * Build the new keyword
- */
- final Keyword keyword = Keyword.newBuilder("divisors")
- .withSyntaxChecker(DivisorsSyntaxChecker.getInstance())
- .withDigester(DivisorsDigesters.getInstance())
- .withValidatorClass(DivisorsKeywordValidator.class).freeze();
-
- /*
- * Build a library, based on the v4 library, with this new keyword
- */
- final Library library = DraftV4Library.get().thaw()
- .addKeyword(keyword).freeze();
-
- /*
- * Complement the validation message bundle with a dedicated message
- * for our keyword validator
- */
- final String key = "missingDivisors";
- final String value = "integer value is not a multiple of all divisors";
- final MessageSource source = MapMessageSource.newBuilder()
- .put(key, value).build();
- final MessageBundle bundle
- = MessageBundles.getBundle(JsonSchemaValidationBundle.class)
- .thaw().appendSource(source).freeze();
-
- /*
- * Build a custom validation configuration: add our custom library and
- * message bundle
- */
- final ValidationConfiguration cfg = ValidationConfiguration.newBuilder()
- .setDefaultLibrary("http://my.site/myschema#", library)
- .setValidationMessages(bundle).freeze();
-
- final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
- .setValidationConfiguration(cfg).freeze();
-
- final JsonSchema schema = factory.getJsonSchema(customSchema);
-
- ProcessingReport report;
-
- report = schema.validate(good);
- System.out.println(report);
-
- report = schema.validate(bad);
- System.out.println(report);
- }
-
- /*
- * Our custom syntax checker
- */
- private static final class DivisorsSyntaxChecker
- extends AbstractSyntaxChecker
- {
- private static final SyntaxChecker INSTANCE
- = new DivisorsSyntaxChecker();
-
- public static SyntaxChecker getInstance()
- {
- return INSTANCE;
- }
-
- private DivisorsSyntaxChecker()
- {
- /*
- * When constructing, the name for the keyword must be provided
- * along with the allowed type for the value (here, an array).
- */
- super("divisors", NodeType.ARRAY);
- }
-
- @Override
- protected void checkValue(final Collection pointers,
- final MessageBundle bundle, final ProcessingReport report,
- final SchemaTree tree)
- throws ProcessingException
- {
- /*
- * Using AbstractSyntaxChecker as a base, we know that when we reach
- * this method, the value has already been validated as being of
- * the allowed primitive types (only array here).
- *
- * But this is not enough for this particular validator: we must
- * also ensure that all elements of this array are integers. Cycle
- * through all elements of the array and check each element. If we
- * encounter a non integer argument, add a message.
- *
- * We must also check that there is at lease one element, that the
- * array contains no duplicates and that all elements are positive
- * integers and strictly greater than 0.
- *
- * The getNode() method grabs the value of this keyword for us, so
- * use that. Note that we also reuse some messages already defined
- * in SyntaxMessages.
- */
- final JsonNode node = getNode(tree);
-
- final int size = node.size();
-
- if (size == 0) {
- report.error(newMsg(tree, bundle, "emptyArray"));
- return;
- }
-
- NodeType type;
- JsonNode element;
- boolean uniqueItems = true;
-
- final Set set = Sets.newHashSet();
-
- for (int index = 0; index < size; index++) {
- element = node.get(index);
- type = NodeType.getNodeType(element);
- if (type != NodeType.INTEGER)
- report.error(newMsg(tree, bundle, "incorrectElementType")
- .put("expected", NodeType.INTEGER)
- .put("found", type));
- else if (element.bigIntegerValue().compareTo(BigInteger.ONE) < 0)
- report.error(newMsg(tree, bundle, "integerIsNegative")
- .put("value", element));
- uniqueItems = set.add(element);
- }
-
- if (!uniqueItems)
- report.error(newMsg(tree, bundle, "elementsNotUnique"));
- }
- }
-
- /*
- * Our custom digester
- *
- * We take the opportunity to build a digested form where, for instance,
- * [ 3, 5 ] and [ 5, 3 ] give the same digest.
- */
- private static final class DivisorsDigesters
- extends AbstractDigester
- {
- private static final Digester INSTANCE = new DivisorsDigesters();
-
- public static Digester getInstance()
- {
- return INSTANCE;
- }
-
- private DivisorsDigesters()
- {
- super("divisors", NodeType.INTEGER);
- }
-
- @Override
- public JsonNode digest(final JsonNode schema)
- {
- final SortedSet set = Sets.newTreeSet(COMPARATOR);
- for (final JsonNode element: schema.get(keyword))
- set.add(element);
-
- return FACTORY.arrayNode().addAll(set);
- }
-
- /*
- * Custom Comparator. We compare BigInteger values, since all integers
- * are representable using this class.
- */
- private static final Comparator COMPARATOR
- = new Comparator()
- {
- @Override
- public int compare(final JsonNode o1, final JsonNode o2)
- {
- return o1.bigIntegerValue().compareTo(o2.bigIntegerValue());
- }
- };
- }
-
-
- /**
- * Custom keyword validator for {@link Example9}
- *
- * It must be {@code public} because it is built by reflection.
- */
- public static final class DivisorsKeywordValidator
- extends AbstractKeywordValidator
- {
- /*
- * We want to validate arbitrarily large integer values, we therefore
- * use BigInteger.
- */
- private final List divisors;
-
- public DivisorsKeywordValidator(final JsonNode digest)
- {
- super("divisors");
-
- final ImmutableList.Builder list
- = ImmutableList.builder();
-
- for (final JsonNode element: digest)
- list.add(element.bigIntegerValue());
-
- divisors = list.build();
- }
-
- @Override
- public void validate(final Processor processor,
- final ProcessingReport report, final MessageBundle bundle,
- final FullData data)
- throws ProcessingException
- {
- final BigInteger value
- = data.getInstance().getNode().bigIntegerValue();
- /*
- * We use a plain list to store failed divisors: remember that the
- * digested form was built with divisors in order, we therefore
- * only need insertion order, and a plain ArrayList guarantees that.
- */
- final List failed = Lists.newArrayList();
-
- for (final BigInteger divisor: divisors)
- if (!value.mod(divisor).equals(BigInteger.ZERO))
- failed.add(divisor);
-
- if (failed.isEmpty())
- return;
-
- /*
- * There are missed divisors: report.
- */
- report.error(newMsg(data, bundle, "missingDivisors")
- .put("divisors", divisors).put("failed", failed));
- }
-
- @Override
- public String toString()
- {
- return "divisors: " + divisors;
- }
- }
-}
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-bad.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-bad.json
deleted file mode 100644
index 5359f2b19..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-bad.json
+++ /dev/null
@@ -1,10 +0,0 @@
-[
- {
- "id": "5aacaa7e-15f5-4798-9857-7c34a0d8fda0",
- "name": "foo"
- },
- {
- "id": "not-an-uuid",
- "name": "bar"
- }
-]
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-good.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-good.json
deleted file mode 100644
index ec4be97d5..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt-good.json
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {
- "id": "5aacaa7e-15f5-4798-9857-7c34a0d8fda0",
- "name": "foo"
- }
-]
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt.json
deleted file mode 100644
index f872d1c2c..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-fmt.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "title": "custom format attribute demonstration",
- "type": "array",
- "items": {
- "type": "object",
- "required": [ "id", "name" ],
- "properties": {
- "id": {
- "type": "string",
- "format": "uuid"
- },
- "name": {
- "type": "string"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-bad.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-bad.json
deleted file mode 100644
index 07dc92425..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-bad.json
+++ /dev/null
@@ -1 +0,0 @@
-[ 3, 12, 17 ]
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-good.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-good.json
deleted file mode 100644
index f5b341927..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword-good.json
+++ /dev/null
@@ -1 +0,0 @@
-[ 6, 12, 90 ]
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword.json
deleted file mode 100644
index 85c4ff243..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/custom-keyword.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "type": "array",
- "items": {
- "type": "integer",
- "divisors": [ 2, 3 ]
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad.json
deleted file mode 100644
index bd4e47097..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "/": {
- "fstype": "btrfs",
- "options": [ "ssd" ]
- },
- "/tmp": {
- "device": "tmpfs",
- "fstype": "tmpfs",
- "options": [ "size=64M" ]
- },
- "/var/lib/mysql": {
- "device": "/dev/data/mysql",
- "fstype": "btrfs"
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad2.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad2.json
deleted file mode 100644
index 743676d52..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-bad2.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "/": {
- "device": "/dev/sda1",
- "options": [ "ssd" ]
- },
- "swap": {
- "device": "/dev/sda2",
- "fstype": "swap"
- },
- "/tmp": {
- "device": "tmpfs",
- "fstype": "tmpfs",
- "options": "size=64M"
- },
- "/var/lib/mysql": {
- "device": "/dev/data/mysql",
- "fstype": "btrfs"
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-draftv3.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-draftv3.json
deleted file mode 100644
index 597df1b89..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-draftv3.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-03/schema#",
- "title": "/etc/fstab",
- "description": "JSON representation of /etc/fstab",
- "type": "object",
- "properties": {
- "/": {
- "required": true,
- "$ref": "#/definitions/mntent"
- },
- "swap": {
- "required": true,
- "$ref": "#/definitions/mntent"
- }
- },
- "patternProperties": {
- "^/[^/]+(/[^/]+)*$": {
- "$ref": "#/definitions/mntent"
- }
- },
- "additionalProperties": false,
- "definitions": {
- "mntent": {
- "title": "mntent",
- "description": "An fstab entry",
- "type": "object",
- "properties": {
- "device": {
- "type": "string",
- "required": true
- },
- "fstype": {
- "type": "string",
- "required": true
- },
- "options": {
- "type": "array",
- "minItems": 1,
- "items": { "type": "string" }
- },
- "dump": {
- "type": "integer",
- "minimum": 0
- },
- "fsck": {
- "type": "integer",
- "minimum": 0
- }
- },
- "additionalItems": false
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-good.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-good.json
deleted file mode 100644
index 6367c4335..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-good.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "/": {
- "device": "/dev/sda1",
- "fstype": "btrfs",
- "options": [ "ssd" ]
- },
- "swap": {
- "device": "/dev/sda2",
- "fstype": "swap"
- },
- "/tmp": {
- "device": "tmpfs",
- "fstype": "tmpfs",
- "options": [ "size=64M" ]
- },
- "/var/lib/mysql": {
- "device": "/dev/data/mysql",
- "fstype": "btrfs"
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-inline.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-inline.json
deleted file mode 100644
index 743b677e3..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-inline.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "title": "/etc/fstab",
- "description": "JSON representation of /etc/fstab",
- "type": "object",
- "required": [ "/", "swap" ],
- "properties": {
- "swap": {
- "$ref": "#mntent"
- }
- },
- "patternProperties": {
- "^/[^/]+(/[^/]+)*$": {
- "$ref": "#mntent"
- }
- },
- "additionalProperties": false,
- "definitions": {
- "mntent": {
- "title": "mntent",
- "description": "An fstab entry",
- "type": "object",
- "properties": {
- "device": {
- "type": "string"
- },
- "fstype": {
- "type": "string"
- },
- "options": {
- "type": "array",
- "minItems": 1,
- "items": { "type": "string" }
- },
- "dump": {
- "type": "integer",
- "minimum": 0
- },
- "fsck": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": [ "device", "fstype" ],
- "additionalItems": false
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-sub.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-sub.json
deleted file mode 100644
index 3c4cc2568..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab-sub.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "title": "/etc/fstab",
- "description": "JSON representation of /etc/fstab",
- "fstab": {
- "type": "object",
- "properties": {
- "swap": {
- "$ref": "#/mntent"
- }
- },
- "patternProperties": {
- "^/([^/]+(/[^/]+)*)?$": {
- "$ref": "#/mntent"
- }
- },
- "required": [ "/", "swap" ],
- "additionalProperties": false
- },
- "mntent": {
- "title": "mntent",
- "description": "An fstab entry",
- "type": "object",
- "properties": {
- "device": {
- "type": "string"
- },
- "fstype": {
- "type": "string"
- },
- "options": {
- "type": "array",
- "minItems": 1,
- "items": { "type": "string" }
- },
- "dump": {
- "type": "integer",
- "minimum": 0
- },
- "fsck": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": [ "device", "fstype" ],
- "additionalItems": false
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab.json
deleted file mode 100644
index ff4f8d702..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/fstab.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "title": "/etc/fstab",
- "description": "JSON representation of /etc/fstab",
- "type": "object",
- "properties": {
- "swap": {
- "$ref": "#/definitions/mntent"
- }
- },
- "patternProperties": {
- "^/([^/]+(/[^/]+)*)?$": {
- "$ref": "#/definitions/mntent"
- }
- },
- "required": [ "/", "swap" ],
- "additionalProperties": false,
- "definitions": {
- "mntent": {
- "title": "mntent",
- "description": "An fstab entry",
- "type": "object",
- "properties": {
- "device": {
- "type": "string"
- },
- "fstype": {
- "type": "string"
- },
- "options": {
- "type": "array",
- "minItems": 1,
- "items": { "type": "string" }
- },
- "dump": {
- "type": "integer",
- "minimum": 0
- },
- "fsck": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": [ "device", "fstype" ],
- "additionalItems": false
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/fstab.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/fstab.json
deleted file mode 100644
index c99ec3d3d..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/fstab.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "title": "/etc/fstab",
- "description": "JSON representation of /etc/fstab",
- "type": "object",
- "properties": {
- "swap": {
- "$ref": "mntent.json"
- }
- },
- "patternProperties": {
- "^/([^/]+(/[^/]+)*)?$": {
- "$ref": "mntent.json"
- }
- },
- "required": [ "/", "swap" ],
- "additionalProperties": false
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/mntent.json b/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/mntent.json
deleted file mode 100644
index 76066d052..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/doc-files/split/mntent.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "$schema": "http://json-schema.org/draft-04/schema#",
- "title": "mntent",
- "description": "An fstab entry",
- "type": "object",
- "properties": {
- "device": {
- "type": "string"
- },
- "fstype": {
- "type": "string"
- },
- "options": {
- "type": "array",
- "minItems": 1,
- "items": { "type": "string" }
- },
- "dump": {
- "type": "integer",
- "minimum": 0
- },
- "fsck": {
- "type": "integer",
- "minimum": 0
- }
- },
- "required": [ "device", "fstype" ],
- "additionalItems": false
-}
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/examples/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/examples/package-info.java
deleted file mode 100644
index adf1fa876..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/examples/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * API usage examples
- *
- * This package contains examples on how to use all features of this API
- * (including augmenting schemas, URI redirections etc).
- *
- * All examples have a {@code main()} program, so you may run them and see
- * the output. Suggestions welcome.
- */
-package com.github.fge.jsonschema.examples;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/exceptions/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/exceptions/package-info.java
deleted file mode 100644
index b824ae488..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/exceptions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Validation processing exceptions
- */
-package com.github.fge.jsonschema.exceptions;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/exceptions/unchecked/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/exceptions/unchecked/package-info.java
deleted file mode 100644
index 3303e7cec..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/exceptions/unchecked/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Validation processing configuration error exceptions (unchecked)
- */
-package com.github.fge.jsonschema.exceptions.unchecked;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/format/common/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/format/common/package-info.java
deleted file mode 100644
index 3288968a4..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/format/common/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Common format attribute classes for draft v3 and draft v4
- */
-
-package com.github.fge.jsonschema.format.common;
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/format/draftv4/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/format/draftv4/package-info.java
deleted file mode 100644
index 96c32619d..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/format/draftv4/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Format attributes specific to draft v4
- */
-
-package com.github.fge.jsonschema.format.draftv4;
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/format/helpers/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/format/helpers/package-info.java
deleted file mode 100644
index 486c6894d..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/format/helpers/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Helper classes for format attributes
- *
- * The one you may want to reuse is {@link
- * com.github.fge.jsonschema.format.helpers.AbstractDateFormatAttribute}, which
- * can be used to validate any date format using Joda Time's {@link
- * org.joda.time.format.DateTimeFormat}.
- */
-package com.github.fge.jsonschema.format.helpers;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/format/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/format/package-info.java
deleted file mode 100644
index b2e51fb74..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/format/package-info.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Format attribute base classes
- *
- * The {@code format} keyword plays a particular role in JSON Schema
- * validation, since it is the only keyword performing semantic validation.
- * Note that supporting it is optional, and that implementations are
- * asked to provide a way to deactivate format checking on demand. This
- * implementation offers this option.
- *
- * Draft v4 defines a narrower subset of format attributes than draft v3.
- * The following format attributes are common to both draft v3 and draft v4:
- *
- *
- * - {@code date-time};
- * - {@code email};
- * - {@code host-name};
- * - {@code ipv6};
- * - {@code regex};
- * - {@code uri}.
- *
- *
- * Draft v3 defines the following additional attributes:
- *
- *
- * - {@code date};
- * - {@code phone};
- * - {@code time};
- * - {@code utc-millisec};
- * - {@code color} (unsupported);
- * - {@code style} (unsupported).
- *
- *
- * Additionally, there is an attribute named {@code ip-address} in draft v3,
- * and {@code ipv4} in draft v4, which can validate IPv4 addresses.
- */
-
-package com.github.fge.jsonschema.format;
\ No newline at end of file
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/common/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/common/package-info.java
deleted file mode 100644
index 631249fbb..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/common/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Digesters common to both draft v3 and draft v4
- */
-
-package com.github.fge.jsonschema.keyword.digest.common;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv3/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv3/package-info.java
deleted file mode 100644
index 886e4efaa..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv3/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Digesters specific to draft v3
- */
-
-package com.github.fge.jsonschema.keyword.digest.draftv3;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv4/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv4/package-info.java
deleted file mode 100644
index 146fd5ccd..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/draftv4/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Digesters specific to draft v4
- */
-
-package com.github.fge.jsonschema.keyword.digest.draftv4;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/helpers/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/helpers/package-info.java
deleted file mode 100644
index f4572d207..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/helpers/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Digester helper classes
- */
-
-package com.github.fge.jsonschema.keyword.digest.helpers;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/package-info.java
deleted file mode 100644
index dc7e7de2b..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/digest/package-info.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword digesters
- *
- * Digesters play two important roles:
- *
- *
- * - they detect similar schemas for a given keyword, and produce the same
- * output in this case;
- * - they provide to later elements in the validation chain the list of
- * types validated by a keyword.
- *
- *
- * The first item has two advantages: not only is the library's memory
- * footprint reduced, it also allows a great simplification of keyword
- * constructors.
- */
-
-package com.github.fge.jsonschema.keyword.digest;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/package-info.java
deleted file mode 100644
index 2ed1ac316..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/package-info.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword syntax checkers, digesters and validators
- *
- * One schema keyword consists, apart from its name, of three elements:
- *
- *
- * - a {@link com.github.fge.jsonschema.keyword.syntax.SyntaxChecker}
- * which checks whether the keyword has the correct syntax in a JSON schema;
- *
- * - a {@link com.github.fge.jsonschema.keyword.digest.Digester} which
- * digests the schema for a specific keyword so as to use a more efficient
- * form when building the validator;
- * - a {@link
- * com.github.fge.jsonschema.keyword.validator.KeywordValidator} which
- * validates an instance against the schema.
- *
- *
- * All these elements are run in this order. Note that keyword validators
- * are always built by reflection. You can create your own custom keyword by
- * providing its name and these three elements wrapped into a {@link
- * com.github.fge.jsonschema.library.Keyword} to inject into a {@link
- * com.github.fge.jsonschema.library.Library}, which you will then submit to a
- * {@link com.github.fge.jsonschema.cfg.ValidationConfiguration}.
- */
-
-package com.github.fge.jsonschema.keyword;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/common/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/common/package-info.java
deleted file mode 100644
index d76589ab2..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/common/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword validators common to both draft v3 and draft v4
- */
-
-package com.github.fge.jsonschema.keyword.validator.common;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv3/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv3/package-info.java
deleted file mode 100644
index 3b60ba53c..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv3/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword validators specific to draft v3
- */
-
-package com.github.fge.jsonschema.keyword.validator.draftv3;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv4/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv4/package-info.java
deleted file mode 100644
index f99fd6443..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/draftv4/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword validators specific to draft v4
- */
-
-package com.github.fge.jsonschema.keyword.validator.draftv4;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/helpers/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/helpers/package-info.java
deleted file mode 100644
index de55c0b8a..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/helpers/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword validator helper classes
- */
-
-package com.github.fge.jsonschema.keyword.validator.helpers;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/package-info.java
deleted file mode 100644
index 66684e2fd..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/keyword/validator/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword validators
- *
- * These are the actual validators of user data.
- *
- * Keywords are built by reflection, with a digested form of schemas
- * (produced by a {@link com.github.fge.jsonschema.keyword.digest.Digester}) as
- * the only constructor argument.
- */
-
-package com.github.fge.jsonschema.keyword.validator;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/library/digest/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/library/digest/package-info.java
deleted file mode 100644
index d55b5d689..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/library/digest/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Dictionaries of builtin {@link
- * com.github.fge.jsonschema.keyword.digest.Digester}s
- */
-package com.github.fge.jsonschema.library.digest;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/library/format/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/library/format/package-info.java
deleted file mode 100644
index 9b55bbc4f..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/library/format/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Dictionaries of builtin {@link
- * com.github.fge.jsonschema.format.FormatAttribute}s
- */
-package com.github.fge.jsonschema.library.format;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/library/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/library/package-info.java
deleted file mode 100644
index 336b7245f..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/library/package-info.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Schema keyword libraries
- *
- * A {@link com.github.fge.jsonschema.library.Library} contains a set of
- * keywords and all elements related to them (syntax validators, digesters and
- * validator classes), along with format attributes.
- *
- * Libraries are immutable, but you can obtain a thawed copy of them in
- * which you can inject new keywords and format attributes (or remove existing
- * ones).
- *
- * The two predefined libraries are the draft v4 core schema library and the
- * draft v3 core schema library.
- */
-package com.github.fge.jsonschema.library;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/library/validator/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/library/validator/package-info.java
deleted file mode 100644
index 34a7accb5..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/library/validator/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Dictionaries of builtin {@link
- * com.github.fge.jsonschema.keyword.validator.KeywordValidator} constructors
- */
-package com.github.fge.jsonschema.library.validator;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/main/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/main/package-info.java
deleted file mode 100644
index c1c79a979..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/main/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Main interface to validation
- *
- * This package contains wrapper classes over validation processors.
- *
- * The main provider is {@link
- * com.github.fge.jsonschema.main.JsonSchemaFactory}: from this class, you can
- * obtain a {@link com.github.fge.jsonschema.processors.syntax.SyntaxValidator},
- * a {@link com.github.fge.jsonschema.main.JsonValidator} or a {@link
- * com.github.fge.jsonschema.main.JsonSchema}.
- */
-package com.github.fge.jsonschema.main;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/messages/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/messages/package-info.java
deleted file mode 100644
index ad723d114..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/messages/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Messages used by exceptions
- */
-package com.github.fge.jsonschema.messages;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/build/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/build/package-info.java
deleted file mode 100644
index b68cf7b61..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/build/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Keyword builder processor
- *
- * @see com.github.fge.jsonschema.keyword.validator.KeywordValidator
- */
-package com.github.fge.jsonschema.processors.build;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/data/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/data/package-info.java
deleted file mode 100644
index 4c01c9747..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/data/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Inputs and outputs used by validation processors
- */
-package com.github.fge.jsonschema.processors.data;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/digest/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/digest/package-info.java
deleted file mode 100644
index dc3886ca1..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/digest/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Schema digester
- *
- * @see com.github.fge.jsonschema.keyword.digest.Digester
- */
-package com.github.fge.jsonschema.processors.digest;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/format/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/format/package-info.java
deleted file mode 100644
index 22d2d90d3..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/format/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Format attribute handler
- *
- * @see com.github.fge.jsonschema.format.FormatAttribute
- */
-package com.github.fge.jsonschema.processors.format;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/package-info.java
deleted file mode 100644
index c3ffed2f0..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/package-info.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Core validation processors
- *
- * A full validation makes use of the following individual processors, in
- * order:
- *
- *
- * - {@link com.github.fge.jsonschema.processors.ref reference
- * resolution};
- * - {@link com.github.fge.jsonschema.processors.syntax syntax checking};
- *
- * - {@link com.github.fge.jsonschema.processors.digest schema digesting};
- *
- * - {@link com.github.fge.jsonschema.processors.build keyword building}.
- *
- *
- *
- * All these individual processors are wrapped into a {@link
- * com.github.fge.jsonschema.processors.validation.ValidationProcessor}, which
- * handles the validation process as a whole -- including {@code $schema}
- * detection.
- */
-package com.github.fge.jsonschema.processors;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/ref/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/ref/package-info.java
deleted file mode 100644
index d8f270655..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/ref/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * JSON Reference resolver
- */
-package com.github.fge.jsonschema.processors.ref;
diff --git a/src/main/javadoc/com/github/fge/jsonschema/processors/validation/package-info.java b/src/main/javadoc/com/github/fge/jsonschema/processors/validation/package-info.java
deleted file mode 100644
index cf86e1b4d..000000000
--- a/src/main/javadoc/com/github/fge/jsonschema/processors/validation/package-info.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
- *
- * 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 both licenses is available under the src/resources/ directory of
- * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
- *
- * Direct link to the sources:
- *
- * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
- * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
- */
-
-/**
- * Main validation processors and utility classes
- *
- * The main processors are:
- *
- *
- * - {@link
- * com.github.fge.jsonschema.processors.validation.ValidationProcessor},
- * which is the backbone behind all main classes, and the coordinator of
- * all individual validation processors;
- * - {@link
- * com.github.fge.jsonschema.processors.validation.ValidationChain}, which
- * performs the schema-to-keyword conversion.
- *
- */
-package com.github.fge.jsonschema.processors.validation;
diff --git a/src/main/javadoc/overview.html b/src/main/javadoc/overview.html
index 54ff12bc5..045352fa1 100644
--- a/src/main/javadoc/overview.html
+++ b/src/main/javadoc/overview.html
@@ -97,7 +97,7 @@ $ref resolution
Note that any failure in $ref validation is considered a fatal error.
The processor in charge of this step is {@link
-com.github.fge.jsonschema.processors.ref.RefResolver}. It is located in package
+com.github.fge.jsonschema.core.load.RefResolver}. It is located in package
json-schema-core.
Schema syntax checking
@@ -113,7 +113,7 @@ Schema syntax checking
not follow JSON References.
The processor in charge of this step is {@link
-com.github.fge.jsonschema.processors.syntax.SyntaxProcessor}. It is located in
+com.github.fge.jsonschema.core.keyword.syntax.SyntaxProcessor}. It is located in
the json-schema-core package.
Digesting
@@ -154,7 +154,7 @@ Digesting
allows to prune a lot of duplicates out of keyword caching.
The processor in charge of this step is {@link
-com.github.fge.jsonschema.processing.digest.SchemaDigester}.
+com.github.fge.jsonschema.processors.digest.SchemaDigester}.
Keyword building
diff --git a/src/main/resources/com/github/fge/jsonschema/validator/configuration.properties b/src/main/resources/com/github/fge/jsonschema/validator/configuration.properties
index ae76069c4..55996e6ff 100644
--- a/src/main/resources/com/github/fge/jsonschema/validator/configuration.properties
+++ b/src/main/resources/com/github/fge/jsonschema/validator/configuration.properties
@@ -37,3 +37,4 @@ nullFormat = format attribute name cannot be null
nullAttribute = attempt to register null implementation of format attribute "%s"
nullKeyword = attempt to add null keyword to library
nullType = null type argument to digester constructor
+invalidCacheSize = cache size must be greater than -1. -1 value sets a cache with unlimited records, zero-value disables the cache
diff --git a/src/test/java/com/github/fge/jsonschema/cfg/ValidationConfigurationTest.java b/src/test/java/com/github/fge/jsonschema/cfg/ValidationConfigurationTest.java
index 79684b6ce..c508bca9f 100644
--- a/src/test/java/com/github/fge/jsonschema/cfg/ValidationConfigurationTest.java
+++ b/src/test/java/com/github/fge/jsonschema/cfg/ValidationConfigurationTest.java
@@ -103,6 +103,18 @@ public void cannotPutNullValidationMessageBundle()
}
}
+ @Test
+ public void cannotPutInvalidCacheSize()
+ {
+ try {
+ cfg.setCacheSize(-2);
+ fail("No exception thrown!!");
+ } catch (IllegalArgumentException e) {
+ assertEquals(e.getMessage(),
+ BUNDLE.getMessage("invalidCacheSize"));
+ }
+ }
+
@Test
public void defaultLibraryIsDraftV4()
{
diff --git a/src/test/java/com/github/fge/jsonschema/format/rfc3339/DateTimeTest.java b/src/test/java/com/github/fge/jsonschema/format/rfc3339/DateTimeTest.java
new file mode 100644
index 000000000..d871bc6b4
--- /dev/null
+++ b/src/test/java/com/github/fge/jsonschema/format/rfc3339/DateTimeTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
+ *
+ * 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: https://www.gnu.org/licenses/lgpl-3.0.txt
+ * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
+ */
+
+package com.github.fge.jsonschema.format.rfc3339;
+
+import com.github.fge.jsonschema.core.util.Dictionary;
+import com.github.fge.jsonschema.core.util.DictionaryBuilder;
+import com.github.fge.jsonschema.format.AbstractFormatAttributeTest;
+import com.github.fge.jsonschema.format.FormatAttribute;
+import com.github.fge.jsonschema.format.common.RFC3339DateTimeAttribute;
+
+import java.io.IOException;
+import java.text.Format;
+
+public final class DateTimeTest
+ extends AbstractFormatAttributeTest
+{
+ private static final Dictionary dict =
+ Dictionary
+ .newBuilder()
+ .addEntry("date-time", RFC3339DateTimeAttribute.getInstance())
+ .freeze();
+
+ public DateTimeTest()
+ throws IOException
+ {
+ super(dict, "rfc3339", "date-time");
+ }
+}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/digest/AbstractDigesterTest.java b/src/test/java/com/github/fge/jsonschema/keyword/digest/AbstractDigesterTest.java
index f9b3f47b2..7c601401c 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/digest/AbstractDigesterTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/digest/AbstractDigesterTest.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jackson.JsonNumEquals;
+import com.github.fge.jackson.JsonNumEquivalence;
import com.github.fge.jackson.NodeType;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.google.common.base.Equivalence;
@@ -40,7 +40,7 @@
public abstract class AbstractDigesterTest
{
private static final Equivalence EQUIVALENCE
- = JsonNumEquals.getInstance();
+ = JsonNumEquivalence.getInstance();
private final String keyword;
private final Digester digester;
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/special/ExtendsKeywordTest.java b/src/test/java/com/github/fge/jsonschema/keyword/special/ExtendsKeywordTest.java
index 36bcee0c9..1edcdb1fb 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/special/ExtendsKeywordTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/special/ExtendsKeywordTest.java
@@ -19,6 +19,19 @@
package com.github.fge.jsonschema.keyword.special;
+import static com.github.fge.jsonschema.TestUtils.anyMessage;
+import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.assertMessage;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import org.mockito.ArgumentCaptor;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JacksonUtils;
@@ -33,22 +46,12 @@
import com.github.fge.jsonschema.core.tree.SimpleJsonTree;
import com.github.fge.jsonschema.core.tree.key.SchemaKey;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.library.validator.DraftV3ValidatorDictionary;
import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import org.mockito.ArgumentCaptor;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import static com.github.fge.jsonschema.TestUtils.*;
-import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.*;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
public final class ExtendsKeywordTest
{
@@ -65,13 +68,12 @@ public final class ExtendsKeywordTest
private ProcessingMessage msg;
public ExtendsKeywordTest()
- throws IllegalAccessException, InvocationTargetException,
- InstantiationException
+ throws ProcessingException
{
- final Constructor extends KeywordValidator> constructor
+ final KeywordValidatorFactory factory
= DraftV3ValidatorDictionary.get().entries().get("extends");
- validator = constructor == null ? null
- : constructor.newInstance(FACTORY.nullNode());
+ validator = factory == null ? null
+ : factory.getKeywordValidator(FACTORY.nullNode());
}
@BeforeMethod
@@ -81,7 +83,7 @@ public void initEnvironment()
return;
final ObjectNode schema = FACTORY.objectNode();
- schema.put("extends", FACTORY.objectNode());
+ schema.set("extends", FACTORY.objectNode());
final SchemaTree tree
= new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema);
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/special/NotKeywordTest.java b/src/test/java/com/github/fge/jsonschema/keyword/special/NotKeywordTest.java
index 3270529a3..f13d9b6ae 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/special/NotKeywordTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/special/NotKeywordTest.java
@@ -19,6 +19,20 @@
package com.github.fge.jsonschema.keyword.special;
+import static com.github.fge.jsonschema.TestUtils.anyMessage;
+import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.assertMessage;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import org.mockito.ArgumentCaptor;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JacksonUtils;
@@ -34,22 +48,12 @@
import com.github.fge.jsonschema.core.tree.SimpleJsonTree;
import com.github.fge.jsonschema.core.tree.key.SchemaKey;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.library.validator.DraftV4ValidatorDictionary;
import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import org.mockito.ArgumentCaptor;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import static com.github.fge.jsonschema.TestUtils.*;
-import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.*;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
public final class NotKeywordTest
{
@@ -65,13 +69,12 @@ public final class NotKeywordTest
private ProcessingReport report;
public NotKeywordTest()
- throws IllegalAccessException, InvocationTargetException,
- InstantiationException
+ throws ProcessingException
{
- final Constructor extends KeywordValidator> constructor
+ final KeywordValidatorFactory factory
= DraftV4ValidatorDictionary.get().entries().get("not");
- validator = constructor == null ? null
- : constructor.newInstance(FACTORY.nullNode());
+ validator = factory == null ? null
+ : factory.getKeywordValidator(FACTORY.nullNode());
}
@BeforeMethod
@@ -81,7 +84,7 @@ public void initEnvironment()
return;
final ObjectNode schema = FACTORY.objectNode();
- schema.put("not", FACTORY.objectNode());
+ schema.set("not", FACTORY.objectNode());
final SchemaTree tree
= new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema);
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/special/PatternKeywordTest.java b/src/test/java/com/github/fge/jsonschema/keyword/special/PatternKeywordTest.java
index 6ff655ae0..873041061 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/special/PatternKeywordTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/special/PatternKeywordTest.java
@@ -19,6 +19,22 @@
package com.github.fge.jsonschema.keyword.special;
+import static com.github.fge.jsonschema.TestUtils.anyMessage;
+import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.assertMessage;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.mockito.ArgumentCaptor;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JsonLoader;
@@ -33,26 +49,13 @@
import com.github.fge.jsonschema.core.tree.SimpleJsonTree;
import com.github.fge.jsonschema.core.tree.key.SchemaKey;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.library.validator.CommonValidatorDictionary;
import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import com.google.common.collect.Lists;
-import org.mockito.ArgumentCaptor;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-
-import static com.github.fge.jsonschema.TestUtils.*;
-import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.*;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
public final class PatternKeywordTest
{
@@ -65,20 +68,20 @@ public final class PatternKeywordTest
private static final MessageBundle BUNDLE
= MessageBundles.getBundle(JsonSchemaValidationBundle.class);
- private final Constructor extends KeywordValidator> constructor;
+ private final KeywordValidatorFactory factory;
private final JsonNode testData;
public PatternKeywordTest()
throws IOException
{
- constructor = CommonValidatorDictionary.get().entries().get("pattern");
+ factory = CommonValidatorDictionary.get().entries().get("pattern");
testData = JsonLoader.fromResource("/keyword/special/pattern.json");
}
@Test
public void keywordExists()
{
- assertNotNull(constructor, "no support for pattern??");
+ assertNotNull(factory, "no support for pattern??");
}
@DataProvider
@@ -120,7 +123,7 @@ public void instancesAreValidatedCorrectly(final JsonNode schema,
// It is a null node which is ignored by the constructor, so we can
// do that
- final KeywordValidator validator = constructor.newInstance(schema);
+ final KeywordValidator validator = factory.getKeywordValidator(schema);
validator.validate(processor, report, BUNDLE, data);
if (valid) {
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/AbstractKeywordValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/AbstractKeywordValidatorTest.java
index aa69bcec9..9916d8a8d 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/AbstractKeywordValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/AbstractKeywordValidatorTest.java
@@ -19,6 +19,22 @@
package com.github.fge.jsonschema.keyword.validator;
+import static com.github.fge.jsonschema.TestUtils.anyMessage;
+import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.assertMessage;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.mockito.ArgumentCaptor;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JsonLoader;
@@ -38,20 +54,6 @@
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import com.google.common.collect.Lists;
-import org.mockito.ArgumentCaptor;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-
-import static com.github.fge.jsonschema.TestUtils.*;
-import static com.github.fge.jsonschema.matchers.ProcessingMessageAssert.*;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
@Test
public abstract class AbstractKeywordValidatorTest
@@ -60,16 +62,16 @@ public abstract class AbstractKeywordValidatorTest
= MessageBundles.getBundle(JsonSchemaValidationBundle.class);
private final String keyword;
- private final Constructor extends KeywordValidator> constructor;
+ private final KeywordValidatorFactory factory;
private final JsonNode testNode;
protected AbstractKeywordValidatorTest(
- final Dictionary> dict,
+ final Dictionary dict,
final String prefix, final String keyword)
throws IOException
{
this.keyword = keyword;
- constructor = dict.entries().get(keyword);
+ factory = dict.entries().get(keyword);
final String resourceName
= String.format("/keyword/validators/%s/%s.json", prefix, keyword);
testNode = JsonLoader.fromResource(resourceName);
@@ -78,7 +80,7 @@ protected AbstractKeywordValidatorTest(
@Test
public final void keywordExists()
{
- assertNotNull(constructor, "no support for " + keyword + "??");
+ assertNotNull(factory, "no support for " + keyword + "??");
}
@DataProvider
@@ -120,7 +122,7 @@ public final void instancesAreValidatedCorrectly(final JsonNode digest,
@SuppressWarnings("unchecked")
final Processor processor = mock(Processor.class);
- final KeywordValidator validator = constructor.newInstance(digest);
+ final KeywordValidator validator = factory.getKeywordValidator(digest);
validator.validate(processor, report, BUNDLE, data);
if (valid) {
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java
index 07ba21ec8..92ada83b5 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java
@@ -19,6 +19,21 @@
package com.github.fge.jsonschema.keyword.validator.callback;
+import static com.github.fge.jsonschema.TestUtils.anyReport;
+import static com.github.fge.jsonschema.TestUtils.onlyOnce;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -36,19 +51,11 @@
import com.github.fge.jsonschema.core.tree.key.SchemaKey;
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
import com.github.fge.jsonschema.messages.JsonSchemaValidationBundle;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import static com.github.fge.jsonschema.TestUtils.*;
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
@Test
public abstract class CallbackValidatorTest
@@ -62,7 +69,7 @@ public abstract class CallbackValidatorTest
protected static final ObjectNode sub2 = FACTORY.objectNode();
protected final String keyword;
- private final Constructor extends KeywordValidator> constructor;
+ private final KeywordValidatorFactory factory;
protected final JsonPointer ptr1;
protected final JsonPointer ptr2;
@@ -72,21 +79,20 @@ public abstract class CallbackValidatorTest
private KeywordValidator validator;
protected CallbackValidatorTest(
- final Dictionary> dict,
+ final Dictionary dict,
final String keyword, final JsonPointer ptr1, final JsonPointer ptr2)
{
this.keyword = keyword;
- constructor = dict.entries().get(keyword);
+ factory = dict.entries().get(keyword);
this.ptr1 = ptr1;
this.ptr2 = ptr2;
}
@BeforeMethod
protected final void initEnvironment()
- throws IllegalAccessException, InvocationTargetException,
- InstantiationException
+ throws ProcessingException
{
- if (constructor == null)
+ if (factory == null)
return;
final SchemaTree tree = new CanonicalSchemaTree(
@@ -95,13 +101,13 @@ protected final void initEnvironment()
data = new FullData(tree, instance);
report = mock(ProcessingReport.class);
when(report.getLogLevel()).thenReturn(LogLevel.DEBUG);
- validator = constructor.newInstance(generateDigest());
+ validator = factory.getKeywordValidator(generateDigest());
}
@Test
public final void keywordExists()
{
- assertNotNull(constructor, "no support for " + keyword + "??");
+ assertNotNull(factory, "no support for " + keyword + "??");
}
@Test(dependsOnMethods = "keywordExists")
@@ -241,6 +247,7 @@ private DummyProcessor(final WantedState wanted1,
}
@Override
+ @SuppressWarnings("ReferenceEquality")
public FullData process(final ProcessingReport report,
final FullData input)
throws ProcessingException
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DisallowValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DisallowValidatorTest.java
index 5f502dad3..dea7f6274 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DisallowValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DisallowValidatorTest.java
@@ -54,8 +54,8 @@ protected void checkOkOk(final ProcessingReport report)
final ObjectNode reports = FACTORY.objectNode();
final ArrayNode oneReport = FACTORY.arrayNode();
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -78,8 +78,8 @@ protected void checkOkKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), FACTORY.arrayNode());
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), FACTORY.arrayNode());
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -102,7 +102,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
@@ -116,11 +116,11 @@ protected JsonNode generateInstance()
protected JsonNode generateDigest()
{
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, FACTORY.arrayNode());
+ ret.set(keyword, FACTORY.arrayNode());
final ArrayNode schemas = FACTORY.arrayNode();
schemas.add(0);
schemas.add(1);
- ret.put("schemas", schemas);
+ ret.set("schemas", schemas);
return ret;
}
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DraftV3TypeValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DraftV3TypeValidatorTest.java
index 9e4fb34c1..4968f4f32 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DraftV3TypeValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/DraftV3TypeValidatorTest.java
@@ -68,8 +68,8 @@ protected void checkKoKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -84,7 +84,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
@@ -98,11 +98,11 @@ protected JsonNode generateInstance()
protected JsonNode generateDigest()
{
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, FACTORY.arrayNode());
+ ret.set(keyword, FACTORY.arrayNode());
final ArrayNode schemas = FACTORY.arrayNode();
schemas.add(0);
schemas.add(1);
- ret.put("schemas", schemas);
+ ret.set("schemas", schemas);
return ret;
}
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/ExtendsValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/ExtendsValidatorTest.java
index f48099215..355c79be1 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/ExtendsValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv3/ExtendsValidatorTest.java
@@ -66,7 +66,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AllOfValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AllOfValidatorTest.java
index 24e0b256f..6dae95d84 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AllOfValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AllOfValidatorTest.java
@@ -61,8 +61,8 @@ protected void checkOkKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), FACTORY.arrayNode());
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), FACTORY.arrayNode());
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -85,8 +85,8 @@ protected void checkKoKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -102,7 +102,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AnyOfValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AnyOfValidatorTest.java
index 48a6f82ba..14c920c3c 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AnyOfValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/AnyOfValidatorTest.java
@@ -68,8 +68,8 @@ protected void checkKoKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -84,7 +84,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/DependenciesValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/DependenciesValidatorTest.java
index ea8b61d93..ac600cab5 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/DependenciesValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/DependenciesValidatorTest.java
@@ -63,11 +63,11 @@ protected void checkKoKo(final ProcessingReport report)
protected JsonNode generateSchema()
{
final ObjectNode value = FACTORY.objectNode();
- value.put("a", sub1);
- value.put("b", sub2);
+ value.set("a", sub1);
+ value.set("b", sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, value);
+ ret.set(keyword, value);
return ret;
}
@@ -88,8 +88,8 @@ protected JsonNode generateDigest()
schemaDeps.add("b");
final ObjectNode ret = FACTORY.objectNode();
- ret.put("propertyDeps", FACTORY.objectNode());
- ret.put("schemaDeps", schemaDeps);
+ ret.set("propertyDeps", FACTORY.objectNode());
+ ret.set("schemaDeps", schemaDeps);
return ret;
}
}
diff --git a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/OneOfValidatorTest.java b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/OneOfValidatorTest.java
index 296f1cfc0..3532b29fe 100644
--- a/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/OneOfValidatorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/keyword/validator/callback/draftv4/OneOfValidatorTest.java
@@ -53,8 +53,8 @@ protected void checkOkOk(final ProcessingReport report)
final ObjectNode reports = FACTORY.objectNode();
final ArrayNode oneReport = FACTORY.arrayNode();
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -84,8 +84,8 @@ protected void checkKoKo(final ProcessingReport report)
final ArrayNode oneReport = FACTORY.arrayNode();
oneReport.add(MSG.asJson());
- reports.put(ptr1.toString(), oneReport);
- reports.put(ptr2.toString(), oneReport);
+ reports.set(ptr1.toString(), oneReport);
+ reports.set(ptr2.toString(), oneReport);
assertMessage(message)
.isValidationError(keyword,
@@ -101,7 +101,7 @@ protected JsonNode generateSchema()
schemas.add(sub1);
schemas.add(sub2);
final ObjectNode ret = FACTORY.objectNode();
- ret.put(keyword, schemas);
+ ret.set(keyword, schemas);
return ret;
}
diff --git a/src/test/java/com/github/fge/jsonschema/matchers/ProcessingMessageAssert.java b/src/test/java/com/github/fge/jsonschema/matchers/ProcessingMessageAssert.java
index 5a53411bb..6248c7a73 100644
--- a/src/test/java/com/github/fge/jsonschema/matchers/ProcessingMessageAssert.java
+++ b/src/test/java/com/github/fge/jsonschema/matchers/ProcessingMessageAssert.java
@@ -19,6 +19,7 @@
package com.github.fge.jsonschema.matchers;
+import org.assertj.core.api.AbstractAssert;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -27,16 +28,15 @@
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.tree.SchemaTree;
import com.github.fge.jsonschema.core.util.AsJson;
-import org.fest.assertions.GenericAssert;
import java.util.Collection;
import java.util.Map;
-import static org.fest.assertions.Assertions.*;
+import static org.assertj.core.api.Assertions.*;
import static org.testng.Assert.*;
public final class ProcessingMessageAssert
- extends GenericAssert
+ extends AbstractAssert
{
private final JsonNode msg;
@@ -48,7 +48,7 @@ public static ProcessingMessageAssert assertMessage(
private ProcessingMessageAssert(final ProcessingMessage actual)
{
- super(ProcessingMessageAssert.class, actual);
+ super(actual, ProcessingMessageAssert.class);
msg = actual.asJson();
}
@@ -88,9 +88,10 @@ public ProcessingMessageAssert hasField(final String name,
assertThat(msg.has(name)).isTrue();
final String input = msg.get(name).textValue();
final String expected = value.toString();
- assertThat(input).isEqualTo(expected)
+ assertThat(input)
.overridingErrorMessage("Strings differ: wanted " + expected
- + " but got " + input);
+ + " but got " + input)
+ .isEqualTo(expected);
return this;
}
diff --git a/src/test/java/com/github/fge/jsonschema/processors/build/ValidatorBuilderTest.java b/src/test/java/com/github/fge/jsonschema/processors/build/ValidatorBuilderTest.java
index 4887af34a..8f038c38c 100644
--- a/src/test/java/com/github/fge/jsonschema/processors/build/ValidatorBuilderTest.java
+++ b/src/test/java/com/github/fge/jsonschema/processors/build/ValidatorBuilderTest.java
@@ -19,6 +19,16 @@
package com.github.fge.jsonschema.processors.build;
+import static org.mockito.Mockito.mock;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.fail;
+
+import java.util.List;
+import java.util.Map;
+
+import org.testng.annotations.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
@@ -27,20 +37,14 @@
import com.github.fge.jsonschema.core.util.Dictionary;
import com.github.fge.jsonschema.core.util.DictionaryBuilder;
import com.github.fge.jsonschema.keyword.validator.KeywordValidator;
+import com.github.fge.jsonschema.keyword.validator.KeywordValidatorFactory;
+import com.github.fge.jsonschema.keyword.validator.ReflectionKeywordValidatorFactory;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.jsonschema.processors.data.SchemaDigest;
import com.github.fge.jsonschema.processors.data.ValidatorList;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Constructor;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.*;
-import static org.testng.Assert.*;
public final class ValidatorBuilderTest
{
@@ -53,17 +57,17 @@ public final class ValidatorBuilderTest
public ValidatorBuilderTest()
throws NoSuchMethodException
{
- final DictionaryBuilder>
+ final DictionaryBuilder
builder = Dictionary.newBuilder();
- Constructor extends KeywordValidator> constructor;
+ KeywordValidatorFactory factory;
- constructor = Keyword1.class .getConstructor(JsonNode.class);
- builder.addEntry(K1, constructor);
- constructor = Keyword2.class.getConstructor(JsonNode.class);
- builder.addEntry(K2, constructor);
- constructor = Challenged.class.getConstructor(JsonNode.class);
- builder.addEntry(CHALLENGED, constructor);
+ factory = new ReflectionKeywordValidatorFactory(K1, Keyword1.class);
+ builder.addEntry(K1, factory);
+ factory = new ReflectionKeywordValidatorFactory(K2, Keyword2.class);
+ builder.addEntry(K2, factory);
+ factory = new ReflectionKeywordValidatorFactory(CHALLENGED, Challenged.class);
+ builder.addEntry(CHALLENGED, factory);
validatorBuilder = new ValidatorBuilder(builder.freeze());
}
diff --git a/src/test/java/com/github/fge/jsonschema/processors/validation/ArraySchemaDigesterTest.java b/src/test/java/com/github/fge/jsonschema/processors/validation/ArraySchemaDigesterTest.java
index 5b1094b92..71fa599a6 100644
--- a/src/test/java/com/github/fge/jsonschema/processors/validation/ArraySchemaDigesterTest.java
+++ b/src/test/java/com/github/fge/jsonschema/processors/validation/ArraySchemaDigesterTest.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jackson.JsonNumEquals;
+import com.github.fge.jackson.JsonNumEquivalence;
import com.github.fge.jsonschema.keyword.digest.Digester;
import com.google.common.base.Equivalence;
import com.google.common.collect.Lists;
@@ -37,7 +37,7 @@
public final class ArraySchemaDigesterTest
{
private static final Equivalence EQUIVALENCE
- = JsonNumEquals.getInstance();
+ = JsonNumEquivalence.getInstance();
private final Digester digester = ArraySchemaDigester.getInstance();
private final JsonNode testNode;
diff --git a/src/test/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigesterTest.java b/src/test/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigesterTest.java
index 2f611288c..9fe6622b1 100644
--- a/src/test/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigesterTest.java
+++ b/src/test/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaDigesterTest.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
-import com.github.fge.jackson.JsonNumEquals;
+import com.github.fge.jackson.JsonNumEquivalence;
import com.github.fge.jsonschema.keyword.digest.Digester;
import com.google.common.base.Equivalence;
import com.google.common.collect.Lists;
@@ -37,7 +37,7 @@
public final class ObjectSchemaDigesterTest
{
private static final Equivalence EQUIVALENCE
- = JsonNumEquals.getInstance();
+ = JsonNumEquivalence.getInstance();
private final Digester digester = ObjectSchemaDigester.getInstance();
private final JsonNode testNode;
diff --git a/src/test/java/com/github/fge/jsonschema/processors/validation/ValidationProcessorTest.java b/src/test/java/com/github/fge/jsonschema/processors/validation/ValidationProcessorTest.java
index bcf238fe0..8b42fa609 100644
--- a/src/test/java/com/github/fge/jsonschema/processors/validation/ValidationProcessorTest.java
+++ b/src/test/java/com/github/fge/jsonschema/processors/validation/ValidationProcessorTest.java
@@ -75,7 +75,7 @@ public final class ValidationProcessorTest
RAWSCHEMA = factory.objectNode();
RAWSCHEMA.put("minItems", 2)
- .put("items", factory.objectNode().put(K1, 0));
+ .set("items", factory.objectNode().put(K1, 0));
RAWINSTANCE = factory.arrayNode();
RAWINSTANCE.add(1);
diff --git a/src/test/resources/format/common/date-time.json b/src/test/resources/format/common/date-time.json
index 1f2d96f1d..f79dcc701 100644
--- a/src/test/resources/format/common/date-time.json
+++ b/src/test/resources/format/common/date-time.json
@@ -25,7 +25,7 @@
"message": "err.format.invalidDate",
"msgData": {
"value": "2012-02-30T00:00:00+0000",
- "expected": [ "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ]
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z" ]
},
"msgParams": [ "value", "expected" ]
},
@@ -35,8 +35,48 @@
"message": "err.format.invalidDate",
"msgData": {
"value": "201202030",
- "expected": [ "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ" ]
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z" ]
},
"msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234567Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345678Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345678Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456789Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234567890Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345678901Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456789012Z",
+ "valid": true
}
]
diff --git a/src/test/resources/format/common/email.json b/src/test/resources/format/common/email.json
index 452e548aa..669b42c08 100644
--- a/src/test/resources/format/common/email.json
+++ b/src/test/resources/format/common/email.json
@@ -14,12 +14,7 @@
},
{
"data": "éioaj@my.name",
- "valid": false,
- "message": "err.format.invalidEmail",
- "msgData": {
- "value": "éioaj@my.name"
- },
- "msgParams": [ "value" ]
+ "valid": true
},
{
"data": "a@",
diff --git a/src/test/resources/format/draftv3/date.json b/src/test/resources/format/draftv3/date.json
index 675faa537..1100d6309 100644
--- a/src/test/resources/format/draftv3/date.json
+++ b/src/test/resources/format/draftv3/date.json
@@ -1,4 +1,8 @@
[
+ {
+ "data": "2017-10-15",
+ "valid": true
+ },
{
"data": "2012-12-02",
"valid": true
diff --git a/src/test/resources/format/rfc3339/date-time.json b/src/test/resources/format/rfc3339/date-time.json
new file mode 100644
index 000000000..1ee20602d
--- /dev/null
+++ b/src/test/resources/format/rfc3339/date-time.json
@@ -0,0 +1,154 @@
+[
+ {
+ "data": "2012-12-02T13:05:00+01:00",
+ "valid": true
+ },
+ {
+ "data": "2001-02-12T00:00:00Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.13Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32+10:00",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32-05:30",
+ "valid": true
+ },
+ {
+ "data": "201202030",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "201202030",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00+0100",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00+0100",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00+01:30:30",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00+01:30:30",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00Z[Europe/Paris]",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00Z[Europe/Paris]",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00+10:00Z",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00+10:00Z",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00America/New_York",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00America/New_York",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00[America/New_York]",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00[America/New_York]",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-12-02T13:05:00.123456",
+ "valid": false,
+ "message": "err.format.invalidDate",
+ "msgData": {
+ "value": "2012-12-02T13:05:00.123456",
+ "expected": [ "yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)" ]
+ },
+ "msgParams": [ "value", "expected" ]
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234+05:00",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234567Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345678Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456789Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.1234567890Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.12345678901Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456789012Z",
+ "valid": true
+ },
+ {
+ "data": "2012-08-07T20:42:32.123456789012+05:00",
+ "valid": true
+ }
+]