Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright (c) 2013, Francis Galiegue <>
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the Lesser GNU General Public License as
   * published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Lesser GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <>.
 package com.github.fge.jsonschema.load;
 import java.util.Map;
 import static com.github.fge.jsonschema.messages.RefProcessingMessages.*;

Class to fetch JSON documents

This uses a map of URIDownloader instances to fetch the contents of a URI as an, then tries and turns this content into JSON using an com.fasterxml.jackson.databind.ObjectMapper.

Normally, you will never use this class directly.

 public final class URIManager
Our object reader
     private static final ObjectReader READER = JacksonUtils.getReader();
     private final Map<StringURIDownloaderdownloaders;
     private final Map<URIURIschemaRedirects;
     public URIManager()
     public URIManager(final LoadingConfiguration cfg)
          = cfg.getDownloaders().entries();
          = cfg.getSchemaRedirects();

Get the content at a given URI as a com.fasterxml.jackson.databind.JsonNode

uri the URI
the content
com.github.fge.jsonschema.exceptions.ProcessingException scheme is not registered, failed to get content, or content is not JSON
     public JsonNode getContent(final URI uri)
         throws ProcessingException
         Preconditions.checkNotNull(uri"null URI");
         final URI target = .containsKey(uri)
             ? .get(uri) : uri;
         final ProcessingMessage msg = new ProcessingMessage()
         if (!target.isAbsolute())
             throw new ProcessingException(msg.message());
         final String scheme = target.getScheme();
         final URIDownloader downloader = .get(scheme);
         if (downloader == null)
             throw new ProcessingException(msg.message()
        final InputStream in;
        try {
            in = downloader.fetch(target);
            return .readTree(in);
        } catch (JsonProcessingException e) {
            throw new ProcessingException(msg.message()
        } catch (IOException e) {
            throw new ProcessingException(msg.message()
New to GrepCode? Check out our FAQ X