diff options
author | William Victor Mote <vmote@apache.org> | 2003-08-28 17:13:22 +0000 |
---|---|---|
committer | William Victor Mote <vmote@apache.org> | 2003-08-28 17:13:22 +0000 |
commit | c52ee3903708f476112e2e2328b3954f42f5c04a (patch) | |
tree | f5bfd87a6eecbadfc84f7a488fa58ae86536854d | |
parent | 72c8c4e583fcd9e8d94ccc4022e0a36cacd4bde8 (diff) | |
download | xmlgraphics-fop-c52ee3903708f476112e2e2328b3954f42f5c04a.tar.gz xmlgraphics-fop-c52ee3903708f476112e2e2328b3954f42f5c04a.zip |
move setDefaultXMLHandler() and addXMLHandler() from apps/FOUserAgent to render/AbstractRenderer
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196867 13f79535-47bb-0310-9956-ffa450edef68
6 files changed, 34 insertions, 32 deletions
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 437c2d5fb..27a3a7532 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -90,8 +90,8 @@ import org.apache.fop.render.RendererContext; public class FOUserAgent implements LogEnabled { private Logger log; - private Map defaults = new java.util.HashMap(); - private Map handlers = new java.util.HashMap(); + public Map defaults = new java.util.HashMap(); + public Map handlers = new java.util.HashMap(); private String baseURL; private PDFEncryptionParams pdfEncryptionParams; private float px2mm = 0.35277777777777777778f; //72dpi (=25.4/dpi) @@ -189,30 +189,6 @@ public class FOUserAgent implements LogEnabled { } /** - * Set the default xml handler for the given mime type. - * @param mime MIME type - * @param handler XMLHandler to use - */ - public void setDefaultXMLHandler(String mime, XMLHandler handler) { - defaults.put(mime, handler); - } - - /** - * Add an xml handler for the given mime type and xml namespace. - * @param mime MIME type - * @param ns Namespace URI - * @param handler XMLHandler to use - */ - public void addXMLHandler(String mime, String ns, XMLHandler handler) { - Map mh = (Map) handlers.get(mime); - if (mh == null) { - mh = new java.util.HashMap(); - handlers.put(mime, mh); - } - mh.put(ns, handler); - } - - /** * Render the xml document with the given xml namespace. * The Render Context is by the handle to render into the current * rendering target. diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index c9d756923..a9de32be6 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -676,5 +676,31 @@ public abstract class AbstractRenderer extends AbstractLogEnabled } } + /** + * Set the default xml handler for the given mime type. + * @param mime MIME type + * @param handler XMLHandler to use + */ + public void setDefaultXMLHandler(FOUserAgent foua, String mime, + XMLHandler handler) { + foua.defaults.put(mime, handler); + } + + /** + * Add an xml handler for the given mime type and xml namespace. + * @param mime MIME type + * @param ns Namespace URI + * @param handler XMLHandler to use + */ + public void addXMLHandler(FOUserAgent foua, String mime, String ns, + XMLHandler handler) { + Map mh = (Map) foua.handlers.get(mime); + if (mh == null) { + mh = new java.util.HashMap(); + foua.handlers.put(mime, mh); + } + mh.put(ns, handler); + } + } diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index f810c852e..42c917315 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -260,7 +260,7 @@ public class PDFRenderer extends PrintRenderer { PDFXMLHandler xmlHandler = new PDFXMLHandler(); //userAgent.setDefaultXMLHandler(MIME_TYPE, xmlHandler); String svg = "http://www.w3.org/2000/svg"; - userAgent.addXMLHandler(MIME_TYPE, svg, xmlHandler); + addXMLHandler(userAgent, MIME_TYPE, svg, xmlHandler); } /** diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index d21bebc7b..c71b08373 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -143,7 +143,7 @@ public class PSRenderer extends AbstractRenderer { PSXMLHandler xmlHandler = new PSXMLHandler(); //userAgent.setDefaultXMLHandler(MIME_TYPE, xmlHandler); String svg = "http://www.w3.org/2000/svg"; - userAgent.addXMLHandler(MIME_TYPE, svg, xmlHandler); + addXMLHandler(userAgent, MIME_TYPE, svg, xmlHandler); } /** diff --git a/src/java/org/apache/fop/render/svg/SVGRenderer.java b/src/java/org/apache/fop/render/svg/SVGRenderer.java index 0a65b0b2a..5bed6232e 100644 --- a/src/java/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/java/org/apache/fop/render/svg/SVGRenderer.java @@ -161,8 +161,8 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { */ public void setUserAgent(FOUserAgent agent) { super.setUserAgent(agent); - userAgent.setDefaultXMLHandler(SVG_MIME_TYPE, this); - userAgent.addXMLHandler(SVG_MIME_TYPE, SVG_NAMESPACE, this); + setDefaultXMLHandler(userAgent, SVG_MIME_TYPE, this); + addXMLHandler(userAgent, SVG_MIME_TYPE, SVG_NAMESPACE, this); } /** diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 2637bc406..6d6af46f3 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -147,9 +147,9 @@ public class XMLRenderer extends AbstractRenderer { // //userAgent.addExtensionHandler(); XMLHandler handler = new XMLXMLHandler(); - userAgent.setDefaultXMLHandler(XML_MIME_TYPE, handler); + setDefaultXMLHandler(userAgent, XML_MIME_TYPE, handler); String svg = "http://www.w3.org/2000/svg"; - userAgent.addXMLHandler(XML_MIME_TYPE, svg, handler); + addXMLHandler(userAgent, XML_MIME_TYPE, svg, handler); } /** |