org.everit.json.schema.loader.internal.DefaultSchemaClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of everit-json-schema Show documentation
Show all versions of everit-json-schema Show documentation
Implementation of the JSON Schema Core Draft v4 specification built with the org.json API
package org.everit.json.schema.loader.internal;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URL;
import java.net.URLConnection;
import org.everit.json.schema.loader.SchemaClient;
/**
* A {@link SchemaClient} implementation which uses {@link URL} for reading the remote content.
*/
public class DefaultSchemaClient implements SchemaClient {
@Override
public InputStream get(final String url) {
try {
URL u = new URL(url);
URLConnection conn = u.openConnection();
String location = conn.getHeaderField("Location");
if (location != null) {
return get(location);
}
return (InputStream) conn.getContent();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy