From: Luis Bernardo Date: Sun, 24 Nov 2013 00:57:26 +0000 (+0000) Subject: FOP-2314: Caching xmlParserClassName in org.apache.fop.svg.SimpleSVGUserAgent; patch... X-Git-Tag: fop-2_0~157 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ca51f4c9117dfba007fc26b9b6ebc2c0914d9d3d;p=xmlgraphics-fop.git FOP-2314: Caching xmlParserClassName in org.apache.fop.svg.SimpleSVGUserAgent; patch submitted by Gonzalo Vasquez git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1544897 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java index 2b27945a4..132c633dc 100644 --- a/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java +++ b/src/java/org/apache/fop/svg/SimpleSVGUserAgent.java @@ -23,8 +23,11 @@ import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; +import org.xml.sax.SAXException; + import org.apache.batik.bridge.UserAgentAdapter; /** @@ -79,17 +82,28 @@ public class SimpleSVGUserAgent extends UserAgentAdapter { return null; // userStyleSheetURI; } + + private static final String XML_PARSER_CLASS_NAME; + + static { + String result; + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + result = factory.newSAXParser().getXMLReader().getClass().getName(); + } catch (SAXException e) { + result = null; + } catch (ParserConfigurationException e) { + result = null; + } + XML_PARSER_CLASS_NAME = result; + } + /** * Returns the class name of the XML parser. * @return the XML parser class name */ public String getXMLParserClassName() { - try { - SAXParserFactory factory = SAXParserFactory.newInstance(); - return factory.newSAXParser().getXMLReader().getClass().getName(); - } catch (Exception e) { - return null; - } + return XML_PARSER_CLASS_NAME; } /**