X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FDownloader.java;h=a8a591a363958412a73eb6ef042d38ba33ae1cf9;hb=530d4062471346d6ececf76d74a0358c91323998;hp=67fd652b306323243365271752eb528f3e6523f2;hpb=2ee6c205bfacff9e9a3103e7738afcd5e3267d3f;p=fanfix.git diff --git a/src/be/nikiroo/utils/Downloader.java b/src/be/nikiroo/utils/Downloader.java index 67fd652..a8a591a 100644 --- a/src/be/nikiroo/utils/Downloader.java +++ b/src/be/nikiroo/utils/Downloader.java @@ -28,6 +28,7 @@ import java.util.zip.GZIPInputStream; public class Downloader { private String UA; private CookieManager cookies; + private TraceHandler tracer = new TraceHandler(); /** * Create a new {@link Downloader}. @@ -46,6 +47,25 @@ public class Downloader { CookieHandler.setDefault(cookies); } + /** + * The traces handler for this {@link Cache}. + * + * @return the traces handler + */ + public TraceHandler getTraceHandler() { + return tracer; + } + + /** + * The traces handler for this {@link Cache}. + * + * @param tracer + * the new traces handler + */ + public void setTraceHandler(TraceHandler tracer) { + this.tracer = tracer; + } + /** * Clear all the cookies currently in the jar. *

@@ -74,6 +94,10 @@ public class Downloader { * * @param url * the {@link URL} to open + * @param currentReferer + * the current referer, for websites that needs this info + * @param cookiesValues + * the cookies * @param postParams * the POST parameters * @param getParams @@ -93,24 +117,6 @@ public class Downloader { getParams, oauth); } - /** - * Trace information (info/error) generated by this class. - *

- * You can override it if you don't want the default sysout/syserr. - * - * @param message - * the message - * @param error - * TRUE for error messages, FALSE for information messages - */ - protected void trace(String message, boolean error) { - if (error) { - System.err.println(message); - } else { - System.out.println(message); - } - } - /** * Open the given {@link URL} and update the cookies. * @@ -134,7 +140,7 @@ public class Downloader { Map postParams, Map getParams, String oauth) throws IOException { - trace("Download: " + url, false); + tracer.trace("Download: " + url); URLConnection conn = openConnectionWithCookies(url, currentReferer, cookiesValues);