diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:21:26 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:21:26 +0000 |
commit | c0b4de31e41dd7d9b698a38db5f7aa479b322790 (patch) | |
tree | 27faf9ca01e1e96d08319f8add2d06d1d63ef2f3 /src/org/apache/fop | |
parent | 9af08fd7f6c6cc45f79511e33a226ccb95515ed3 (diff) | |
download | xmlgraphics-fop-c0b4de31e41dd7d9b698a38db5f7aa479b322790.tar.gz xmlgraphics-fop-c0b4de31e41dd7d9b698a38db5f7aa479b322790.zip |
Separate baseURL parameter unnecessary as it comes from the user agent anyway.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195897 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r-- | src/org/apache/fop/image/ImageFactory.java | 16 | ||||
-rw-r--r-- | src/org/apache/fop/image/ImageLoader.java | 34 |
2 files changed, 28 insertions, 22 deletions
diff --git a/src/org/apache/fop/image/ImageFactory.java b/src/org/apache/fop/image/ImageFactory.java index 6a99d1367..93b23a7ec 100644 --- a/src/org/apache/fop/image/ImageFactory.java +++ b/src/org/apache/fop/image/ImageFactory.java @@ -115,15 +115,13 @@ public class ImageFactory { /** * Create an FopImage objects. * @param href the url for the image - * @param baseURL the base url * @param ua the user agent context * @return the fop image instance */ - protected static FopImage loadImage(String href, String baseURL, - FOUserAgent ua) { + protected static FopImage loadImage(String href, FOUserAgent ua) { Logger log = ua.getLogger(); - InputStream in = openStream(href, baseURL, ua); + InputStream in = openStream(href, ua); if (in == null) { return null; @@ -202,12 +200,10 @@ public class ImageFactory { /** * Create an FopImage objects. * @param href image URL as a String - * @param baseURL base URL for relative URLs * @param ua user agent * @return a new FopImage object */ - protected static InputStream openStream(String href, String baseURL, - FOUserAgent ua) { + protected static InputStream openStream(String href, FOUserAgent ua) { Logger log = ua.getLogger(); // Get the absolute URL URL absoluteURL = null; @@ -237,13 +233,13 @@ public class ImageFactory { return null; } catch (Exception e) { // maybe relative - if (baseURL == null) { + if (ua.getBaseURL() == null) { log.error("Error with image URL: " + e.getMessage() - + " and no base directory is specified", e); + + " and no base URL is specified", e); return null; } try { - absoluteURL = new URL(baseURL + absoluteURL.getFile()); + absoluteURL = new URL(ua.getBaseURL() + absoluteURL.getFile()); } catch (MalformedURLException e_context) { // pb context url log.error("Invalid Image URL - error on relative URL: " diff --git a/src/org/apache/fop/image/ImageLoader.java b/src/org/apache/fop/image/ImageLoader.java index 625cd717c..efd3e6124 100644 --- a/src/org/apache/fop/image/ImageLoader.java +++ b/src/org/apache/fop/image/ImageLoader.java @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the * LICENSE file included with these sources. */ @@ -13,24 +13,34 @@ import org.apache.fop.fo.FOUserAgent; * Class to load images. */ class ImageLoader { - String url; - ImageCache cache; - boolean valid = true; - FOUserAgent userAgent; - FopImage image = null; + + private String url; + private ImageCache cache; + private boolean valid = true; + private FOUserAgent userAgent; + private FopImage image = null; - public ImageLoader(String u, ImageCache c, FOUserAgent ua) { - url = u; - cache = c; - userAgent = ua; + /** + * Main constructor. + * @param url URL to the image + * @param cache Image cache + * @param ua User agent + */ + public ImageLoader(String url, ImageCache cache, FOUserAgent ua) { + this.url = url; + this.cache = cache; + this.userAgent = ua; } + /** + * Loads the image. + * @return the loaded image + */ public synchronized FopImage loadImage() { if (!valid || image != null) { return image; } - String base = userAgent.getBaseURL(); - image = ImageFactory.loadImage(url, base, userAgent); + image = ImageFactory.loadImage(url, userAgent); if (image == null) { cache.invalidateImage(url, userAgent); valid = false; |