Interface JsonSchemaReaderFactory

  • All Known Subinterfaces:
    JsonValidationService

    public interface JsonSchemaReaderFactory
    A factory interface for creating JsonSchemaReader instances.

    The following code sample shows how to read a JSON schema from a string:

     
     JsonValidationService service = JsonValidationService.newInstance();
     JsonSchemaReaderFactory factory = service.createSchemaReaderFactory();
     StringReader reader = new StringReader("{\"type\": \"integer\"}");
     try (JsonSchemaReader reader = factory.createSchemaReader(reader)) {
         JsonSchema schema = reader.read();
     }
     
     

    Any instance of this class is safe for use by multiple concurrent threads.

    Author:
    leadpony
    • Method Detail

      • createSchemaReader

        JsonSchemaReader createSchemaReader​(InputStream in)
        Creates a JSON schema reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.
        Parameters:
        in - the byte stream from which a JSON schema is to be read.
        Returns:
        newly created instance of JSON schema reader. It must be closed by the method caller after use.
        Throws:
        NullPointerException - if the specified in is null.
        See Also:
        JsonSchemaReader
      • createSchemaReader

        JsonSchemaReader createSchemaReader​(InputStream in,
                                            Charset charset)
        Creates a JSON schema reader from a byte stream encoded by the specified charset. The bytes of the stream will be decoded to characters using the specified charset.
        Parameters:
        in - the byte stream from which a JSON schema is to be read.
        charset - the character set.
        Returns:
        newly created instance of JSON schema reader. It must be closed by the method caller after use.
        Throws:
        NullPointerException - if the specified in or charset is null.
        See Also:
        JsonSchemaReader
      • createSchemaReader

        JsonSchemaReader createSchemaReader​(Reader reader)
        Creates a JSON schema reader from a character stream.
        Parameters:
        reader - the character stream from which a JSON schema is to be read.
        Returns:
        newly created instance of JSON schema reader. It must be closed by the method caller after use.
        Throws:
        NullPointerException - if the specified reader is null.
        See Also:
        JsonSchemaReader
      • createSchemaReader

        JsonSchemaReader createSchemaReader​(Path path)
        Creates a JSON schema reader from a path.
        Parameters:
        path - the path from which a JSON schema is to be read.
        Returns:
        newly created instance of JSON schema reader. It must be closed by the method caller after use.
        Throws:
        JsonException - if an I/O error occurs while creating reader.
        NullPointerException - if the specified path is null.
        See Also:
        JsonSchemaReader