/** * Create a new {@code UrlResource} based on a URI specification. * <p>The given parts will automatically get encoded if necessary. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon); * also known as "scheme" * @param location the location (e.g. the file path within that protocol); * also known as "scheme-specific part" * @param fragment the fragment within that location (e.g. anchor on an HTML page, * as following after a "#" separator) * @throws MalformedURLException if the given URL specification is not valid * @see java.net.URI#URI(String, String, String) */ public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException { try { this.uri = new URI(protocol, location, fragment); this.url = this.uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString()); } catch (URISyntaxException ex) { MalformedURLException exToThrow = new MalformedURLException(ex.getMessage()); exToThrow.initCause(ex); throw exToThrow; } }
/** * Create a new {@code UrlResource} based on a URI specification. * <p>The given parts will automatically get encoded if necessary. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon); * also known as "scheme" * @param location the location (e.g. the file path within that protocol); * also known as "scheme-specific part" * @param fragment the fragment within that location (e.g. anchor on an HTML page, * as following after a "#" separator) * @throws MalformedURLException if the given URL specification is not valid * @see java.net.URI#URI(String, String, String) */ public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException { try { this.uri = new URI(protocol, location, fragment); this.url = this.uri.toURL(); this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString()); } catch (URISyntaxException ex) { MalformedURLException exToThrow = new MalformedURLException(ex.getMessage()); exToThrow.initCause(ex); throw exToThrow; } }
malformedUrl.initCause(e); throw malformedUrl;
e.initCause(iaE); throw e;
mx.initCause(ioe); throw mx;
/** * Creates an MalformedURLException with a message and a cause. * * @param message exception message * @param cause exception cause * @throws MalformedURLException the created MalformedURLException */ private static void throwAsMalformedURLException(final String message, final Exception cause) throws MalformedURLException { final MalformedURLException exception = new MalformedURLException(message); exception.initCause(cause); throw exception; }
/** * Creates an MalformedURLException with a message and a cause. * * @param message exception message * @param cause exception cause * * @throws MalformedURLException the created MalformedURLException */ private static void throwAsMalformedURLException( final String message, final Exception cause ) throws MalformedURLException { final MalformedURLException exception = new MalformedURLException( message ); exception.initCause( cause ); throw exception; }
public QTURL(final URL url) throws MalformedURLException { this.actualURL = url; try { this.originalURL = new URL(url.toURI().toASCIIString()); } catch (URISyntaxException e) { final MalformedURLException exception = new MalformedURLException(url.toString()); exception.initCause(e); throw exception; } }
public static URL getEncodedURL(String urlStr) throws MalformedURLException { URL url = new URL(urlStr); String scheme = String.valueOf(url.getProtocol()).toLowerCase(); if (scheme.equals("http") || scheme.equals("https")) { try { return new URL(url.toURI().toASCIIString()); } catch (URISyntaxException e) { MalformedURLException malformedURLException = new MalformedURLException(e.getMessage()); malformedURLException.initCause(e); throw malformedURLException; } } return url; }
public static URL getEncodedURL(String urlStr) throws MalformedURLException { URL url = new URL(urlStr); String scheme = String.valueOf(url.getProtocol()).toLowerCase(); if (scheme.equals("http") || scheme.equals("https")) { try { return new URL(url.toURI().toASCIIString()); } catch (URISyntaxException e) { MalformedURLException malformedURLException = new MalformedURLException(e.getMessage()); malformedURLException.initCause(e); throw malformedURLException; } } return url; }
public static URL getEncodedURL(String urlStr) throws MalformedURLException { URL url = new URL(urlStr); String scheme = String.valueOf(url.getProtocol()).toLowerCase(); if (scheme.equals("http") || scheme.equals("https")) { try { return new URL(url.toURI().toASCIIString()); } catch (URISyntaxException e) { MalformedURLException malformedURLException = new MalformedURLException(e.getMessage()); malformedURLException.initCause(e); throw malformedURLException; } } return url; }
@NonNull public static File urlToFile(@NonNull URL url) throws MalformedURLException { try { return new File(url.toURI()); } catch (IllegalArgumentException e) { MalformedURLException ex = new MalformedURLException(e.getLocalizedMessage()); ex.initCause(e); throw ex; } catch (URISyntaxException e) { return new File(url.getPath()); } }
protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpsClientTransport(asTextWireFormat(wf), uri); } }
protected Transport createTransport(URI location, WireFormat wf) throws IOException { TextWireFormat textWireFormat = asTextWireFormat(wf); // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpClientTransport(textWireFormat, uri); }
@Override protected Transport createTransport(URI location, WireFormat wf) throws IOException { TextWireFormat textWireFormat = asTextWireFormat(wf); // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpClientTransport(textWireFormat, uri); }
@Override protected Transport createTransport(URI location, WireFormat wf) throws IOException { TextWireFormat textWireFormat = asTextWireFormat(wf); // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpClientTransport(textWireFormat, uri); }
@Override protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpsClientTransport(asTextWireFormat(wf), uri); } }
@Override protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpsClientTransport(asTextWireFormat(wf), uri); } }
@Override protected Transport createTransport(URI location, WireFormat wf) throws IOException { TextWireFormat textWireFormat = asTextWireFormat(wf); // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpClientTransport(textWireFormat, uri); }
@Override protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { // need to remove options from uri URI uri; try { uri = URISupport.removeQuery(location); } catch (URISyntaxException e) { MalformedURLException cause = new MalformedURLException("Error removing query on " + location); cause.initCause(e); throw cause; } return new HttpsClientTransport(asTextWireFormat(wf), uri); } }