Package org.faceless.report
Interface URLConnectionFactory
-
public interface URLConnectionFactory
An interface that can be implemented to override or extend the Report Generators method of resolving URLs. For example, for more control over how redirections are done on HTTP:
ReportParser.registerURLConnectionFactory("http", new URLConnectionFactory() { public URLConnection openURLConnection(String url) throws IOException { HttpURLConnection con; int redirectcount = 0; while (true) { con = (HttpURLConnection)new URL(url).openConnection(); int code = con.getResponseCode(); if (code == 301 || code == 302 && ++redirectcount < 5) { url = con.getHeaderField("Location"); } else if (code != 200) { con.disconnect(); throw new IOException("HTTP "+code+": "+con.getResponseMessage()+" for "+url); } else { return con; } } } });
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.net.URLConnection
openURLConnection(java.lang.String url)
Return a URLConnection for the specified uri.
-
-
-
Method Detail
-
openURLConnection
java.net.URLConnection openURLConnection(java.lang.String url) throws java.io.IOException
Return a URLConnection for the specified uri. The URI will have a scheme that is a case-insensitive match for one of the schemes this factory was registered with. If this method returns null, the default method of opening a URL will be used.- Parameters:
url
- the URL to be opened, as a string.- Returns:
- a URLConnection that was opened to the specified URL, or null if the default approach should be used.
- Throws:
java.io.IOException
- if the URL cannot be opened for any reason
-
-